feat: allow blacklisting domains
fixes https://github.com/mikecao/umami/issues/429 Signed-off-by: Kipras Melnikovas <kipras@kipras.org>pull/436/head
parent
1bb46f1d42
commit
44429dceb8
|
@ -23,12 +23,25 @@ import { removeTrailingSlash } from '../lib/url';
|
||||||
const dnt = attr('data-do-not-track');
|
const dnt = attr('data-do-not-track');
|
||||||
const useCache = attr('data-cache');
|
const useCache = attr('data-cache');
|
||||||
const domains = attr('data-domains');
|
const domains = attr('data-domains');
|
||||||
|
const domainBlacklist = attr('data-domains-blacklist');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* blacklist has higher importance than whitelist,
|
||||||
|
*
|
||||||
|
* i.e., if an item is both whitelisted and blacklisted,
|
||||||
|
* it will be blacklisted.
|
||||||
|
*
|
||||||
|
*/
|
||||||
const disableTracking =
|
const disableTracking =
|
||||||
localStorage.getItem('umami.disabled') ||
|
localStorage.getItem('umami.disabled') ||
|
||||||
(dnt && doNotTrack()) ||
|
(dnt && doNotTrack()) ||
|
||||||
(domains &&
|
(domains &&
|
||||||
!domains
|
!domains
|
||||||
|
.split(',')
|
||||||
|
.map(n => n.trim())
|
||||||
|
.includes(hostname)) ||
|
||||||
|
(domainBlacklist &&
|
||||||
|
domainBlacklist
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(n => n.trim())
|
.map(n => n.trim())
|
||||||
.includes(hostname));
|
.includes(hostname));
|
||||||
|
|
Loading…
Reference in New Issue