I added sentry.io integration to a Laravel application
public function register()
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
If works fine if there are exceptions. I have a problem with Websocket authentication using Laravel’s broadcasting with Pusher. From time to time it returns 403 when JTW token is refreshed. I cannot reproduce it locally.
How can I log all 4xx and 5xx requests to Sentry?
2
Answers
By default Laravel doesn't report there exceptions
you need an override in Hander.php
I think the best option is to use middleware.
php artisan make:middleware SentryStatusCodeMiddleware
app/Http/Middleware/SentryStatusCodeMiddleware.php
app/Http/Kernel.php
file