From 37498111d6c72e6d909ff6a317b616fb0109aa9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Wed, 15 Apr 2026 16:00:47 +0100 Subject: [PATCH] chore: configure production Sentry integration (#291) ## Summary - wire Laravel exception handling into Sentry via `bootstrap/app.php` - add the `sentry_logs` logging channel and document production Sentry env defaults - keep local/example defaults disabled while enabling the production example for logs, traces, and profiles ## Verification - `vendor/bin/pint --dirty --format agent` - `php artisan sentry:test` could not run locally after disabling the local DSN, which is expected - `php artisan test --compact tests/Feature/ExampleTest.php` currently fails because the local Vite manifest is missing at `public/build/manifest.json` --- .env.example | 1 + .env.production.example | 8 +++++++- bootstrap/app.php | 3 ++- config/logging.php | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 1d00d579..64fd3351 100644 --- a/.env.example +++ b/.env.example @@ -98,6 +98,7 @@ STRIPE_PRO_YEARLY_LOOKUP_KEY=whisper_pro_yearly SENTRY_LARAVEL_DSN= SENTRY_TRACES_SAMPLE_RATE=1.0 SENTRY_PROFILES_SAMPLE_RATE=0 +SENTRY_ENABLE_LOGS=false # Docker Service Ports (forwarded to host) FORWARD_DB_PORT=3307 diff --git a/.env.production.example b/.env.production.example index de12533e..78305ab0 100644 --- a/.env.production.example +++ b/.env.production.example @@ -16,7 +16,7 @@ APP_FAKER_LOCALE=en_US # Logging LOG_CHANNEL=stack -LOG_STACK=single +LOG_STACK=single,sentry_logs LOG_LEVEL=error # Database (MySQL) @@ -36,6 +36,12 @@ SESSION_ENCRYPT=true # Queue QUEUE_CONNECTION=database +# Sentry Error Tracking +SENTRY_LARAVEL_DSN= +SENTRY_TRACES_SAMPLE_RATE=1.0 +SENTRY_PROFILES_SAMPLE_RATE=1.0 +SENTRY_ENABLE_LOGS=true + # Redis (internal to container - no configuration needed) REDIS_HOST=127.0.0.1 REDIS_PORT=6379 diff --git a/bootstrap/app.php b/bootstrap/app.php index cf73aa7d..8982046f 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -13,6 +13,7 @@ use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets; use Illuminate\Http\Request; +use Sentry\Laravel\Integration; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -49,5 +50,5 @@ return Application::configure(basePath: dirname(__DIR__)) ]); }) ->withExceptions(function (Exceptions $exceptions): void { - // + Integration::handles($exceptions); })->create(); diff --git a/config/logging.php b/config/logging.php index 9e998a49..14067a29 100644 --- a/config/logging.php +++ b/config/logging.php @@ -118,6 +118,11 @@ return [ 'replace_placeholders' => true, ], + 'sentry_logs' => [ + 'driver' => 'sentry_logs', + 'level' => env('LOG_LEVEL', 'info'), + ], + 'null' => [ 'driver' => 'monolog', 'handler' => NullHandler::class,