mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-26 12:29:05 +01:00
Removed do not track logic.
This commit is contained in:
parent
6b9c83381c
commit
2197551e58
@ -18,7 +18,6 @@
|
|||||||
const website = attr(_data + 'website-id');
|
const website = attr(_data + 'website-id');
|
||||||
const hostUrl = attr(_data + 'host-url');
|
const hostUrl = attr(_data + 'host-url');
|
||||||
const autoTrack = attr(_data + 'auto-track') !== _false;
|
const autoTrack = attr(_data + 'auto-track') !== _false;
|
||||||
const dnt = attr(_data + 'do-not-track');
|
|
||||||
const domain = attr(_data + 'domains') || '';
|
const domain = attr(_data + 'domains') || '';
|
||||||
const domains = domain.split(',').map(n => n.trim());
|
const domains = domain.split(',').map(n => n.trim());
|
||||||
const root = hostUrl
|
const root = hostUrl
|
||||||
@ -61,23 +60,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Tracking functions */
|
/* Tracking functions */
|
||||||
|
|
||||||
const doNotTrack = () => {
|
|
||||||
const { doNotTrack, navigator, external } = window;
|
|
||||||
|
|
||||||
const msTrackProtection = 'msTrackingProtectionEnabled';
|
|
||||||
const msTracking = () => {
|
|
||||||
return external && msTrackProtection in external && external[msTrackProtection]();
|
|
||||||
};
|
|
||||||
|
|
||||||
const dnt = doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || msTracking();
|
|
||||||
|
|
||||||
return dnt == '1' || dnt === 'yes';
|
|
||||||
};
|
|
||||||
|
|
||||||
const trackingDisabled = () =>
|
const trackingDisabled = () =>
|
||||||
(localStorage && localStorage.getItem('umami.disabled')) ||
|
(localStorage && localStorage.getItem('umami.disabled')) ||
|
||||||
(dnt && doNotTrack()) ||
|
|
||||||
(domain && !domains.includes(hostname));
|
(domain && !domains.includes(hostname));
|
||||||
|
|
||||||
const handlePush = (state, title, url) => {
|
const handlePush = (state, title, url) => {
|
||||||
@ -174,7 +158,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const send = (payload, type = 'event') => {
|
const send = async (payload, type = 'event') => {
|
||||||
if (trackingDisabled()) return;
|
if (trackingDisabled()) return;
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -182,14 +166,17 @@
|
|||||||
if (typeof cache !== 'undefined') {
|
if (typeof cache !== 'undefined') {
|
||||||
headers['x-umami-cache'] = cache;
|
headers['x-umami-cache'] = cache;
|
||||||
}
|
}
|
||||||
return fetch(endpoint, {
|
try {
|
||||||
method: 'POST',
|
const res = await fetch(endpoint, {
|
||||||
body: JSON.stringify({ type, payload }),
|
method: 'POST',
|
||||||
headers,
|
body: JSON.stringify({ type, payload }),
|
||||||
})
|
headers,
|
||||||
.then(res => res.text())
|
});
|
||||||
.then(text => (cache = text))
|
const text = await res.text();
|
||||||
.catch(() => {}); // no-op, gulp error
|
return (cache = text);
|
||||||
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const track = (obj, data) => {
|
const track = (obj, data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user