Skip to content

Commit

Permalink
Fix excluded exceptions option
Browse files Browse the repository at this point in the history
Since we're not using ClientInterface::captureException to capture exceptions, we should do the check ourselves
  • Loading branch information
DieterHolvoet committed Jun 6, 2020
1 parent 824e1fb commit e9fa070
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.1] - 2020-06-06
### Fixed
- Fix excluded exceptions option. Since we're not using ClientInterface::captureException to capture exceptions,
we should do the check ourselves

## [1.5.0] - 2020-05-27
### Changed
- Increase minimum version of the SDK to 2.3.0
Expand Down
18 changes: 9 additions & 9 deletions src/Logger/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public function log($level, $message, array $context = [])
return;
}

if (isset($context['%type']) && !$this->isExceptionIncluded($context['%type'])) {
return;
}

$scope = $this->buildScope($context);

$payload = [
Expand All @@ -110,7 +114,6 @@ protected function getClient(): ?ClientInterface
return $this->client;
}

$integrations = [];
$options = new Options([
'dsn' => $this->config->get('dsn'),
'attach_stacktrace' => true,
Expand All @@ -126,14 +129,6 @@ protected function getClient(): ?ClientInterface
$options->setEnvironment($value);
}

if ($value = $this->config->get('excluded_exceptions')) {
$integrations[] = new IgnoreErrorsIntegration([
'ignore_exceptions' => $value
]);
}

$options->setIntegrations($integrations);

$this->eventDispatcher->dispatch(WmsentryEvents::OPTIONS_ALTER, new SentryOptionsAlterEvent($options));

return $this->client = (new ClientBuilder($options))->getClient();
Expand Down Expand Up @@ -270,4 +265,9 @@ protected function isLogLevelIncluded(int $level): bool

return !empty($this->config->get("log_levels.{$index}"));
}

protected function isExceptionIncluded(string $type): bool
{
return !in_array($type, $this->config->get('excluded_exceptions'), true);
}
}

0 comments on commit e9fa070

Please sign in to comment.