use new analytics id for non-pb traffic

This commit is contained in:
Sean Yesmunt 2019-11-04 13:36:37 -05:00
parent 801e285260
commit 8900038a4a

View file

@ -9,6 +9,15 @@ import ElectronCookies from '@exponent/electron-cookies';
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
const devInternalApis = process.env.LBRY_API_URL; const devInternalApis = process.env.LBRY_API_URL;
const LBRY_TV_MINUS_PIRATE_BAY_UA_ID = 'UA-60403362-16';
const LBRY_TV_UA_ID = 'UA-60403362-12';
const DESKTOP_UA_ID = 'UA-60403362-13';
// @if TARGET='app'
ElectronCookies.enable({
origin: 'https://lbry.tv',
});
// @endif
type Analytics = { type Analytics = {
pageView: string => void, pageView: string => void,
@ -157,18 +166,29 @@ function sendGaTimingEvent(category: string, action: string, timeInMs: number) {
} }
} }
// Initialize google analytics let gaTrackers = [];
// Set `debug: true` for debug info
// Will change once we have separate ids for desktop/web
const UA_ID = IS_WEB ? 'UA-60403362-12' : 'UA-60403362-13';
// @if TARGET='app' if (!IS_WEB) {
ElectronCookies.enable({ gaTrackers.push({
origin: 'https://lbry.tv', trackingId: DESKTOP_UA_ID,
}); });
// @endif } else {
gaTrackers.push({
trackingId: LBRY_TV_UA_ID,
});
ReactGA.initialize(UA_ID, { const { search } = window.location;
const urlParams = new URLSearchParams(search);
const isPirateBayUser = urlParams.get('tm_source') === 'PB';
if (!isPirateBayUser) {
gaTrackers.push({
trackingId: LBRY_TV_MINUS_PIRATE_BAY_UA_ID,
});
}
}
ReactGA.initialize(gaTrackers, {
testMode: process.env.NODE_ENV !== 'production', testMode: process.env.NODE_ENV !== 'production',
cookieDomain: 'auto', cookieDomain: 'auto',
siteSpeedSampleRate: 100, siteSpeedSampleRate: 100,