stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
305 stars 48 forks source link

Add option to exclude admin users #93

Closed stefs7 closed 2 years ago

stefs7 commented 3 years ago

This feature would allow to exclude errors origin from third-party plugin's which have a high chance of producing errors in the WP Admin.

stayallive commented 3 years ago

I think it might be better to actually exclude errors from third-party plugins if you are not interested in them?

See: https://github.com/stayallive/wp-sentry#capturing-errors-only-from-certain-theme-andor-plugin


If you wanted you can use the same code example to ignore errors when is_admin() is true:

add_filter( 'wp_sentry_options', function ( \Sentry\Options $options ) {
    $options->setBeforeSendCallback( function ( \Sentry\Event $event ) {
        return is_admin() ? null : $event;
    } );
} );

Note: the wp_sentry_options filter fires on the WordPress after_setup_theme action so make sure to register your filter before that for example in the functions.php of your theme.

stayallive commented 2 years ago

I am closing this issue because of inactivity, if there is still an issue please re-open / open a new issue so we can investigate 👍