|
7 | 7 | use Sentry\State\HubInterface; |
8 | 8 | use Illuminate\Log\LogManager; |
9 | 9 | use Laravel\Lumen\Application as Lumen; |
10 | | -use Sentry\Integration\IntegrationInterface; |
| 10 | +use Sentry\Integration as SdkIntegration; |
11 | 11 | use Illuminate\Foundation\Application as Laravel; |
12 | 12 | use Illuminate\Support\ServiceProvider as IlluminateServiceProvider; |
13 | 13 |
|
@@ -123,6 +123,31 @@ protected function configureAndRegisterClient(): void |
123 | 123 | $clientBuilder->setSdkIdentifier(Version::SDK_IDENTIFIER); |
124 | 124 | $clientBuilder->setSdkVersion(Version::SDK_VERSION); |
125 | 125 |
|
| 126 | + $options = $clientBuilder->getOptions(); |
| 127 | + |
| 128 | + if ($options->hasDefaultIntegrations()) { |
| 129 | + $integrations = $options->getIntegrations(); |
| 130 | + |
| 131 | + // Remove the default error and fatal exception listeners to let Laravel handle those |
| 132 | + // itself. These event are still bubbling up through the documented changes in the users |
| 133 | + // `ExceptionHandler` of their application or through the log channel integration to Sentry |
| 134 | + $options->setIntegrations(array_filter($integrations, static function (SdkIntegration\IntegrationInterface $integration): bool { |
| 135 | + if ($integration instanceof SdkIntegration\ErrorListenerIntegration) { |
| 136 | + return false; |
| 137 | + } |
| 138 | + |
| 139 | + if ($integration instanceof SdkIntegration\ExceptionListenerIntegration) { |
| 140 | + return false; |
| 141 | + } |
| 142 | + |
| 143 | + if ($integration instanceof SdkIntegration\FatalErrorListenerIntegration) { |
| 144 | + return false; |
| 145 | + } |
| 146 | + |
| 147 | + return true; |
| 148 | + })); |
| 149 | + } |
| 150 | + |
126 | 151 | $hub = new Hub($clientBuilder->getClient()); |
127 | 152 |
|
128 | 153 | Integration::setCurrentHub($hub); |
@@ -157,7 +182,7 @@ private function getIntegrations(): array |
157 | 182 | $userIntegrations = $this->getUserConfig()['integrations'] ?? []; |
158 | 183 |
|
159 | 184 | foreach ($userIntegrations as $userIntegration) { |
160 | | - if ($userIntegration instanceof IntegrationInterface) { |
| 185 | + if ($userIntegration instanceof SdkIntegration\IntegrationInterface) { |
161 | 186 | $integrations[] = $userIntegration; |
162 | 187 | } elseif (\is_string($userIntegration)) { |
163 | 188 | $integrations[] = $this->app->make($userIntegration); |
|
0 commit comments