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

allow using Sentry global event processor #84

Closed kkmuffme closed 3 years ago

stayallive commented 3 years ago

This doesn't seem needed... you can place your script right after the one from Sentry and call Sentry.addGlobalEventProcessor there. No need for changes to the plugin :)

kkmuffme commented 3 years ago

My problem is that https://developer.wordpress.org/reference/functions/wp_localize_script/ doesn't have a dependency option, so I always get Sentry not defined error bc the sentry init didn't run at the point I am localizing the script (even when in footer)

stayallive commented 3 years ago

Yeah you shouldn't use wp_localize_script because that always runs before the actual script.

You can use wp_add_inline_script or possibly a JS file using wp_enqueue_script.

They both have dependency options. Would that work for you?