diff options
author | Jeremy Jackson <jjackson@gitlab.com> | 2019-08-23 10:11:26 +0300 |
---|---|---|
committer | Kushal Pandya <kushalspandya@gmail.com> | 2019-08-23 10:11:26 +0300 |
commit | ca9598c1fb9bc408a26793d419b19f39314efe3f (patch) | |
tree | faff18e02bdd152d0a3221b2543c102709a77954 /spec | |
parent | e12f7fe062574b0ad3e271b149928252a99119f5 (diff) |
Add logic for respecting browser DNT setting
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/tracking_spec.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/frontend/tracking_spec.js b/spec/frontend/tracking_spec.js index cd0bf50f8e9..0e862c683d3 100644 --- a/spec/frontend/tracking_spec.js +++ b/spec/frontend/tracking_spec.js @@ -15,6 +15,12 @@ describe('Tracking', () => { snowplowSpy = jest.spyOn(window, 'snowplow'); }); + afterEach(() => { + window.doNotTrack = undefined; + navigator.doNotTrack = undefined; + navigator.msDoNotTrack = undefined; + }); + it('tracks to snowplow (our current tracking system)', () => { Tracking.event('_category_', '_eventName_', { label: '_label_' }); @@ -31,6 +37,27 @@ describe('Tracking', () => { expect(snowplowSpy).not.toHaveBeenCalled(); }); + + it('skips tracking if the user does not want to be tracked (general spec)', () => { + window.doNotTrack = '1'; + Tracking.event('_category_', '_eventName_'); + + expect(snowplowSpy).not.toHaveBeenCalled(); + }); + + it('skips tracking if the user does not want to be tracked (firefox legacy)', () => { + navigator.doNotTrack = 'yes'; + Tracking.event('_category_', '_eventName_'); + + expect(snowplowSpy).not.toHaveBeenCalled(); + }); + + it('skips tracking if the user does not want to be tracked (IE legacy)', () => { + navigator.msDoNotTrack = '1'; + Tracking.event('_category_', '_eventName_'); + + expect(snowplowSpy).not.toHaveBeenCalled(); + }); }); describe('tracking interface events', () => { |