From ad28d94f5acd7401c70c69c962d4d4282096e632 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Wed, 3 Jan 2024 16:11:21 +0100 Subject: [PATCH] Move `wp_sentry_hook` lower --- public/wp-sentry-browser.wp.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/public/wp-sentry-browser.wp.js b/public/wp-sentry-browser.wp.js index 704147f..0835501 100644 --- a/public/wp-sentry-browser.wp.js +++ b/public/wp-sentry-browser.wp.js @@ -17,15 +17,6 @@ } } - if (typeof wp_sentry_hook === 'function') { - var hookResult = wp_sentry_hook(wp_sentry); - - // If the hook returns false we do not continue to initialize Sentry - if (hookResult === false) { - return; - } - } - wp_sentry.integrations = []; // Enable replay if a sample rate is set @@ -47,6 +38,16 @@ wp_sentry.integrations.push(new Sentry.Integrations.BrowserTracing(wp_sentry.wpBrowserTracingOptions)); } + // If the hook is defined we call it with the Sentry object so that the user can modify it + if (typeof wp_sentry_hook === 'function') { + var hookResult = wp_sentry_hook(wp_sentry); + + // If the hook returns false we do not continue to initialize Sentry + if (hookResult === false) { + return; + } + } + Sentry.init(wp_sentry); if (typeof wp_sentry.context === 'object') {