From fb710111cba45e25e677ce240a575556bd3e9c75 Mon Sep 17 00:00:00 2001 From: vedatakdogan Date: Mon, 30 Nov 2020 18:07:59 +0300 Subject: [PATCH] added exception --- app/Exceptions/ExceptionHandler.php | 21 +++++++++++++++++ composer.json | 3 ++- config/app.php | 7 ++++++ config/sentry.php | 36 +++++++++++++++++++++++++++++ config/streams.php | 12 ++++++---- 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 app/Exceptions/ExceptionHandler.php create mode 100644 config/sentry.php diff --git a/app/Exceptions/ExceptionHandler.php b/app/Exceptions/ExceptionHandler.php new file mode 100644 index 000000000..f08304731 --- /dev/null +++ b/app/Exceptions/ExceptionHandler.php @@ -0,0 +1,21 @@ +bound('sentry') && $this->shouldReport($e)) { + app('sentry')->captureException($e); + } + + parent::report($e); + } +} diff --git a/composer.json b/composer.json index f4ff8997a..57dcf5107 100644 --- a/composer.json +++ b/composer.json @@ -79,7 +79,8 @@ "visiosoft/integer-field_type": "~2.1.0", "visiosoft/list-field_type": "*", "guzzlehttp/guzzle": "~6.3.3", - "composer/composer": "^1.6" + "composer/composer": "^1.6", + "sentry/sentry-laravel": "*" }, "replace": { "anomaly/streams-platform": "*" diff --git a/config/app.php b/config/app.php index d30a0f6a8..83cf80506 100644 --- a/config/app.php +++ b/config/app.php @@ -1,5 +1,8 @@ Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, + 'Sentry' => Sentry\Laravel\Facade::class, + ], diff --git a/config/sentry.php b/config/sentry.php new file mode 100644 index 000000000..bd95322af --- /dev/null +++ b/config/sentry.php @@ -0,0 +1,36 @@ + 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/error-reporting/configuration/?platform=php#send-default-pii + 'send_default_pii' => false, + + 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 1)), + + 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), + +]; diff --git a/config/streams.php b/config/streams.php index 766f261e5..a05e9b5d3 100644 --- a/config/streams.php +++ b/config/streams.php @@ -1,7 +1,9 @@ [], + 'bindings' => [ + 'Anomaly\Streams\Platform\Exception\ExceptionHandler' => ExceptionHandler::class + ], /* |-------------------------------------------------------------------------- @@ -118,7 +122,7 @@ return [ */ 'middleware_priority' => [], - + /* |-------------------------------------------------------------------------- | View Overrides @@ -129,7 +133,7 @@ return [ */ 'overrides' => [], - + /* |-------------------------------------------------------------------------- | Control Panel Customization