mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Allow tracker script to load even if tracking is disabled.
This commit is contained in:
parent
360a676dee
commit
56ccdf8c8e
@ -12,8 +12,10 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
} = window;
|
} = window;
|
||||||
|
|
||||||
const script = document.querySelector('script[data-website-id]');
|
const script = document.querySelector('script[data-website-id]');
|
||||||
const attr = key => script && script.getAttribute(key);
|
|
||||||
|
|
||||||
|
if (!script) return;
|
||||||
|
|
||||||
|
const attr = key => script && script.getAttribute(key);
|
||||||
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';
|
||||||
@ -21,17 +23,13 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
const useCache = attr('data-cache');
|
const useCache = attr('data-cache');
|
||||||
const domains = attr('data-domains');
|
const domains = attr('data-domains');
|
||||||
|
|
||||||
if (
|
const disableTracking =
|
||||||
!script ||
|
|
||||||
(dnt && doNotTrack()) ||
|
(dnt && doNotTrack()) ||
|
||||||
(domains &&
|
(domains &&
|
||||||
!domains
|
!domains
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(n => n.trim())
|
.map(n => n.trim())
|
||||||
.includes(hostname))
|
.includes(hostname));
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const root = hostUrl
|
const root = hostUrl
|
||||||
? removeTrailingSlash(hostUrl)
|
? removeTrailingSlash(hostUrl)
|
||||||
@ -58,6 +56,8 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
};
|
};
|
||||||
|
|
||||||
const collect = (type, params, uuid) => {
|
const collect = (type, params, uuid) => {
|
||||||
|
if (disableTracking) return;
|
||||||
|
|
||||||
const key = 'umami.cache';
|
const key = 'umami.cache';
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
@ -74,7 +74,7 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return post(
|
post(
|
||||||
`${root}/api/collect`,
|
`${root}/api/collect`,
|
||||||
{
|
{
|
||||||
type,
|
type,
|
||||||
@ -160,7 +160,7 @@ import { removeTrailingSlash } from '../lib/url';
|
|||||||
|
|
||||||
/* Start */
|
/* Start */
|
||||||
|
|
||||||
if (autoTrack) {
|
if (autoTrack && !disableTracking) {
|
||||||
history.pushState = hook(history, 'pushState', handlePush);
|
history.pushState = hook(history, 'pushState', handlePush);
|
||||||
history.replaceState = hook(history, 'replaceState', handlePush);
|
history.replaceState = hook(history, 'replaceState', handlePush);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user