mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +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;
|
||||
|
||||
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 hostUrl = attr('data-host-url');
|
||||
const autoTrack = attr('data-auto-track') !== 'false';
|
||||
@ -21,17 +23,13 @@ import { removeTrailingSlash } from '../lib/url';
|
||||
const useCache = attr('data-cache');
|
||||
const domains = attr('data-domains');
|
||||
|
||||
if (
|
||||
!script ||
|
||||
const disableTracking =
|
||||
(dnt && doNotTrack()) ||
|
||||
(domains &&
|
||||
!domains
|
||||
.split(',')
|
||||
.map(n => n.trim())
|
||||
.includes(hostname))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
.includes(hostname));
|
||||
|
||||
const root = hostUrl
|
||||
? removeTrailingSlash(hostUrl)
|
||||
@ -58,6 +56,8 @@ import { removeTrailingSlash } from '../lib/url';
|
||||
};
|
||||
|
||||
const collect = (type, params, uuid) => {
|
||||
if (disableTracking) return;
|
||||
|
||||
const key = 'umami.cache';
|
||||
|
||||
const payload = {
|
||||
@ -74,7 +74,7 @@ import { removeTrailingSlash } from '../lib/url';
|
||||
});
|
||||
}
|
||||
|
||||
return post(
|
||||
post(
|
||||
`${root}/api/collect`,
|
||||
{
|
||||
type,
|
||||
@ -160,7 +160,7 @@ import { removeTrailingSlash } from '../lib/url';
|
||||
|
||||
/* Start */
|
||||
|
||||
if (autoTrack) {
|
||||
if (autoTrack && !disableTracking) {
|
||||
history.pushState = hook(history, 'pushState', handlePush);
|
||||
history.replaceState = hook(history, 'replaceState', handlePush);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user