Remove references to Desktop and lbry.tv
This commit is contained in:
parent
bba3a17977
commit
dab1ca1cb7
1 changed files with 17 additions and 91 deletions
108
ui/analytics.js
108
ui/analytics.js
|
@ -4,11 +4,6 @@ import ReactGA from 'react-ga';
|
||||||
import * as Sentry from '@sentry/browser';
|
import * as Sentry from '@sentry/browser';
|
||||||
import { history } from './store';
|
import { history } from './store';
|
||||||
import { SDK_API_PATH } from './index';
|
import { SDK_API_PATH } from './index';
|
||||||
// @if TARGET='app'
|
|
||||||
import Native from 'native';
|
|
||||||
import ElectronCookies from '@exponent/electron-cookies';
|
|
||||||
import { generateInitialUrl } from 'util/url';
|
|
||||||
// @endif
|
|
||||||
// import getConnectionSpeed from 'util/detect-user-bandwidth';
|
// import getConnectionSpeed from 'util/detect-user-bandwidth';
|
||||||
|
|
||||||
// let userDownloadBandwidthInBitsPerSecond;
|
// let userDownloadBandwidthInBitsPerSecond;
|
||||||
|
@ -21,25 +16,13 @@ import { generateInitialUrl } from 'util/url';
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const devInternalApis = process.env.LBRY_API_URL && process.env.LBRY_API_URL.includes('dev');
|
const devInternalApis = process.env.LBRY_API_URL && process.env.LBRY_API_URL.includes('dev');
|
||||||
const LBRY_TV_MINUS_PIRATE_BAY_UA_ID = 'UA-60403362-16';
|
const ODYSEE_UA_ID = 'UA-60403362-12';
|
||||||
const LBRY_TV_UA_ID = 'UA-60403362-12';
|
|
||||||
const DESKTOP_UA_ID = 'UA-60403362-13';
|
|
||||||
const SECOND_TRACKER_NAME = 'tracker2';
|
|
||||||
|
|
||||||
export const SHARE_INTERNAL = 'shareInternal';
|
export const SHARE_INTERNAL = 'shareInternal';
|
||||||
const SHARE_THIRD_PARTY = 'shareThirdParty';
|
|
||||||
|
|
||||||
const WATCHMAN_BACKEND_ENDPOINT = 'https://watchman.na-backend.odysee.com/reports/playback';
|
const WATCHMAN_BACKEND_ENDPOINT = 'https://watchman.na-backend.odysee.com/reports/playback';
|
||||||
const SEND_DATA_TO_WATCHMAN_INTERVAL = 10; // in seconds
|
const SEND_DATA_TO_WATCHMAN_INTERVAL = 10; // in seconds
|
||||||
|
|
||||||
// @if TARGET='app'
|
|
||||||
if (isProduction) {
|
|
||||||
ElectronCookies.enable({
|
|
||||||
origin: 'https://lbry.tv',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// @endif
|
|
||||||
|
|
||||||
type Analytics = {
|
type Analytics = {
|
||||||
error: (string) => Promise<any>,
|
error: (string) => Promise<any>,
|
||||||
sentryError: ({} | string, {}) => Promise<any>,
|
sentryError: ({} | string, {}) => Promise<any>,
|
||||||
|
@ -87,10 +70,6 @@ type LogPublishParams = {
|
||||||
|
|
||||||
let internalAnalyticsEnabled: boolean = IS_WEB || false;
|
let internalAnalyticsEnabled: boolean = IS_WEB || false;
|
||||||
// let thirdPartyAnalyticsEnabled: boolean = IS_WEB || false;
|
// let thirdPartyAnalyticsEnabled: boolean = IS_WEB || false;
|
||||||
// @if TARGET='app'
|
|
||||||
if (window.localStorage.getItem(SHARE_INTERNAL) === 'true') internalAnalyticsEnabled = true;
|
|
||||||
// if (window.localStorage.getItem(SHARE_THIRD_PARTY) === 'true') thirdPartyAnalyticsEnabled = true;
|
|
||||||
// @endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the mobile device type viewing the data
|
* Determine the mobile device type viewing the data
|
||||||
|
@ -297,7 +276,7 @@ const analytics: Analytics = {
|
||||||
},
|
},
|
||||||
pageView: (path, search) => {
|
pageView: (path, search) => {
|
||||||
if (internalAnalyticsEnabled) {
|
if (internalAnalyticsEnabled) {
|
||||||
ReactGA.pageview(path, [SECOND_TRACKER_NAME]);
|
ReactGA.pageview(path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setUser: (userId) => {
|
setUser: (userId) => {
|
||||||
|
@ -305,28 +284,14 @@ const analytics: Analytics = {
|
||||||
ReactGA.set({
|
ReactGA.set({
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// @if TARGET='app'
|
|
||||||
Native.getAppVersionInfo().then(({ localVersion }) => {
|
|
||||||
sendGaEvent('Version', 'Desktop-Version', localVersion);
|
|
||||||
});
|
|
||||||
// @endif
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleInternal: (enabled: boolean): void => {
|
toggleInternal: (enabled: boolean): void => {
|
||||||
// Always collect analytics on lbry.tv
|
// Always collect analytics on Odysee for now.
|
||||||
// @if TARGET='app'
|
|
||||||
internalAnalyticsEnabled = enabled;
|
|
||||||
window.localStorage.setItem(SHARE_INTERNAL, enabled);
|
|
||||||
// @endif
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleThirdParty: (enabled: boolean): void => {
|
toggleThirdParty: (enabled: boolean): void => {
|
||||||
// Always collect analytics on lbry.tv
|
// Always collect analytics on Odysee for now.
|
||||||
// @if TARGET='app'
|
|
||||||
// thirdPartyAnalyticsEnabled = enabled;
|
|
||||||
window.localStorage.setItem(SHARE_THIRD_PARTY, enabled);
|
|
||||||
// @endif
|
|
||||||
},
|
},
|
||||||
|
|
||||||
apiLogView: (uri, outpoint, claimId, timeToStart) => {
|
apiLogView: (uri, outpoint, claimId, timeToStart) => {
|
||||||
|
@ -432,29 +397,23 @@ const analytics: Analytics = {
|
||||||
|
|
||||||
function sendGaEvent(category, action, label, value) {
|
function sendGaEvent(category, action, label, value) {
|
||||||
if (internalAnalyticsEnabled && isProduction) {
|
if (internalAnalyticsEnabled && isProduction) {
|
||||||
ReactGA.event(
|
ReactGA.event({
|
||||||
{
|
category,
|
||||||
category,
|
action,
|
||||||
action,
|
...(label ? { label } : {}),
|
||||||
...(label ? { label } : {}),
|
...(value ? { value } : {}),
|
||||||
...(value ? { value } : {}),
|
});
|
||||||
},
|
|
||||||
[SECOND_TRACKER_NAME]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendGaTimingEvent(category: string, action: string, timeInMs: number, label?: string) {
|
function sendGaTimingEvent(category: string, action: string, timeInMs: number, label?: string) {
|
||||||
if (internalAnalyticsEnabled && isProduction) {
|
if (internalAnalyticsEnabled && isProduction) {
|
||||||
ReactGA.timing(
|
ReactGA.timing({
|
||||||
{
|
category,
|
||||||
category,
|
variable: action,
|
||||||
variable: action,
|
value: timeInMs,
|
||||||
value: timeInMs,
|
...(label ? { label } : {}),
|
||||||
...(label ? { label } : {}),
|
});
|
||||||
},
|
|
||||||
[SECOND_TRACKER_NAME]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,30 +426,7 @@ function sendPromMetric(name: string, value?: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let gaTrackers = [];
|
const gaTrackers = [{ trackingId: ODYSEE_UA_ID }];
|
||||||
|
|
||||||
if (!IS_WEB) {
|
|
||||||
gaTrackers.push({
|
|
||||||
trackingId: DESKTOP_UA_ID,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
gaTrackers.push({
|
|
||||||
trackingId: LBRY_TV_UA_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { search } = window.location;
|
|
||||||
const urlParams = new URLSearchParams(search);
|
|
||||||
const isPirateBayUser = urlParams.get('utm_source') === 'PB';
|
|
||||||
|
|
||||||
if (!isPirateBayUser) {
|
|
||||||
gaTrackers.push({
|
|
||||||
trackingId: LBRY_TV_MINUS_PIRATE_BAY_UA_ID,
|
|
||||||
gaOptions: {
|
|
||||||
name: SECOND_TRACKER_NAME,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReactGA.initialize(gaTrackers, {
|
ReactGA.initialize(gaTrackers, {
|
||||||
testMode: process.env.NODE_ENV !== 'production',
|
testMode: process.env.NODE_ENV !== 'production',
|
||||||
|
@ -502,17 +438,7 @@ ReactGA.initialize(gaTrackers, {
|
||||||
|
|
||||||
// Manually call the first page view
|
// Manually call the first page view
|
||||||
// React Router doesn't include this on `history.listen`
|
// React Router doesn't include this on `history.listen`
|
||||||
// @if TARGET='web'
|
|
||||||
analytics.pageView(window.location.pathname + window.location.search, window.location.search);
|
analytics.pageView(window.location.pathname + window.location.search, window.location.search);
|
||||||
// @endif
|
|
||||||
|
|
||||||
// @if TARGET='app'
|
|
||||||
ReactGA.set({ checkProtocolTask: null });
|
|
||||||
ReactGA.set({ location: 'https://odysee.com' });
|
|
||||||
analytics.pageView(
|
|
||||||
window.location.pathname.split('.html')[1] + window.location.search || generateInitialUrl(window.location.hash)
|
|
||||||
);
|
|
||||||
// @endif;
|
|
||||||
|
|
||||||
// Listen for url changes and report
|
// Listen for url changes and report
|
||||||
// This will include search queries
|
// This will include search queries
|
||||||
|
|
Loading…
Reference in a new issue