diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2e5e1524..81bbf751 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -5,6 +5,7 @@ namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Sentry\Laravel\Integration; use Throwable; class Handler extends ExceptionHandler @@ -37,16 +38,7 @@ class Handler extends ExceptionHandler public function register() { $this->reportable(function (Throwable $e) { - // + Integration::captureUnhandledException($e); }); } - - 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 0bcb213c..4b42f01d 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "matthewbdaly/laravel-azure-storage": "^2.0", "netopia/payment": "^1.0", "plank/laravel-mediable": "^5.9", - "sentry/sentry-laravel": "^4.1", + "sentry/sentry-laravel": "^4.2", "spatie/laravel-responsecache": "^7.4", "spatie/laravel-translatable": "^6.5", "spatie/laravel-translation-loader": "^2.7", diff --git a/composer.lock b/composer.lock index 595e7383..5e1c4021 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "07a8fc4b1abe562ccf49181f3cb8caf3", + "content-hash": "63225cad315b133a0dfadb5021c32956", "packages": [ { "name": "andreiio/blade-remix-icon", @@ -5878,16 +5878,16 @@ }, { "name": "sentry/sentry", - "version": "4.3.1", + "version": "4.5.0", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "cd89f230bda0833cb9992ebe9a1b7d24d6ee245b" + "reference": "a6e06f0b7a17e7f68e11297427da76bfe01a3ca3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/cd89f230bda0833cb9992ebe9a1b7d24d6ee245b", - "reference": "cd89f230bda0833cb9992ebe9a1b7d24d6ee245b", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/a6e06f0b7a17e7f68e11297427da76bfe01a3ca3", + "reference": "a6e06f0b7a17e7f68e11297427da76bfe01a3ca3", "shasum": "" }, "require": { @@ -5951,7 +5951,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/4.3.1" + "source": "https://github.com/getsentry/sentry-php/tree/4.5.0" }, "funding": [ { @@ -5963,28 +5963,28 @@ "type": "custom" } ], - "time": "2023-12-22T18:46:49+00:00" + "time": "2024-01-29T16:16:10+00:00" }, { "name": "sentry/sentry-laravel", - "version": "4.1.1", + "version": "4.2.0", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-laravel.git", - "reference": "792944c1d0b7342d1635ac6d72fbdc2f32486310" + "reference": "054638ac05d7668e8b2c636e66fed5b5b468f11f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/792944c1d0b7342d1635ac6d72fbdc2f32486310", - "reference": "792944c1d0b7342d1635ac6d72fbdc2f32486310", + "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/054638ac05d7668e8b2c636e66fed5b5b468f11f", + "reference": "054638ac05d7668e8b2c636e66fed5b5b468f11f", "shasum": "" }, "require": { "illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", "nyholm/psr7": "^1.0", "php": "^7.2 | ^8.0", - "sentry/sentry": "^4.0", - "symfony/psr-http-message-bridge": "^1.0 | ^2.0" + "sentry/sentry": "^4.5", + "symfony/psr-http-message-bridge": "^1.0 | ^2.0 | ^6.0 | ^7.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.11", @@ -6040,7 +6040,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-laravel/issues", - "source": "https://github.com/getsentry/sentry-laravel/tree/4.1.1" + "source": "https://github.com/getsentry/sentry-laravel/tree/4.2.0" }, "funding": [ { @@ -6052,7 +6052,7 @@ "type": "custom" } ], - "time": "2023-12-12T22:17:13+00:00" + "time": "2024-01-29T17:08:18+00:00" }, { "name": "spatie/laravel-package-tools", @@ -8302,43 +8302,38 @@ }, { "name": "symfony/psr-http-message-bridge", - "version": "v2.3.1", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e" + "reference": "d9fadaf9541d7c01c307e48905d7ce1dbee6bf38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/581ca6067eb62640de5ff08ee1ba6850a0ee472e", - "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/d9fadaf9541d7c01c307e48905d7ce1dbee6bf38", + "reference": "d9fadaf9541d7c01c307e48905d7ce1dbee6bf38", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/http-message": "^1.0 || ^2.0", - "symfony/deprecation-contracts": "^2.5 || ^3.0", - "symfony/http-foundation": "^5.4 || ^6.0" + "php": ">=8.2", + "psr/http-message": "^1.0|^2.0", + "symfony/http-foundation": "^6.4|^7.0" + }, + "conflict": { + "php-http/discovery": "<1.15", + "symfony/http-kernel": "<6.4" }, "require-dev": { "nyholm/psr7": "^1.1", - "psr/log": "^1.1 || ^2 || ^3", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/config": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/framework-bundle": "^5.4 || ^6.0", - "symfony/http-kernel": "^5.4 || ^6.0", - "symfony/phpunit-bridge": "^6.2" - }, - "suggest": { - "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" + "php-http/discovery": "^1.15", + "psr/log": "^1.1.4|^2|^3", + "symfony/browser-kit": "^6.4|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/framework-bundle": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0" }, "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-main": "2.3-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Bridge\\PsrHttpMessage\\": "" @@ -8358,11 +8353,11 @@ }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" } ], "description": "PSR HTTP message bridge", - "homepage": "http://symfony.com", + "homepage": "https://symfony.com", "keywords": [ "http", "http-message", @@ -8370,8 +8365,7 @@ "psr-7" ], "support": { - "issues": "https://github.com/symfony/psr-http-message-bridge/issues", - "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.3.1" + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v7.0.3" }, "funding": [ { @@ -8387,7 +8381,7 @@ "type": "tidelift" } ], - "time": "2023-07-26T11:53:26+00:00" + "time": "2024-01-23T15:02:46+00:00" }, { "name": "symfony/routing", diff --git a/config/sentry.php b/config/sentry.php index e7a69b2a..384ab423 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -4,56 +4,102 @@ return [ + // @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ 'dsn' => 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')), + // The release version of your application + // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) + // 'release' => env('SENTRY_RELEASE'), - // When left empty or `null` the Laravel environment will be used + // When left empty or `null` the Laravel environment will be used (usually discovered from `APP_ENV` in your `.env`) 'environment' => env('SENTRY_ENVIRONMENT'), + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#sample-rate + 'sample_rate' => env('SENTRY_SAMPLE_RATE') === null ? 1.0 : (float) env('SENTRY_SAMPLE_RATE'), + + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate + 'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float) env('SENTRY_TRACES_SAMPLE_RATE'), + + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#profiles-sample-rate + 'profiles_sample_rate' => env('SENTRY_PROFILES_SAMPLE_RATE') === null ? null : (float) env('SENTRY_PROFILES_SAMPLE_RATE'), + + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send-default-pii + 'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false), + + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#ignore-exceptions + // 'ignore_exceptions' => [], + + // @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#ignore-transactions + // 'ignore_transactions' => [], + + // Breadcrumb specific configuration 'breadcrumbs' => [ - // Capture Laravel logs in breadcrumbs - 'logs' => true, + // Capture Laravel logs as breadcrumbs + 'logs' => env('SENTRY_BREADCRUMBS_LOGS_ENABLED', true), + + // Capture Laravel cache events (hits, writes etc.) as breadcrumbs + 'cache' => env('SENTRY_BREADCRUMBS_CACHE_ENABLED', true), + + // Capture Livewire components like routes as breadcrumbs + 'livewire' => env('SENTRY_BREADCRUMBS_LIVEWIRE_ENABLED', true), - // Capture SQL queries in breadcrumbs - 'sql_queries' => true, + // Capture SQL queries as breadcrumbs + 'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true), - // Capture bindings on SQL queries logged in breadcrumbs - 'sql_bindings' => true, + // Capture SQL query bindings (parameters) in SQL query breadcrumbs + 'sql_bindings' => env('SENTRY_BREADCRUMBS_SQL_BINDINGS_ENABLED', false), - // Capture queue job information in breadcrumbs - 'queue_info' => true, + // Capture queue job information as breadcrumbs + 'queue_info' => env('SENTRY_BREADCRUMBS_QUEUE_INFO_ENABLED', true), - // Capture command information in breadcrumbs - 'command_info' => true, + // Capture command information as breadcrumbs + 'command_info' => env('SENTRY_BREADCRUMBS_COMMAND_JOBS_ENABLED', true), + + // Capture HTTP client request information as breadcrumbs + 'http_client_requests' => env('SENTRY_BREADCRUMBS_HTTP_CLIENT_REQUESTS_ENABLED', true), ], + // Performance monitoring specific configuration 'tracing' => [ - // Trace queue jobs as their own transactions + // Trace queue jobs as their own transactions (this enables tracing for queue jobs) 'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false), // Capture queue jobs as spans when executed on the sync driver - 'queue_jobs' => true, + 'queue_jobs' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true), // Capture SQL queries as spans - 'sql_queries' => true, + 'sql_queries' => env('SENTRY_TRACE_SQL_QUERIES_ENABLED', true), - // Try to find out where the SQL query originated from and add it to the query spans - 'sql_origin' => true, + // Capture SQL query bindings (parameters) in SQL query spans + 'sql_bindings' => env('SENTRY_TRACE_SQL_BINDINGS_ENABLED', false), - // Capture views as spans - 'views' => true, + // Capture where the SQL query originated from on the SQL query spans + 'sql_origin' => env('SENTRY_TRACE_SQL_ORIGIN_ENABLED', true), - // Indicates if the tracing integrations supplied by Sentry should be loaded - 'default_integrations' => true, - ], + // Capture views rendered as spans + 'views' => env('SENTRY_TRACE_VIEWS_ENABLED', true), + + // Capture Livewire components as spans + 'livewire' => env('SENTRY_TRACE_LIVEWIRE_ENABLED', true), + + // Capture HTTP client requests as spans + 'http_client_requests' => env('SENTRY_TRACE_HTTP_CLIENT_REQUESTS_ENABLED', true), - // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii - 'send_default_pii' => false, + // Capture Redis operations as spans (this enables Redis events in Laravel) + 'redis_commands' => env('SENTRY_TRACE_REDIS_COMMANDS', false), - 'traces_sample_rate' => (float) (env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), + // Capture where the Redis command originated from on the Redis command spans + 'redis_origin' => env('SENTRY_TRACE_REDIS_ORIGIN_ENABLED', true), - 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), + // Enable tracing for requests without a matching route (404's) + 'missing_routes' => env('SENTRY_TRACE_MISSING_ROUTES_ENABLED', false), + + // Configures if the performance trace should continue after the response has been sent to the user until the application terminates + // This is required to capture any spans that are created after the response has been sent like queue jobs dispatched using `dispatch(...)->afterResponse()` for example + 'continue_after_response' => env('SENTRY_TRACE_CONTINUE_AFTER_RESPONSE', true), + + // Enable the tracing integrations supplied by Sentry (recommended) + 'default_integrations' => env('SENTRY_TRACE_DEFAULT_INTEGRATIONS_ENABLED', true), + ], ];