RESAZIP-PC\resaz

update

...@@ -99,26 +99,29 @@ class DaitoExceptionNotifierManager ...@@ -99,26 +99,29 @@ class DaitoExceptionNotifierManager
99 $arrSummaryWidgets = array( 99 $arrSummaryWidgets = array(
100 $this->makeDecoratedTextWidget('time', date('Y-m-d H:i:s')), 100 $this->makeDecoratedTextWidget('time', date('Y-m-d H:i:s')),
101 $this->makeDecoratedTextWidget('action', $action), 101 $this->makeDecoratedTextWidget('action', $action),
102 - $this->makeDecoratedTextWidget('file', (string) $throwable->getFile()), 102 + $this->makeCompactFileLineWidget((string) $throwable->getFile(), (int) $throwable->getLine()),
103 - $this->makeDecoratedTextWidget('line', (string) $throwable->getLine()), 103 + array(
104 - $this->makeDecoratedTextWidget( 104 + 'textParagraph' => array(
105 - 'message', 105 + 'text' => '<b>message</b><br/><font color="#d93025">'
106 + . $this->escapeForGoogleChat(
106 $this->limitText((string) $throwable->getMessage(), (int) config('daito-exception-notifier.message_max_length', 1000)) 107 $this->limitText((string) $throwable->getMessage(), (int) config('daito-exception-notifier.message_max_length', 1000))
108 + )
109 + . '</font>',
110 + ),
107 ), 111 ),
108 ); 112 );
109 113
110 - if ((bool) config('daito-exception-notifier.trace_include_first_app_frame', true) 114 + // if ((bool) config('daito-exception-notifier.trace_include_first_app_frame', true)
111 - && $arrTraceData['first_app_frame'] !== '' 115 + // && $arrTraceData['first_app_frame'] !== ''
112 - ) { 116 + // ) {
113 - $arrSummaryWidgets[] = $this->makeDecoratedTextWidget('first_app_frame', $arrTraceData['first_app_frame']); 117 + // $arrSummaryWidgets[] = $this->makeDecoratedTextWidget('first_app_frame', $arrTraceData['first_app_frame']);
114 - } 118 + // }
115 119
116 return array( 120 return array(
117 'cardId' => 'daito-exception-alert', 121 'cardId' => 'daito-exception-alert',
118 'card' => array( 122 'card' => array(
119 'header' => array( 123 'header' => array(
120 - 'title' => (string) config('daito-exception-notifier.card_title', 'Exception Alert'), 124 + 'title' => '🚨 ' . (string) config('daito-exception-notifier.card_title', 'Exception Alert'),
121 - 'subtitle' => $action,
122 ), 125 ),
123 'sections' => array( 126 'sections' => array(
124 array( 127 array(
...@@ -307,6 +310,42 @@ class DaitoExceptionNotifierManager ...@@ -307,6 +310,42 @@ class DaitoExceptionNotifierManager
307 ); 310 );
308 } 311 }
309 312
313 + private function makeCompactFileLineWidget(string $filePath, int $line): array
314 + {
315 + $displayPath = $this->formatCompactPath($filePath);
316 + $lineText = $line > 0 ? (string) $line : '?';
317 +
318 + return array(
319 + 'textParagraph' => array(
320 + 'text' => '<b>location</b> ' . $this->escapeForGoogleChat($displayPath) . ':' . $lineText,
321 + ),
322 + );
323 + }
324 +
325 + private function formatCompactPath(string $filePath): string
326 + {
327 + if ($filePath === '') {
328 + return '[unknown]';
329 + }
330 +
331 + $normalizedPath = str_replace('\\', '/', $filePath);
332 + if (function_exists('base_path')) {
333 + $rootDir = str_replace('\\', '/', base_path());
334 + if ($rootDir !== '' && strpos($normalizedPath, $rootDir . '/') === 0) {
335 + $normalizedPath = substr($normalizedPath, strlen($rootDir) + 1);
336 + }
337 + }
338 +
339 + $arrPathParts = explode('/', $normalizedPath);
340 + $pathPartCount = count($arrPathParts);
341 + if ($pathPartCount > 4) {
342 + $arrPathParts = array_slice($arrPathParts, $pathPartCount - 4);
343 + $normalizedPath = '.../' . implode('/', $arrPathParts);
344 + }
345 +
346 + return $normalizedPath;
347 + }
348 +
310 private function limitText(string $text, int $maxLength): string 349 private function limitText(string $text, int $maxLength): string
311 { 350 {
312 $maxLength = max(1, $maxLength); 351 $maxLength = max(1, $maxLength);
......