From 1bbd24f71fb4cc47464ba98391a0bf2580837596 Mon Sep 17 00:00:00 2001 From: Francisco Chicharro Sanz Date: Wed, 6 Mar 2024 17:18:03 +0100 Subject: [PATCH] fix: add json type header to beacon --- scripts/lib-franklin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lib-franklin.js b/scripts/lib-franklin.js index 320d557a..7d241706 100644 --- a/scripts/lib-franklin.js +++ b/scripts/lib-franklin.js @@ -33,8 +33,9 @@ export function sampleRUM(checkpoint, data) { const pathBase = window.hlx.codeBasePath ? `${window.hlx.codeBasePath}/` : ''; // eslint-disable-next-line object-curly-newline, max-len const body = JSON.stringify({ weight, id, referer: window.location.href, checkpoint: 'top', t: timeShift(), target: document.visibilityState }); + const headers = { type: 'application/json' }; const url = new URL(`${pathBase}.rum/${weight}`, sampleRUM.collectBaseURL).href; - navigator.sendBeacon(url, body); + navigator.sendBeacon(url, new Blob([body], headers)); // eslint-disable-next-line max-statements-per-line, brace-style window.addEventListener('load', () => { sampleRUM('load');