From c9c35079501e82f8d166afc52417a123338e3238 Mon Sep 17 00:00:00 2001 From: saeid Date: Thu, 28 Jan 2021 17:57:29 +0330 Subject: [PATCH] add sentry --- app/Exceptions/Handler.php | 4 ++++ composer.json | 3 ++- config/sentry.php | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 config/sentry.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index b02a0b2..a464486 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -36,6 +36,10 @@ class Handler extends ExceptionHandler */ public function report(Throwable $exception) { + if (app()->bound('sentry') && $this->shouldReport($exception)) { + app('sentry')->captureException($exception); + } + parent::report($exception); } diff --git a/composer.json b/composer.json index a193c27..2817a37 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "laravel/tinker": "^2.0", "maatwebsite/excel": "^3.1", "nestedset/willaarts": "^5.0.7", + "sentry/sentry-laravel": "^2.3", "spatie/laravel-medialibrary": "^8.0.0", "wm/blog": "dev-master", "wm/common": "dev-master", @@ -76,7 +77,7 @@ "@php artisan key:generate --ansi" ] }, - + "repositories": [ { "type": "vcs", diff --git a/config/sentry.php b/config/sentry.php new file mode 100644 index 0000000..b283146 --- /dev/null +++ b/config/sentry.php @@ -0,0 +1,37 @@ + env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), + + // capture release as git sha + // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), + + // When left empty or `null` the Laravel environment will be used + 'environment' => env('SENTRY_ENVIRONMENT'), + + 'breadcrumbs' => [ + // Capture Laravel logs in breadcrumbs + 'logs' => true, + + // Capture SQL queries in breadcrumbs + 'sql_queries' => true, + + // Capture bindings on SQL queries logged in breadcrumbs + 'sql_bindings' => true, + + // Capture queue job information in breadcrumbs + 'queue_info' => true, + + // Capture command information in breadcrumbs + 'command_info' => true, + ], + + // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii + 'send_default_pii' => false, + + 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), + + 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), + +];