From 195eb06a02916f3bc93f471264d074b6abfc639b Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Sun, 4 Oct 2020 22:27:59 -0700 Subject: [PATCH] Add domain filter to tracker. --- package.json | 2 +- tracker/index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0d602350..c21f3076 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", diff --git a/tracker/index.js b/tracker/index.js index 154e0034..df4c5216 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -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)