Skip to content

Commit

Permalink
Add capture method for sending manual exceptions to Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook committed Mar 16, 2021
1 parent 688ea30 commit 832d69e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/WpSentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Zeek\WpSentry;

use Sentry;
use Sentry\ClientBuilder;
use Sentry\Event;
use Sentry\SentrySdk;
Expand All @@ -28,6 +29,10 @@ protected function __construct() {
$this->initSentryClient();
}

public function captureException( $exception ) {
Sentry\captureException( $exception );
}

private function get_dsn() : ?string {
$this->sentryDsn = get_env_value( 'SENTRY_DSN' );

Expand Down Expand Up @@ -60,7 +65,7 @@ private function get_default_options() : array {
];

$options['before_send'] = function ( Event $event ) : ?Event {
$excludeEvents = array_merge( $this->coreExclusions, get_env_value( 'SENTRY_EXCLUDE_EVENTS' ) ?? []);
$excludeEvents = array_merge( $this->coreExclusions, get_env_value( 'SENTRY_EXCLUDE_EVENTS' ) ?? [] );

// Errors always get reported
if ( (string) $event->getLevel() === 'error' ) {
Expand Down

0 comments on commit 832d69e

Please sign in to comment.