From 91b07fd56cb2669f4aeab55968edbf50c80647eb Mon Sep 17 00:00:00 2001 From: Daksh Shah Date: Sun, 6 Sep 2020 15:46:29 +0530 Subject: [PATCH] Add support for excluded and included domains --- tracker/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tracker/index.js b/tracker/index.js index 9a5051b8..251e2aec 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -17,6 +17,16 @@ import { removeTrailingSlash } from '../lib/url'; // eslint-disable-next-line no-undef if (!script || (__DNT__ && doNotTrack())) return; + const excludedDomains = script.getAttribute('excluded-domains') + ? script.getAttribute('excluded-domains').split(',') + : []; + const allowedDomains = script.getAttribute('included-domains') + ? script.getAttribute('included-domains').split(',') + : []; + const isExcludedDomain = excludedDomains.includes(window.location.hostname); + const isAllowedDomain = allowedDomains.includes(window.location.hostname); + if (isExcludedDomain || !isAllowedDomain) return; + const website = script.getAttribute('data-website-id'); const hostUrl = script.getAttribute('data-host-url'); const root = hostUrl