Skip to content

Commit

Permalink
Fix missing dsn error
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook committed Mar 16, 2021
1 parent 832d69e commit 4bc28e9
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/WpSentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class WpSentry extends Singleton {
];

protected function __construct() {
$this->dsn = $this->get_dsn();

if ( empty( $this->dsn ) ) {
return;
}

$this->initSentryClient();
}

Expand All @@ -40,25 +46,27 @@ private function get_dsn() : ?string {
$this->sentryDsn = get_env_value( 'SENTRY_URL' );
}

if ( empty( $this->sentryDsn ) ) {
$this->sentryDsn = E_ALL & ~E_NOTICE & ~E_WARNING;
return $this->sentryDsn;
}

private function errorTypes() {
$errorTypes = get_env_value( 'SENTRY_ERROR_TYPES' );

if ( empty( $errorTypes ) ) {
$errorTypes = E_ALL & ~E_NOTICE & ~E_WARNING;
}

return $this->sentryDsn;
return $errorTypes;
}

private function get_default_options() : array {
$options = [
'dsn' => $this->get_dsn(),
'dsn' => $this->sentryDsn,
'prefixes' => [ ABSPATH ],
'environment' => get_env_value( 'ENVIRONMENT' ),
'error_types' => $this->errorTypes()
];

$sentryErrorLevel = get_env_value( 'SENTRY_ERROR_LEVEL' );
if ( ! empty( $sentryErrorLevel ) ) {
$options['error_types'] = $sentryErrorLevel;
}

$options['in_app_exclude'] = [
ABSPATH . 'wp-admin',
ABSPATH . 'wp-includes',
Expand Down

0 comments on commit 4bc28e9

Please sign in to comment.