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 useCache = attr('data-cache');
|
||||
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 =
|
||||
localStorage.getItem('umami.disabled') ||
|
||||
(dnt && doNotTrack()) ||
|
||||
(domains &&
|
||||
!domains
|
||||
.split(',')
|
||||
.map(n => n.trim())
|
||||
.includes(hostname)) ||
|
||||
(domainBlacklist &&
|
||||
domainBlacklist
|
||||
.split(',')
|
||||
.map(n => n.trim())
|
||||
.includes(hostname));
|
||||
|
|
Loading…
Reference in New Issue