From 9f449c73cbdd2dd28c4d9c34259a133e332764d5 Mon Sep 17 00:00:00 2001 From: Ewen Le Bihan Date: Sat, 30 Mar 2024 21:40:10 +0100 Subject: [PATCH] Filter out all reserved data- fields on tracker before sending custom pageview data --- src/tracker/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tracker/index.js b/src/tracker/index.js index 96163a862..797ec4ff3 100644 --- a/src/tracker/index.js +++ b/src/tracker/index.js @@ -27,6 +27,7 @@ const screen = `${width}x${height}`; const eventRegex = /data-umami-event-([\w-_]+)/; const pageviewCustomPropertyRegex = /data-([\w-_]+)/; + const reservedDataAttributes = ['website-id', 'domains', 'umami-event', 'auto-track', 'host-url']; const eventNameAttribute = _data + 'umami-event'; const delayDuration = 300; @@ -44,7 +45,10 @@ Object.fromEntries( Array.from(currentScript.attributes) .filter(attribute => attribute.name.match(pageviewCustomPropertyRegex)) - .filter(attribute => attribute.name !== 'data-website-id') + .filter( + attribute => + !reservedDataAttributes.some(reserved => _data + reserved === attribute.name), + ) .map(attribute => { const match = attribute.name.match(pageviewCustomPropertyRegex); return [match[1], attribute.value];