mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Minor enhancements and clarifications
This commit is contained in:
parent
130c024c3e
commit
1f36726f73
1 changed files with 12 additions and 25 deletions
|
|
@ -8,12 +8,12 @@
|
|||
top,
|
||||
doNotTrack,
|
||||
} = window;
|
||||
const { hostname, href, origin } = location;
|
||||
const { currentScript, referrer } = document;
|
||||
const localStorage = href.startsWith('data:') ? undefined : window.localStorage;
|
||||
|
||||
if (!currentScript) return;
|
||||
|
||||
const { hostname, href, origin } = location;
|
||||
const localStorage = href.startsWith('data:') ? undefined : window.localStorage;
|
||||
|
||||
const _data = 'data-';
|
||||
const _false = 'false';
|
||||
const _true = 'true';
|
||||
|
|
@ -55,20 +55,14 @@
|
|||
|
||||
/* Event handlers */
|
||||
|
||||
const handlePush = (state, title, url) => {
|
||||
const handlePush = (_state, _title, url) => {
|
||||
if (!url) return;
|
||||
|
||||
currentRef = currentUrl;
|
||||
currentUrl = new URL(url, location.href);
|
||||
|
||||
if (excludeSearch) {
|
||||
currentUrl.search = '';
|
||||
}
|
||||
|
||||
if (excludeHash) {
|
||||
currentUrl.hash = '';
|
||||
}
|
||||
|
||||
if (excludeSearch) currentUrl.search = '';
|
||||
if (excludeHash) currentUrl.hash = '';
|
||||
currentUrl = currentUrl.toString();
|
||||
|
||||
if (currentUrl !== currentRef) {
|
||||
|
|
@ -127,6 +121,7 @@
|
|||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const el = e.target;
|
||||
|
|
@ -208,25 +203,17 @@
|
|||
|
||||
const init = () => {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
track();
|
||||
handlePathChanges();
|
||||
handleClicks();
|
||||
initialized = true;
|
||||
}
|
||||
};
|
||||
|
||||
const track = (obj, data) => {
|
||||
if (typeof obj === 'string') {
|
||||
return send({
|
||||
...getPayload(),
|
||||
name: obj,
|
||||
data: typeof data === 'object' ? data : undefined,
|
||||
});
|
||||
} else if (typeof obj === 'object') {
|
||||
return send(obj);
|
||||
} else if (typeof obj === 'function') {
|
||||
return send(obj(getPayload()));
|
||||
}
|
||||
if (typeof obj === 'string') return send({ ...getPayload(), name: obj, data });
|
||||
if (typeof obj === 'object') return send(obj);
|
||||
if (typeof obj === 'function') return send(obj(getPayload()));
|
||||
return send(getPayload());
|
||||
};
|
||||
|
||||
|
|
@ -244,7 +231,7 @@
|
|||
let currentUrl = href;
|
||||
let currentRef = referrer.startsWith(origin) ? '' : referrer;
|
||||
let cache;
|
||||
let initialized;
|
||||
let initialized = false;
|
||||
let disabled = false;
|
||||
|
||||
if (autoTrack && !trackingDisabled()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue