• Resolved Filipe Chaves

    (@flschaves)


    Shouldn’t this apply_filters be assigned to a variable?

    if ( has_filter( 'wp_sentry_options' ) ) {
    	apply_filters( 'wp_sentry_options', $this->get_client()->getClient()->getOptions() );
    }

    I’m trying to filter the $options but it is not reflecting my changes.

    My code (according to https://github.com/stayallive/wp-sentry/blob/v4.0.1/README.md#wp_sentry_options-array):

    add_filter( 'wp_sentry_options', 'sentry_excluded_list' );
    function sentry_excluded_list( \Sentry\Options $options ) {
    	$excluded_list = $options->getInAppExcludedPaths();
    
    	foreach ( $excluded_list as $key => $excluded ) {
    		if ( stripos( $excluded, 'wp-admin' ) !== false or stripos( $excluded, 'wp-includes' ) !== false ) {
    			unset( $excluded_list[ $key ] );
    		}
    	}
    
    	$options->setInAppExcludedPaths( $excluded_list );
    
    	return $options;
    }
    
    • This topic was modified 3 years, 11 months ago by Filipe Chaves.
    • This topic was modified 3 years, 11 months ago by Filipe Chaves.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author stayallive

    (@stayallive)

    Hi Filipe,

    It should not since we pass the options by reference and the reference is shared with the Sentry SDK so this indirectly updates the options correctly.

    This does seem like it should work, however maybe your excluded list is not doing what you think it would? Have you tried to simply set it to a [] to see if that has effect (especially since you are removing the only 2 entries in the list in the first place)?

    What is not happening what you would expect to happen?

    And also out of curiosity, why do you want to modify that value, are the defaults not correct for your use case?

    Thread Starter Filipe Chaves

    (@flschaves)

    Hey Alex!

    Even setting an empty array to $options->setInAppExcludedPaths([]);, when I force a fatal error on wp-includes/post.php just for test, it is not logging on Sentry.

    I’d like to modify this values to log all WordPress errors, even of the core.
    But is it possible? The plugin loads after those WordPress folders (wp-includes/wp-admin) right? So it would not make sense ??

    Plugin Author stayallive

    (@stayallive)

    Hi Filipe,

    I don’t think you understand what this option is doing.

    setInAppExcludedPaths set’s the paths Sentry should _mark_ as not part of your application. If an error/exception occurs there it will still be recorded. The in-app flag has effect on the stacktrace and automatically collapses the frames inside the Sentry UI, it will _not_ prevent an error/exception from being reported.

    So either the error is occurring _before_ the Sentry plugin is loaded or it’s an error that is excluded by the value defined in your php.ini error_reporting level. But since you indicate it’s a fatal error it should be reported since that one is always included most likely… but do check what the error_reporting level is just to be sure ??

    Can you tell a bit more about the error that is you are forcing and how and where exactly you are doing this?

    Thread Starter Filipe Chaves

    (@flschaves)

    Ohhh I’m so sorry, thank you a lot for this explanation!

    Now I got how this excluded paths works! Thanks again!

    I was just temporarily inserting into wp-includes/post.php a call for a undefined function like blablabla(), but yeah, it completely makes no sense because the plugin is not loaded at this time =p

    Thanks for the quick answers and for the explanation!

    Plugin Author stayallive

    (@stayallive)

    Hi Filipe,

    No worries, happy to explain ??

    There is a way to load the plugin before other plugins but not a really good and supported way to load Sentry before WordPress so there are some gains to be had. But since 99% of the errors occur _after_ WordPress loaded and within plugins or themes you should catch everything except for errors like yours where the error is in the WP core.

    For loading before other plugins: https://github.com/stayallive/wp-sentry#capturing-plugin-errors.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Isn’t possible to filter the options’ is closed to new replies.