mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 04:25:39 +01:00
Filter out all reserved data- fields on tracker before sending custom pageview data
This commit is contained in:
parent
faf1fb81c1
commit
9f449c73cb
1 changed files with 5 additions and 1 deletions
|
|
@ -27,6 +27,7 @@
|
||||||
const screen = `${width}x${height}`;
|
const screen = `${width}x${height}`;
|
||||||
const eventRegex = /data-umami-event-([\w-_]+)/;
|
const eventRegex = /data-umami-event-([\w-_]+)/;
|
||||||
const pageviewCustomPropertyRegex = /data-([\w-_]+)/;
|
const pageviewCustomPropertyRegex = /data-([\w-_]+)/;
|
||||||
|
const reservedDataAttributes = ['website-id', 'domains', 'umami-event', 'auto-track', 'host-url'];
|
||||||
const eventNameAttribute = _data + 'umami-event';
|
const eventNameAttribute = _data + 'umami-event';
|
||||||
const delayDuration = 300;
|
const delayDuration = 300;
|
||||||
|
|
||||||
|
|
@ -44,7 +45,10 @@
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
Array.from(currentScript.attributes)
|
Array.from(currentScript.attributes)
|
||||||
.filter(attribute => attribute.name.match(pageviewCustomPropertyRegex))
|
.filter(attribute => attribute.name.match(pageviewCustomPropertyRegex))
|
||||||
.filter(attribute => attribute.name !== 'data-website-id')
|
.filter(
|
||||||
|
attribute =>
|
||||||
|
!reservedDataAttributes.some(reserved => _data + reserved === attribute.name),
|
||||||
|
)
|
||||||
.map(attribute => {
|
.map(attribute => {
|
||||||
const match = attribute.name.match(pageviewCustomPropertyRegex);
|
const match = attribute.name.match(pageviewCustomPropertyRegex);
|
||||||
return [match[1], attribute.value];
|
return [match[1], attribute.value];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue