Supporting "Do Not Track" for Gogle Analytics and Sentry error reporting
This commit is contained in:
parent
7698901451
commit
1a8bb762cb
@ -1,10 +1,12 @@
|
||||
import ReactGA from 'react-ga';
|
||||
|
||||
const setupAnalytics = () => {
|
||||
ReactGA.initialize(process.env.GA_PROPERTY, {
|
||||
debug: (process.env.NODE_ENV !== 'production')
|
||||
});
|
||||
ReactGA.pageview(document.location.pathname);
|
||||
if (navigator.doNotTrack !== '1' && window.doNotTrack !== '1') {
|
||||
ReactGA.initialize(process.env.GA_PROPERTY, {
|
||||
debug: (process.env.NODE_ENV !== 'production')
|
||||
});
|
||||
ReactGA.pageview(document.location.pathname);
|
||||
}
|
||||
};
|
||||
|
||||
export default setupAnalytics;
|
||||
|
@ -34,4 +34,24 @@ describe('setupAnalytics', () => {
|
||||
setupAnalytics();
|
||||
expect(ReactGA.pageview).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('when "Do Not Track" is set', () => {
|
||||
beforeEach(() => {
|
||||
navigator.doNotTrack = '1';
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
navigator.doNotTrack = undefined;
|
||||
});
|
||||
|
||||
it('does not initialize', () => {
|
||||
setupAnalytics();
|
||||
expect(ReactGA.initialize).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not trigger a pageview', () => {
|
||||
setupAnalytics();
|
||||
expect(ReactGA.pageview).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,12 +1,14 @@
|
||||
import Raven from 'raven-js';
|
||||
|
||||
const setupRaven = () => {
|
||||
Raven.config(process.env.SENTRY_KEY, {
|
||||
whitelistUrls: [/https:\/\/(.*\.)?regexper\.com/],
|
||||
environment: process.env.DEPLOY_ENV,
|
||||
debug: (process.env.NODE_ENV !== 'production'),
|
||||
release: process.env.BUILD_ID
|
||||
});
|
||||
if (navigator.doNotTrack !== '1' && window.doNotTrack !== '1') {
|
||||
Raven.config(process.env.SENTRY_KEY, {
|
||||
whitelistUrls: [/https:\/\/(.*\.)?regexper\.com/],
|
||||
environment: process.env.DEPLOY_ENV,
|
||||
debug: (process.env.NODE_ENV !== 'production'),
|
||||
release: process.env.BUILD_ID
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default setupRaven;
|
||||
|
@ -45,4 +45,19 @@ describe('setupRaven', () => {
|
||||
release: 'test ID'
|
||||
}));
|
||||
});
|
||||
|
||||
describe('when "Do Not Track" is set', () => {
|
||||
beforeEach(() => {
|
||||
navigator.doNotTrack = '1';
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
navigator.doNotTrack = undefined;
|
||||
});
|
||||
|
||||
it('does not intialize', () => {
|
||||
setupRaven();
|
||||
expect(Raven.config).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user