stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
314 stars 48 forks source link

How to enable Interaction to Next Paint (INP)? #192

Closed katkat100 closed 2 months ago

katkat100 commented 3 months ago

I am trying to enable Interaction to Next Paint (INP) but I don't see an option for it or a way to do so. I have tried the code below but I don't see a change in Sentry Dashboard. Any help would be appreciated thanks! add_filter('wp_sentry_public_options', function (array $options) { return array_merge($options, array( 'enableInp' => true, )); });

stayallive commented 3 months ago

It looks like this is part of the browserTracingIntegration and not the regular options.

You can set those using define( 'WP_SENTRY_BROWSER_TRACING_OPTIONS', ['enableInp' => true] ).

Place that next to your DSN defines in your wp-config.php.

This also requires you to enable browser tracing, see the docs for the full details: https://github.com/stayallive/wp-sentry?tab=readme-ov-file#wp_sentry_browser_traces_sample_rate-browser

katkat100 commented 3 months ago

Thanks for the quick reply! I tried out adding the tracing options and sample but I don't see any changes in the dashboard. I took another look at the docs and it doesn't look like Sentry PHP has enableInp since it's under automatic instrumentation in JS and missing in PHP. How would I go about adding custom instrumentation instead? Thanks again for your help!

define('WP_SENTRY_BROWSER_TRACES_SAMPLE_RATE', 1);
define('WP_SENTRY_BROWSER_TRACING_OPTIONS', ['enableInp' => true]);
stayallive commented 3 months ago

Hey @katkat100, INP is a browser metric so the PHP does not have to support it and what you have done would be what I would expect to be correct. I'd have to give it a go myself to see if I can figure out where it's going wrong. But first glance this looks good.

katkat100 commented 3 months ago

I was able to see data in Sentry database but INP was still not enabled I can see in Network that sample rate is being applied but not integrations and the passed tracing options.

{"event_id":[EVENT_ID],"sent_at":"2024-06-18T20:14:37.566Z","sdk":{"name":"sentry.javascript.browser","version":"7.73.0"},"trace":{"environment":[ENV],"release":"unknown","public_key":[PUBLIC_KEY]"trace_id":[TRACE_ID],"sample_rate":"0.9","sampled":"true"}}

Am I looking at the wrong place?

stayallive commented 3 months ago

What version of the plugin are you on?

katkat100 commented 3 months ago

6.26.0

stayallive commented 3 months ago

Are you able to upgrade to 7.x of this plugin?

INP is only supported in the JS SDK version 7.104.0 or higher.

Version 6.26.0 of this plugin ships with 7.73.0 which is why it isn't working!

katkat100 commented 3 months ago

I updated to 7.16.0 but it doesn't pass enableINP, I checked the request and it is using the sentry javascript version 7.116.0. I am on wp version 6.5.2

stayallive commented 2 months ago

but it doesn't pass enableINP,

What do you mean? I tried define('WP_SENTRY_BROWSER_TRACING_OPTIONS', ['enableInp' => true]); and it does pass it to the SDK.

I am working on a upgrade to version 8 of the JS SDK where it will be enabled by default so that will also fix it 👍

stayallive commented 2 months ago

Hey @katkat100, I just release version 8 of this plugin which embeds version 8 of the JS SDK. It enabled INP by default so this should fix it for you without any configuration from your side 👍