diff --git a/plugins/experimentation/src/index.js b/plugins/experimentation/src/index.js index 1594a86f..3b93b90f 100644 --- a/plugins/experimentation/src/index.js +++ b/plugins/experimentation/src/index.js @@ -372,13 +372,14 @@ function createModificationsHandler( const url = await getExperienceUrl(ns.config); let res; if (url && new URL(url, window.location.origin).pathname !== window.location.pathname) { - if (metadata?.resolution === 'redirect') { + if (toClassName(metadata?.resolution) === 'redirect') { + // Firing RUM event early since redirection will stop the rest of the JS execution fireRUM(type, config, pluginOptions, url); window.location.replace(url); - } else { - // eslint-disable-next-line no-await-in-loop - res = await replaceInner(new URL(url, window.location.origin).pathname, el); + return null; } + // eslint-disable-next-line no-await-in-loop + res = await replaceInner(new URL(url, window.location.origin).pathname, el); } else { res = url; }