mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +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,
|
top,
|
||||||
doNotTrack,
|
doNotTrack,
|
||||||
} = window;
|
} = window;
|
||||||
const { hostname, href, origin } = location;
|
|
||||||
const { currentScript, referrer } = document;
|
const { currentScript, referrer } = document;
|
||||||
const localStorage = href.startsWith('data:') ? undefined : window.localStorage;
|
|
||||||
|
|
||||||
if (!currentScript) return;
|
if (!currentScript) return;
|
||||||
|
|
||||||
|
const { hostname, href, origin } = location;
|
||||||
|
const localStorage = href.startsWith('data:') ? undefined : window.localStorage;
|
||||||
|
|
||||||
const _data = 'data-';
|
const _data = 'data-';
|
||||||
const _false = 'false';
|
const _false = 'false';
|
||||||
const _true = 'true';
|
const _true = 'true';
|
||||||
|
|
@ -55,20 +55,14 @@
|
||||||
|
|
||||||
/* Event handlers */
|
/* Event handlers */
|
||||||
|
|
||||||
const handlePush = (state, title, url) => {
|
const handlePush = (_state, _title, url) => {
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
currentRef = currentUrl;
|
currentRef = currentUrl;
|
||||||
currentUrl = new URL(url, location.href);
|
currentUrl = new URL(url, location.href);
|
||||||
|
|
||||||
if (excludeSearch) {
|
if (excludeSearch) currentUrl.search = '';
|
||||||
currentUrl.search = '';
|
if (excludeHash) currentUrl.hash = '';
|
||||||
}
|
|
||||||
|
|
||||||
if (excludeHash) {
|
|
||||||
currentUrl.hash = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
currentUrl = currentUrl.toString();
|
currentUrl = currentUrl.toString();
|
||||||
|
|
||||||
if (currentUrl !== currentRef) {
|
if (currentUrl !== currentRef) {
|
||||||
|
|
@ -127,6 +121,7 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const el = e.target;
|
const el = e.target;
|
||||||
|
|
@ -208,25 +203,17 @@
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
initialized = true;
|
||||||
track();
|
track();
|
||||||
handlePathChanges();
|
handlePathChanges();
|
||||||
handleClicks();
|
handleClicks();
|
||||||
initialized = true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const track = (obj, data) => {
|
const track = (obj, data) => {
|
||||||
if (typeof obj === 'string') {
|
if (typeof obj === 'string') return send({ ...getPayload(), name: obj, data });
|
||||||
return send({
|
if (typeof obj === 'object') return send(obj);
|
||||||
...getPayload(),
|
if (typeof obj === 'function') return send(obj(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()));
|
|
||||||
}
|
|
||||||
return send(getPayload());
|
return send(getPayload());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -244,7 +231,7 @@
|
||||||
let currentUrl = href;
|
let currentUrl = href;
|
||||||
let currentRef = referrer.startsWith(origin) ? '' : referrer;
|
let currentRef = referrer.startsWith(origin) ? '' : referrer;
|
||||||
let cache;
|
let cache;
|
||||||
let initialized;
|
let initialized = false;
|
||||||
let disabled = false;
|
let disabled = false;
|
||||||
|
|
||||||
if (autoTrack && !trackingDisabled()) {
|
if (autoTrack && !trackingDisabled()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue