Skip to content

Commit c9de0c9

Browse files
authored
Add Sentry logging (#393) (#394)
1 parent 69a3030 commit c9de0c9

File tree

3 files changed

+316
-5
lines changed

3 files changed

+316
-5
lines changed

backend/app/Exceptions/Handler.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HiEvents\Exceptions;
44

55
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Sentry\Laravel\Facade as Sentry;
67
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
78
use Throwable;
89

@@ -14,7 +15,7 @@ class Handler extends ExceptionHandler
1415
* @var array
1516
*/
1617
protected $dontReport = [
17-
//
18+
// Add exceptions that shouldn't be reported
1819
];
1920

2021
/**
@@ -30,20 +31,25 @@ class Handler extends ExceptionHandler
3031
/**
3132
* Report or log an exception.
3233
*
33-
* @param \Exception $e
34+
* @param Throwable $e
3435
* @return void
36+
* @throws Throwable
3537
*/
3638
public function report(Throwable $e)
3739
{
40+
if ($this->shouldReport($e)) {
41+
Sentry::captureException($e);
42+
}
43+
3844
parent::report($e);
3945
}
4046

4147
/**
4248
* Render an exception into an HTTP response.
4349
*
4450
* @param \Illuminate\Http\Request $request
45-
* @param \Exception $exception
46-
* @return \Illuminate\Http\JsonResponse
51+
* @param Throwable $exception
52+
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
4753
* @throws Throwable
4854
*/
4955
public function render($request, Throwable $exception)

backend/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"maatwebsite/excel": "^3.1",
2323
"nette/php-generator": "^4.0",
2424
"php-open-source-saver/jwt-auth": "^2.1",
25+
"sentry/sentry-laravel": "^4.13",
2526
"spatie/icalendar-generator": "^2.8",
2627
"spatie/laravel-data": "^4.11",
2728
"spatie/laravel-webhook-server": "^3.8",

backend/composer.lock

Lines changed: 305 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)