Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
sentry
/
sentry-laravel
/
src
/
Sentry
/
Laravel
/
Integration
:
LaravelContextIntegration.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Sentry\Laravel\Integration; use Illuminate\Support\Facades\Context; use Sentry\Event; use Sentry\EventHint; use Sentry\EventType; use Sentry\Integration\IntegrationInterface; use Sentry\SentrySdk; use Sentry\State\Scope; class LaravelContextIntegration implements IntegrationInterface { public function setupOnce(): void { // Context was introduced in Laravel 11 so we need to check if we can use it otherwise we skip the event processor if (!class_exists(Context::class)) { return; } Scope::addGlobalEventProcessor(static function (Event $event, ?EventHint $hint = null): Event { $self = SentrySdk::getCurrentHub()->getIntegration(self::class); if (!$self instanceof self) { return $event; } if (!in_array($event->getType(), [EventType::event(), EventType::transaction()], true)) { return $event; } $event->setContext('laravel', Context::all()); return $event; }); } }