diff --git a/dist/aem.js b/dist/aem.js index 3723b0d..81c6d47 100644 --- a/dist/aem.js +++ b/dist/aem.js @@ -28,7 +28,6 @@ function sampleRUM(checkpoint, data) { on: 1, off: 0, high: 10, - medium: 100, low: 1000, }[rate]; const weight = rateValue !== undefined ? rateValue : 100; @@ -94,18 +93,14 @@ function sampleRUM(checkpoint, data) { sampleRUM.baseURL = sampleRUM.baseURL || new URL(window.RUM_BASE || '/', new URL('https://ot.aem.live')); sampleRUM.collectBaseURL = sampleRUM.collectBaseURL || sampleRUM.baseURL; sampleRUM.sendPing = (ck, time, pingData = {}) => { - const uaExtra = navigator.webdriver && !navigator.userAgent.includes('+http') - ? { ua: `${navigator.userAgent} +http://navigator.webdriver` } - : {}; // eslint-disable-next-line max-len, object-curly-newline const rumData = JSON.stringify({ weight, id, - referer: window.location.origin + window.location.pathname, + referer: window.location.href, checkpoint: ck, t: time, ...pingData, - ...uaExtra, }); const urlParams = window.RUM_PARAMS ? new URLSearchParams(window.RUM_PARAMS).toString() || '' @@ -125,9 +120,7 @@ function sampleRUM(checkpoint, data) { sampleRUM.enhance = () => { // only enhance once - if (document.querySelector('script[src*="rum-enhancer"]')) { - return; - } + if (document.querySelector('script[src*="rum-enhancer"]')) return; const { enhancerVersion, enhancerHash } = sampleRUM.enhancerContext || {}; const script = document.createElement('script'); if (enhancerHash) { @@ -157,22 +150,21 @@ function sampleRUM(checkpoint, data) { /** * Setup block utils. */ -function setup() { +function setup(importUrl = import.meta.url) { window.hlx = window.hlx || {}; window.hlx.RUM_MASK_URL = 'full'; window.hlx.RUM_MANUAL_ENHANCE = true; window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on'; - [window.hlx.codeBasePath] = new URL(import.meta.url).pathname.split('/scripts/'); + [window.hlx.codeBasePath] = new URL(importUrl).pathname.split('/scripts/'); } /** * Auto initialization. */ - function init() { setup(); - sampleRUM.collectBaseURL = window.origin; + sampleRUM.collectBaseURL = new URL(`${window.hlx.codeBasePath}/`, window.origin); sampleRUM(); } diff --git a/test/setup/setup.test.html b/test/setup/setup.test.html index acacab4..aa3cd58 100644 --- a/test/setup/setup.test.html +++ b/test/setup/setup.test.html @@ -42,7 +42,7 @@ it('init - sets sampleRUM.collectBaseURL to include the codeBasePath', () => { init(); - expect(sampleRUM.collectBaseURL.href).to.be.equal(`${window.origin}/some/path/`); + expect(sampleRUM.collectBaseURL.href).to.be.equal(`${window.origin}/src/setup.js/`); }); });