feat: allow blacklisting domains

fixes https://github.com/mikecao/umami/issues/429

Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
pull/436/head
Kipras Melnikovas 2021-01-16 20:13:53 +02:00
parent 1bb46f1d42
commit 44429dceb8
No known key found for this signature in database
GPG Key ID: AA505BC1C6D8AD90
1 changed files with 13 additions and 0 deletions

View File

@ -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));