Skip to content

Commit

Permalink
Merge pull request #42 from CookiesEater/fix-41
Browse files Browse the repository at this point in the history
Fixed default Sentry integrations
  • Loading branch information
CookiesEater authored Aug 24, 2020
2 parents e31707d + 08d7c76 commit a891dd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log

## 1.5.1 - 2020-08-24
### Fixed
* Fix double sending of events to Sentry.
* Fix event exclusion ("except" parameter).

## 1.5.0 - 2020-07-07
1.5.0 released

Expand Down
29 changes: 28 additions & 1 deletion src/SentryTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

namespace notamedia\sentry;

use Sentry\ClientBuilder;
use Sentry\Integration\ErrorListenerIntegration;
use Sentry\Integration\ExceptionListenerIntegration;
use Sentry\Integration\FatalErrorListenerIntegration;
use Sentry\Integration\IntegrationInterface;
use Sentry\SentrySdk;
use Sentry\Severity;
use Sentry\State\Scope;
use Throwable;
Expand Down Expand Up @@ -47,7 +53,28 @@ public function __construct($config = [])
{
parent::__construct($config);

\Sentry\init(array_merge(['dsn' => $this->dsn], $this->clientOptions));
$userOptions = array_merge(['dsn' => $this->dsn], $this->clientOptions);
$builder = ClientBuilder::create($userOptions);

$options = $builder->getOptions();
$options->setIntegrations(static function (array $integrations) {
// Remove the default error and fatal exception listeners to let us handle those
return array_filter($integrations, static function (IntegrationInterface $integration): bool {
if ($integration instanceof ErrorListenerIntegration) {
return false;
}
if ($integration instanceof ExceptionListenerIntegration) {
return false;
}
if ($integration instanceof FatalErrorListenerIntegration) {
return false;
}

return true;
});
});

SentrySdk::init()->bindClient($builder->getClient());
}

/**
Expand Down

0 comments on commit a891dd2

Please sign in to comment.