• Resolved iqbal1486

    (@iqbal1486)


    Is it possible to limit sentry to log only the errors of the specific plugin?
    Is there any filters I can use to modify to meet this requirement?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author stayallive

    (@stayallive)

    Hi @iqbal1486,

    Interesting question, I don’t have a plug-and-play piece of code for you but I can give you some direction on how I would go about this.

    The Sentry PHP SDK has a before_send hook in which you can inspect what we are going to send to Sentry and allow you to return null to discard the event. In this hook you could inspect the event to see if it’s stack trace touches your plugin code and if it does not discard it.

    > https://docs.sentry.io/platforms/php/configuration/options/#before-send

    You can set the before_send option using: https://github.com/stayallive/wp-sentry#wp_sentry_options-array.

    This could something like this:

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

    You’d need to implement sentry_event_occured_in_my_plugin yourself of course.

    You can learn more about how the Event class looks like and how you could inspect it here: https://github.com/getsentry/sentry-php/blob/f35ffc85a383c22f82098a82ba283a73c0267fa0/src/Event.php.

    Make sure you do this before the after_setup_theme action fires.

    Hope this helps!

    • This reply was modified 5 years, 3 months ago by stayallive. Reason: fix formatting
    Plugin Author stayallive

    (@stayallive)

    Hi @iqbal1486,

    It’s been 2 months since you last posted so I’m going to close this topic.

    Feel free to re-open and/or submit a new one if I can still help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Enable Sentry for Specific plugin’ is closed to new replies.