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

JavaScript failed to send test event. #125

Closed ValeSauer closed 2 years ago

ValeSauer commented 2 years ago

JS test returns

JavaScript failed to send test event. Check your configuration to make sure your DSN is set correctly.

DSNs are set correctly, even the legacy way:

define( 'WP_SENTRY_ENV', 'production' );
define( 'WP_SENTRY_PHP_DSN', '...' );
define( 'WP_SENTRY_ERROR_TYPES', E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_USER_DEPRECATED );
define( 'WP_SENTRY_SEND_DEFAULT_PII', false );
define( 'WP_SENTRY_BROWSER_DSN', '...');
define( 'WP_SENTRY_PUBLIC_DSN', '...' );

Are there any known interferrences with other plugins or any approaches on debugging this?

stayallive commented 2 years ago

Check your browsers console to see if there are any errors reported.

The most likely thing is that you are using a adblocker which might be blocking the calls.

ValeSauer commented 2 years ago

@stayallive My browser console shows

=> Sending a test message to Sentry...

tools.php?page=wp-sentry:415 !> Failed to sent a test message to Sentry
(anonymous) @ tools.php?page=wp-sentry:415

There is no adblocker, tried it even with different machines and with different networks. It does not even start an XHR call.

At least in the global scope Sentry is undefined.

stayallive commented 2 years ago

Hmm, that is not saying much 😅 I'm a bit at a loss here since you seem to do all the things correct.

You can try and run Sentry.SDK_VERSION in your console window. It should look something like this:

image

If it doesn't then the Sentry JavaScript bundle might not have been loaded at all.

ValeSauer commented 2 years ago

@stayallive Unfortunately Sentry is undefined. image

stayallive commented 2 years ago

@ValeSauer okay so that is the issue, the JavaScript SDK is not loading for you.

Do you have minification plugins installed, hosted on a server using Ligthspeed or behind Cloudflare (or a combination of those things)?

ValeSauer commented 2 years ago

The page is https://take-a-garden.com Neither frontend nor backend does load any js-file that looks wp-sentry-related. There is no minification plugin, however we use WP Super Cache (but without CDN activated). Enabling and disabling the plugin does not have any effect. I have uninstalled and reinstalled wp sentry: No effect.

Really weird... :-(

yashumitsu commented 2 years ago

Hi, I had the same problem, please make sure you have defined variables before wp-settings.php inclusion:

wp-config.php:

define( 'WP_SENTRY_BROWSER_DSN', ...

require_once ABSPATH . 'wp-settings.php';
ValeSauer commented 2 years ago

@yashumitsu Thanks! That actually solved it! I'll propose a change to the documentation.

stayallive commented 2 years ago

There is no need to propose any changes, you missed this line in your wp-config.php:

/* That's all, stop editing! Happy publishing. */

You should never do anything below that line as it suggests.

(you can see this in the wp-config.php template file)

ValeSauer commented 2 years ago

Oh right! Make certainly sense.