Skip to content

Commit

Permalink
fix: check for H5
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Jun 3, 2024
1 parent 826e81a commit 4574555
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@ function trackCheckpoint(checkpoint, data, t) {
const sendPing = (pdata = data) => {
// eslint-disable-next-line object-curly-newline, max-len
const body = JSON.stringify({ weight, id, sanitizeURL: urlSanitizers[window.hlx.RUM_MASK_URL || 'path'], checkpoint, t, ...data }, KNOWN_PROPERTIES);
const url = new URL(`.rum/${weight}`, sampleRUM.collectBaseURL || sampleRUM.baseURL).href;
navigator.sendBeacon(url, body);
const { href: url, origin} = new URL(`.rum/${weight}`, sampleRUM.collectBaseURL || sampleRUM.baseURL);
if (window.location.origin === origin) {
const headers = { type: 'application/json' };
navigator.sendBeacon(url, new Blob([body], headers));
} else {
navigator.sendBeacon(url, body);
}
// eslint-disable-next-line no-console
console.debug(`ping:${checkpoint}`, pdata);
};
Expand Down

0 comments on commit 4574555

Please sign in to comment.