Skip to content

Commit

Permalink
Add support for lite mode flag to error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Newcomer committed Jul 15, 2019
1 parent 50d88e6 commit e1e95d0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/third-party/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public static function init_php() {
$options = [
'send_callback' => function ( $data ) use ( $exclusions ) {

if ( static::lite_mode_enabled() && ! ( $data['force'] ?? false ) ) {
return false;
}

if ( 'error' === $data['level'] ) {
return $data;
}
Expand Down Expand Up @@ -96,7 +100,7 @@ static function capture( $exception ) {
return;
}

self::$client->captureException( $exception );
self::$client->captureException( $exception, [ 'force' => true ] );
}

/**
Expand All @@ -119,4 +123,13 @@ public static function js_init_sentry_sdk() {
</script>
<?php
}

/**
* Whether lite mode is enabled.
*
* @return bool
*/
public static function lite_mode_enabled() {
return boolval( get_env_value( 'ERROR_HANDLING_LITE_MODE_ENABLED' ) );
}
}

0 comments on commit e1e95d0

Please sign in to comment.