add events for startup and app-ready
This commit is contained in:
parent
a0e0684d14
commit
7628a04f6a
2 changed files with 28 additions and 0 deletions
|
@ -20,6 +20,8 @@ type Analytics = {
|
|||
emailProvidedEvent: () => void,
|
||||
emailVerifiedEvent: () => void,
|
||||
rewardEligibleEvent: () => void,
|
||||
startupEvent: () => void,
|
||||
readyEvent: number => void,
|
||||
};
|
||||
|
||||
let analyticsEnabled: boolean = true;
|
||||
|
@ -104,6 +106,13 @@ const analytics: Analytics = {
|
|||
rewardEligibleEvent: () => {
|
||||
sendGaEvent('Engagement', 'Reward-Eligible');
|
||||
},
|
||||
startupEvent: () => {
|
||||
sendGaEvent('Startup', 'Startup');
|
||||
},
|
||||
readyEvent: (timeToReady: number) => {
|
||||
sendGaEvent('Startup', 'App-Ready');
|
||||
sendGaTimingEvent('Startup', 'App-Ready', timeToReady);
|
||||
},
|
||||
};
|
||||
|
||||
function sendGaEvent(category, action) {
|
||||
|
@ -115,6 +124,16 @@ function sendGaEvent(category, action) {
|
|||
}
|
||||
}
|
||||
|
||||
function sendGaTimingEvent(category: string, action: string, timeInMs: number) {
|
||||
if (analyticsEnabled && isProduction) {
|
||||
ReactGA.timing({
|
||||
category,
|
||||
variable: action,
|
||||
value: timeInMs,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize google analytics
|
||||
// Set `debug: true` for debug info
|
||||
// Will change once we have separate ids for desktop/web
|
||||
|
@ -129,6 +148,7 @@ ElectronCookies.enable({
|
|||
ReactGA.initialize(UA_ID, {
|
||||
testMode: process.env.NODE_ENV !== 'production',
|
||||
cookieDomain: 'auto',
|
||||
siteSpeedSampleRate: 100,
|
||||
// un-comment to see events as they are sent to google
|
||||
// debug: true,
|
||||
});
|
||||
|
|
|
@ -29,12 +29,16 @@ import { ConnectedRouter, push } from 'connected-react-router';
|
|||
import cookie from 'cookie';
|
||||
import { formatLbryUriForWeb } from 'util/uri';
|
||||
import { PersistGate } from 'redux-persist/integration/react';
|
||||
import analytics from 'analytics';
|
||||
|
||||
// Import our app styles
|
||||
// If a style is not necessary for the initial page load, it should be removed from `all.scss`
|
||||
// and loaded dynamically in the component that consumes it
|
||||
import 'scss/all.scss';
|
||||
|
||||
const startTime = Date.now();
|
||||
analytics.startupEvent();
|
||||
|
||||
const APPPAGEURL = 'lbry://?';
|
||||
// @if TARGET='app'
|
||||
const { autoUpdater } = remote.require('electron-updater');
|
||||
|
@ -231,6 +235,10 @@ function AppWrapper() {
|
|||
app.store.dispatch(doBlackListedOutpointsSubscribe());
|
||||
app.store.dispatch(doFilteredOutpointsSubscribe());
|
||||
window.sessionStorage.setItem('loaded', 'y');
|
||||
|
||||
const appReadyTime = Date.now();
|
||||
const timeToStart = appReadyTime - startTime;
|
||||
analytics.readyEvent(timeToStart);
|
||||
}
|
||||
}, [readyToLaunch, haveLaunched]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue