Skip to content

Commit

Permalink
feat(lib): update scripts/aem.js to aem.js@2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot committed Oct 7, 2024
1 parent 7312419 commit 9ec6798
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ function sampleRUM(checkpoint, data) {
t: time,
...pingData,
});
const { href: url, origin } = new URL(`.rum/${weight}`, sampleRUM.collectBaseURL);
const urlParams = window.RUM_PARAMS
? `?${new URLSearchParams(window.RUM_PARAMS).toString()}`
: '';
const { href: url, origin } = new URL(
`.rum/${weight}${urlParams}`,
sampleRUM.collectBaseURL,
);
const body = origin === window.location.origin
? new Blob([rumData], { type: 'application/json' })
: rumData;
Expand Down Expand Up @@ -108,7 +114,7 @@ function sampleRUM(checkpoint, data) {
}
document.dispatchEvent(new CustomEvent('rum', { detail: { checkpoint, data } }));
} catch (error) {
// something went wrong
// something went awry
}
}

Expand Down Expand Up @@ -139,7 +145,12 @@ function setup() {

function init() {
setup();
sampleRUM();
// Prerender-aware initialization
if (document.prerendering) {
document.addEventListener('prerenderingchange', sampleRUM, { once: true });
} else {
sampleRUM();
}
}

/**
Expand Down

0 comments on commit 9ec6798

Please sign in to comment.