diff --git a/scripts/aem.js b/scripts/aem.js index 40662e6148..2ace3102c6 100644 --- a/scripts/aem.js +++ b/scripts/aem.js @@ -100,10 +100,14 @@ function sampleRUM(checkpoint, data) { sampleRUM.enhance = () => { // only enhance once if (document.querySelector('script[src*="rum-enhancer"]')) return; - + const { enhancerVersion, enhancerHash } = sampleRUM.enhancerContext || {}; const script = document.createElement('script'); + if (enhancerHash) { + script.integrity = enhancerHash; + script.setAttribute('crossorigin', 'anonymous'); + } script.src = new URL( - '.rum/@adobe/helix-rum-enhancer@^2/src/index.js', + `.rum/@adobe/helix-rum-enhancer@${enhancerVersion || '^2'}/src/index.js`, sampleRUM.baseURL, ).href; document.head.appendChild(script);