Title: Enable Sentry for Specific plugin
Last modified: March 9, 2021

---

# Enable Sentry for Specific plugin

 *  Resolved [iqbal1486](https://wordpress.org/support/users/iqbal1486/)
 * (@iqbal1486)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/enable-sentry-for-specific-plugin/)
 * 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](https://wordpress.org/support/users/stayallive/)
 * (@stayallive)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/enable-sentry-for-specific-plugin/#post-14155498)
 * Hi [@iqbal1486](https://wordpress.org/support/users/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](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](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](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](https://wordpress.org/support/users/stayallive/).
      Reason: fix formatting
 *  Plugin Author [stayallive](https://wordpress.org/support/users/stayallive/)
 * (@stayallive)
 * [5 years ago](https://wordpress.org/support/topic/enable-sentry-for-specific-plugin/#post-14464306)
 * Hi [@iqbal1486](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/wp-sentry-integration/assets/icon-256x256.jpg?rev=1772463)
 * [Sentry for WordPress](https://wordpress.org/plugins/wp-sentry-integration/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-sentry-integration/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-sentry-integration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-sentry-integration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-sentry-integration/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [stayallive](https://wordpress.org/support/users/stayallive/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/enable-sentry-for-specific-plugin/#post-14464306)
 * Status: resolved