Skip to content

Commit a891dd2

Browse files
authored
Merge pull request #42 from CookiesEater/fix-41
Fixed default Sentry integrations
2 parents e31707d + 08d7c76 commit a891dd2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change log
22

3+
## 1.5.1 - 2020-08-24
4+
### Fixed
5+
* Fix double sending of events to Sentry.
6+
* Fix event exclusion ("except" parameter).
7+
38
## 1.5.0 - 2020-07-07
49
1.5.0 released
510

src/SentryTarget.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
namespace notamedia\sentry;
88

9+
use Sentry\ClientBuilder;
10+
use Sentry\Integration\ErrorListenerIntegration;
11+
use Sentry\Integration\ExceptionListenerIntegration;
12+
use Sentry\Integration\FatalErrorListenerIntegration;
13+
use Sentry\Integration\IntegrationInterface;
14+
use Sentry\SentrySdk;
915
use Sentry\Severity;
1016
use Sentry\State\Scope;
1117
use Throwable;
@@ -47,7 +53,28 @@ public function __construct($config = [])
4753
{
4854
parent::__construct($config);
4955

50-
\Sentry\init(array_merge(['dsn' => $this->dsn], $this->clientOptions));
56+
$userOptions = array_merge(['dsn' => $this->dsn], $this->clientOptions);
57+
$builder = ClientBuilder::create($userOptions);
58+
59+
$options = $builder->getOptions();
60+
$options->setIntegrations(static function (array $integrations) {
61+
// Remove the default error and fatal exception listeners to let us handle those
62+
return array_filter($integrations, static function (IntegrationInterface $integration): bool {
63+
if ($integration instanceof ErrorListenerIntegration) {
64+
return false;
65+
}
66+
if ($integration instanceof ExceptionListenerIntegration) {
67+
return false;
68+
}
69+
if ($integration instanceof FatalErrorListenerIntegration) {
70+
return false;
71+
}
72+
73+
return true;
74+
});
75+
});
76+
77+
SentrySdk::init()->bindClient($builder->getClient());
5178
}
5279

5380
/**

0 commit comments

Comments
 (0)