zing / laravel-sentry
Provides sentry context middleware.
Installs: 1 050
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- illuminate/container: ^8.0 || ^9.0 || ^10.0 || ^11.0
- sentry/sentry-laravel: ^2.3.1 || ^3.0.0 || ^4.0.0
Requires (Dev)
- mockery/mockery: ~1.3.3 || ^1.4.2
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpstan/phpstan-mockery: ^1.0
- phpunit/phpunit: ^9.3.3 || ^10.0
- zing/coding-standard: ^6.4 || ^7.0
README
Requirements
Require Laravel Sentry using Composer:
composer require zing/laravel-sentry
Usage
Add user context
use Zing\LaravelSentry\Middleware\SentryContext; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { protected $middleware = [ // ... SentryContext::class, ]; // ... }
Custom user context
use Zing\LaravelSentry\Middleware\SentryContext; class CustomSentryContext extends SentryContext { /** * @param \Zing\LaravelSentry\Tests\User $user * * @return array<string, mixed>|mixed[] */ protected function resolveUserContext(string $guard, \Illuminate\Contracts\Auth\Authenticatable $user): array { if ($guard === 'api') { return [ 'id' => $user->getAuthIdentifier(), 'username' => $user->username, ]; } return parent::resolveUserContext($guard, $user); } }
License
Laravel Sentry is an open-sourced software licensed under the MIT license.