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 3 years, 8 months ago by stayallive. Reason: fix formatting