diff --git a/backend/app/Console/Kernel.php b/backend/app/Console/Kernel.php index 9056c7a..34099fd 100644 --- a/backend/app/Console/Kernel.php +++ b/backend/app/Console/Kernel.php @@ -16,9 +16,15 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule): void { - $schedule->job(new UpdateAvailabilityWithSchedulesJob)->everyThirtyMinutes(); - $schedule->job(new NotifyUsersManualModeOn)->dailyAt('7:00'); - $schedule->job(new ResetAvailabilityMinutes)->monthlyOn(1, '0:00'); + $schedule->job(new UpdateAvailabilityWithSchedulesJob) + ->everyThirtyMinutes() + ->sentryMonitor(); + $schedule->job(new NotifyUsersManualModeOn) + ->dailyAt('7:00') + ->sentryMonitor(); + $schedule->job(new ResetAvailabilityMinutes) + ->monthlyOn(1, '0:00') + ->sentryMonitor(); } /** diff --git a/backend/app/Jobs/NotifyUsersManualModeOn.php b/backend/app/Jobs/NotifyUsersManualModeOn.php index 91d699b..ceec3f1 100644 --- a/backend/app/Jobs/NotifyUsersManualModeOn.php +++ b/backend/app/Jobs/NotifyUsersManualModeOn.php @@ -53,4 +53,11 @@ class NotifyUsersManualModeOn implements ShouldQueue ->send(); } } + + public function failed(\Exception $exception) + { + if (app()->bound('sentry')) { + app('sentry')->captureException($exception); + } + } } diff --git a/backend/app/Jobs/ResetAvailabilityMinutes.php b/backend/app/Jobs/ResetAvailabilityMinutes.php index ccad3b2..91ac612 100644 --- a/backend/app/Jobs/ResetAvailabilityMinutes.php +++ b/backend/app/Jobs/ResetAvailabilityMinutes.php @@ -49,4 +49,11 @@ class ResetAvailabilityMinutes implements ShouldQueue $row->save(); } } + + public function failed(\Exception $exception) + { + if (app()->bound('sentry')) { + app('sentry')->captureException($exception); + } + } } diff --git a/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php b/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php index 14a6388..e6ef30a 100644 --- a/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php +++ b/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php @@ -96,4 +96,11 @@ class UpdateAvailabilityWithSchedulesJob implements ShouldQueue } } } + + public function failed(\Exception $exception) + { + if (app()->bound('sentry')) { + app('sentry')->captureException($exception); + } + } } diff --git a/backend/app/Telegram/WebhookController.php b/backend/app/Telegram/WebhookController.php index 67f4d29..8546956 100644 --- a/backend/app/Telegram/WebhookController.php +++ b/backend/app/Telegram/WebhookController.php @@ -9,6 +9,8 @@ use App\Utils\Availability; use DefStudio\Telegraph\Facades\Telegraph; +use Sentry\State\Scope; + class WebhookController extends \DefStudio\Telegraph\Handlers\WebhookHandler { @@ -27,6 +29,16 @@ class WebhookController extends private function user(): User|null { if($this->user) return $this->user; $this->user = $this->message->from()->storage()->get('user'); + + if(app()->bound('sentry')) { + \Sentry\configureScope(function (Scope $scope): void { + $scope->setUser([ + 'id' => $this->user->id, + 'name' => $this->user->name, + ]); + }); + } + return $this->user; } diff --git a/backend/config/logging.php b/backend/config/logging.php index 5aa1dbb..f6e2528 100644 --- a/backend/config/logging.php +++ b/backend/config/logging.php @@ -53,10 +53,14 @@ return [ 'channels' => [ 'stack' => [ 'driver' => 'stack', - 'channels' => ['single'], + 'channels' => ['single', 'sentry'], 'ignore_exceptions' => false, ], + 'sentry' => [ + 'driver' => 'sentry', + ], + 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'),