From a1e0807f735a7c8097c588f401efdb9aac08dfc7 Mon Sep 17 00:00:00 2001 From: Francisco Chicharro Sanz Date: Wed, 6 Mar 2024 17:17:02 +0100 Subject: [PATCH] fix: add json type header to beacon --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 4cf3bef..6a88016 100644 --- a/src/index.js +++ b/src/index.js @@ -82,7 +82,8 @@ function trackCheckpoint(checkpoint, data, t) { // 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 headers = { type: 'application/json' }; + navigator.sendBeacon(url, new Blob([body], headers)); // eslint-disable-next-line no-console console.debug(`ping:${checkpoint}`, pdata); };