Add domain filter to tracker.

This commit is contained in:
Mike Cao 2020-10-04 22:27:59 -07:00
parent ca8a6fe049
commit 195eb06a02
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "umami",
"version": "0.77.0",
"version": "0.78.0",
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <mike@mikecao.com>",
"license": "MIT",

View File

@ -19,8 +19,19 @@ import { removeTrailingSlash } from '../lib/url';
const autoTrack = attr('data-auto-track') !== 'false';
const dnt = attr('data-do-not-track');
const useCache = attr('data-cache');
const domains = attr('data-domains');
if (!script || (dnt && doNotTrack())) return;
if (
!script ||
(dnt && doNotTrack()) ||
(domains &&
!domains
.split(',')
.map(n => n.trim())
.includes(hostname))
) {
return;
}
const root = hostUrl
? removeTrailingSlash(hostUrl)