Skip to content

Commit

Permalink
enable sentry reporter to evaluate config at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
esbenp committed Jan 19, 2017
1 parent c9dcfb0 commit ee263f6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Reporters/SentryReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class SentryReporter implements ReporterInterface
{
private $config;

public function __construct(array $config)
{
$config = $this->extendConfig($config);
Expand All @@ -17,12 +19,23 @@ public function __construct(array $config)
throw new InvalidArgumentException("Sentry client is not installed. Use composer require sentry/sentry.");
}

$this->raven = new Raven_Client($config['dsn'], $config['sentry_options']);
$this->config = $config;
}

public function report(Exception $e)
{
return $this->raven->captureException($e);
$options = $this->config['sentry_options'];

if (is_callable($options)) {
$options = options($e);
}

$raven = new Raven_Client(
$this->config['dsn'],
$options
);

return $raven->captureException($e);
}

public function extendConfig(array $config)
Expand Down

0 comments on commit ee263f6

Please sign in to comment.