mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 12:35:38 +01:00
Shorten custom pageview data attribute to just data-*
This commit is contained in:
parent
3eae82632f
commit
faf1fb81c1
1 changed files with 11 additions and 9 deletions
|
|
@ -26,7 +26,7 @@
|
||||||
const endpoint = `${root}/api/send`;
|
const endpoint = `${root}/api/send`;
|
||||||
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-event-([\w-_]+)/;
|
const pageviewCustomPropertyRegex = /data-([\w-_]+)/;
|
||||||
const eventNameAttribute = _data + 'umami-event';
|
const eventNameAttribute = _data + 'umami-event';
|
||||||
const delayDuration = 300;
|
const delayDuration = 300;
|
||||||
|
|
||||||
|
|
@ -40,14 +40,16 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPageviewEventData = () => Object.fromEntries(
|
const getPageviewEventData = () =>
|
||||||
|
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')
|
||||||
.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];
|
||||||
})
|
}),
|
||||||
)
|
);
|
||||||
|
|
||||||
const getPayload = () => ({
|
const getPayload = () => ({
|
||||||
website,
|
website,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue