diff --git a/.env.example b/.env.example index 300aaef..f29f8b8 100644 --- a/.env.example +++ b/.env.example @@ -26,22 +26,25 @@ REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 -#Change this only if you know what you are doing +# Default Queue Connection Name QUEUE_CONNECTION=redis -#Change this only if you know what you are doing +# Default Cache Store CACHE_DRIVER=redis -#Change this only if you know what you are doing +# Default Session Driver +SESSION_DRIVER=redis + +# The disk on which to store the uploaded files MIXPOST_DISK=public -#Change this only if you know what you are doing +# Default log channel for Mixpost MIXPOST_LOG_CHANNEL=mixpost -#This is the path which Mixpost will use to load its core routes and assets +# This is the path which Mixpost will use to load its core routes and assets MIXPOST_CORE_PATH=mixpost -#SMTP +# SMTP MAIL_MAILER=smtp MAIL_HOST=smtp.mailgun.org MAIL_PORT=587 @@ -49,4 +52,7 @@ MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="hello@example.com" -MAIL_FROM_NAME="${APP_NAME}" \ No newline at end of file +MAIL_FROM_NAME="${APP_NAME}" + +# Sentry +SENTRY_LARAVEL_DSN=null \ No newline at end of file diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 56af264..09ff238 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; +use Sentry\Laravel\Integration; class Handler extends ExceptionHandler { @@ -24,7 +25,7 @@ class Handler extends ExceptionHandler public function register(): void { $this->reportable(function (Throwable $e) { - // + Integration::captureUnhandledException($e); }); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 1fb53dc..494c050 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -60,6 +60,7 @@ class Kernel extends HttpKernel 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..1e99714 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,8 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Inovector\Mixpost\Mixpost; +use Sentry\Laravel\Integration; class AppServiceProvider extends ServiceProvider { @@ -11,7 +13,9 @@ class AppServiceProvider extends ServiceProvider */ public function register(): void { - // + Mixpost::report(function($exception) { + Integration::captureUnhandledException($exception); + }); } /** diff --git a/composer.json b/composer.json index 9cd9448..fd7a3fe 100644 --- a/composer.json +++ b/composer.json @@ -7,10 +7,11 @@ "php": "^8.1", "doctrine/dbal": "^3.6", "guzzlehttp/guzzle": "^7.2", + "inovector/mixpost-enterprise": "^1.0", "laravel/framework": "^10.8", "laravel/horizon": "^5.15", "laravel/tinker": "^2.8", - "inovector/mixpost-enterprise": "^1.0" + "sentry/sentry-laravel": "^3.8" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/config/sentry.php b/config/sentry.php new file mode 100644 index 0000000..6476e31 --- /dev/null +++ b/config/sentry.php @@ -0,0 +1,99 @@ + env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), + + // 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 (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), + + // Breadcrumb specific configuration + 'breadcrumbs' => [ + // 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 as breadcrumbs + 'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true), + + // Capture SQL query bindings (parameters) in SQL query breadcrumbs + 'sql_bindings' => env('SENTRY_BREADCRUMBS_SQL_BINDINGS_ENABLED', false), + + // Capture queue job information as breadcrumbs + 'queue_info' => env('SENTRY_BREADCRUMBS_QUEUE_INFO_ENABLED', 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 (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' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true), + + // Capture SQL queries as spans + 'sql_queries' => env('SENTRY_TRACE_SQL_QUERIES_ENABLED', true), + + // Capture where the SQL query originated from on the SQL query spans + 'sql_origin' => env('SENTRY_TRACE_SQL_ORIGIN_ENABLED', 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), + + // Capture Redis operations as spans (this enables Redis events in Laravel) + 'redis_commands' => env('SENTRY_TRACE_REDIS_COMMANDS', false), + + // Capture where the Redis command originated from on the Redis command spans + 'redis_origin' => env('SENTRY_TRACE_REDIS_ORIGIN_ENABLED', true), + + // 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), + ], + +];