From 31ef4f0dfac8ff0abdd537b3bae8e8cacb9ecce3 Mon Sep 17 00:00:00 2001 From: Aaron Holbrook Date: Mon, 15 Mar 2021 09:52:59 -0500 Subject: [PATCH 1/4] Initial change --- src/bootstrap/bootstrap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.php b/src/bootstrap/bootstrap.php index c90e194..87eb88f 100644 --- a/src/bootstrap/bootstrap.php +++ b/src/bootstrap/bootstrap.php @@ -2,6 +2,7 @@ namespace Zeek\WP_Util; +use Zeek\WpSentry\WpSentry; use function A7\autoload; function bootstrap( $dir ) { @@ -13,7 +14,9 @@ function bootstrap( $dir ) { /** * Add Sentry Error Logging */ - ErrorHandling::init(); + // @todo remove old call +// ErrorHandling::init(); + WpSentry::init(); /** * Enable WP Util Behaviors From ba8c3f7dcfccdc24c5fea7d695af6e80af3645c1 Mon Sep 17 00:00:00 2001 From: Aaron Holbrook Date: Mon, 15 Mar 2021 10:02:52 -0500 Subject: [PATCH 2/4] Remove sentry requirement --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index beacfba..487ade6 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,6 @@ }, "require": { "php": ">=7.0", - "sentry/sentry": "^1.9", "arrilot/dotenv-php": "^1.0", "a7/autoload": ">=2", From 9339e768964504c30e21ca6406bcf3d0263f5175 Mon Sep 17 00:00:00 2001 From: Aaron Holbrook Date: Mon, 15 Mar 2021 14:27:04 -0500 Subject: [PATCH 3/4] Add environment var --- src/Constants.php | 1 + src/bootstrap/bootstrap.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Constants.php b/src/Constants.php index 2fdfd94..fc6093d 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -7,6 +7,7 @@ class Constants { private static $env_vars = [ + 'ENVIRONMENT' => 'production', 'ACF_LITE' => true, 'DISABLE_WP_CRON' => false, 'FILE_MOD_ALLOWED' => false, diff --git a/src/bootstrap/bootstrap.php b/src/bootstrap/bootstrap.php index 87eb88f..0c654e5 100644 --- a/src/bootstrap/bootstrap.php +++ b/src/bootstrap/bootstrap.php @@ -15,7 +15,7 @@ function bootstrap( $dir ) { * Add Sentry Error Logging */ // @todo remove old call -// ErrorHandling::init(); + //ErrorHandling::init(); WpSentry::init(); /** From 03e4e023f488f98e175122e17835a8ed99a54856 Mon Sep 17 00:00:00 2001 From: Aaron Holbrook Date: Mon, 15 Mar 2021 16:06:35 -0500 Subject: [PATCH 4/4] Finish sentry update --- composer.json | 6 +- src/bootstrap/bootstrap.php | 2 - src/third-party/Sentry.php | 136 ------------------------------------ 3 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 src/third-party/Sentry.php diff --git a/composer.json b/composer.json index 487ade6..94113ed 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,9 @@ "php": ">=7.0", "arrilot/dotenv-php": "^1.0", "a7/autoload": ">=2", - - "zeek/php-utils": ">=2" + + "zeek/php-utils": ">=2", + + "zeek/wp-sentry": "^1.0" } } diff --git a/src/bootstrap/bootstrap.php b/src/bootstrap/bootstrap.php index 0c654e5..88c34b9 100644 --- a/src/bootstrap/bootstrap.php +++ b/src/bootstrap/bootstrap.php @@ -14,8 +14,6 @@ function bootstrap( $dir ) { /** * Add Sentry Error Logging */ - // @todo remove old call - //ErrorHandling::init(); WpSentry::init(); /** diff --git a/src/third-party/Sentry.php b/src/third-party/Sentry.php deleted file mode 100644 index 233c989..0000000 --- a/src/third-party/Sentry.php +++ /dev/null @@ -1,136 +0,0 @@ - function ( $data ) use ( $exclusions ) { - - if ( static::lite_mode_enabled() && ! ( $data['force'] ?? false ) ) { - return false; - } - - if ( 'error' === $data['level'] ) { - return $data; - } - - $value = $data['exception']['values'][0]['value'] ?? null; - - if ( empty( $value ) ) { - return $data; - } - - if ( in_array( $value, $exclusions ) ) { - return false; - } - - return $data; - }, - ]; - - self::$client = new \Raven_Client( static::$sentry_url, $options ); - self::$client->install(); - - return self::$client; - } - - /** - * @return \Raven_Client - */ - static function get_client() { - if ( empty( self::$client ) ) { - self::init(); - } - - return self::$client; - } - - - static function capture( $exception ) { - if ( empty( self::$client ) ) { - return; - } - - self::$client->captureException( $exception, [ 'force' => true ] ); - } - - /** - * Enqueue the Sentry Javascript SDK. - */ - public static function js_enqueue_sentry_sdk() { - wp_enqueue_script( - 'sentry', - sprintf( 'https://browser.sentry-cdn.com/%s/bundle.min.js', static::SENTRY_JS_SDK_VERSION ) - ); - } - - /** - * Initialize the Sentry Javascript SDK. - */ - public static function js_init_sentry_sdk() { - ?> - -