Sentry
Description
Sentry integrates Laravel Enso with Sentry error reporting.
The package provides a small exception-reporting helper that enriches captured events with the current Enso user and role, deduplicates repeated exceptions for a configurable interval, stores the last Sentry event id per authenticated user, and exposes an authenticated endpoint that allows the frontend to retrieve that event id.
It is designed to complement Enso's backend exception pipeline and frontend error-reporting flows without requiring application code to talk to the Sentry SDK directly.
Installation
Install the package in an application that already uses the Sentry Laravel SDK:
composer require laravel-enso/sentry
If needed, publish the package config:
php artisan vendor:publish --tag=enso-sentry-config
Default configuration:
return [
'dedupeInterval' => 5,
];
Features
- Reports unhandled exceptions through the Sentry Laravel integration.
- Enriches Sentry scope with the authenticated Enso user id, name, email, and role.
- Deduplicates repeated exceptions for a configurable interval.
- Stores the latest Sentry event id per authenticated user in cache.
- Exposes an authenticated API endpoint for reading the current event id from the frontend.
- Falls back to the file cache store for Redis exceptions during dedupe checks.
Usage
Report an exception through the package handler:
use LaravelEnso\Sentry\Exceptions\Handler;
Handler::report($exception);
Read the current event id from backend code:
$eventId = Handler::eventId();
The frontend can retrieve the same value from:
route('sentry');
Which returns:
{
"eventId": "..."
}
Tip
The handler stores the event id only when the application is running in production and an authenticated user is available.
API
Route
Authenticated endpoint:
GET /api/sentry
Route name:
sentry
Middleware:
apiauth
Controller
LaravelEnso\Sentry\Http\Controllers\Sentry
Returns:
eventId
Exception Handler Helper
LaravelEnso\Sentry\Exceptions\Handler
Public methods:
report(Throwable $exception): voideventId(): ?string
Behavior:
- skips duplicate exceptions within the dedupe interval
- resolves the current user across the configured default guard,
web, andsanctum - sends the exception to Sentry as an unhandled exception
- stores the last event id per authenticated user when running in production
Configuration
config/enso/sentry.php
Keys:
dedupeInterval
Depends On
Framework dependency:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!