cleanup reactGA events
This commit is contained in:
parent
5dfee2c30a
commit
88cd024c8c
2 changed files with 19 additions and 34 deletions
|
@ -36,10 +36,7 @@ const analytics: Analytics = {
|
||||||
|
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
Native.getAppVersionInfo().then(({ localVersion }) => {
|
Native.getAppVersionInfo().then(({ localVersion }) => {
|
||||||
ReactGA.event({
|
sendGaEvent('Desktop-Version', localVersion);
|
||||||
category: 'Desktop-Version',
|
|
||||||
action: localVersion,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
// @endif
|
// @endif
|
||||||
}
|
}
|
||||||
|
@ -88,47 +85,31 @@ const analytics: Analytics = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tagFollowEvent: (tag, following, location) => {
|
tagFollowEvent: (tag, following, location) => {
|
||||||
if (analyticsEnabled) {
|
sendGaEvent(following ? 'Tag-Follow' : 'Tag-Unfollow', tag);
|
||||||
ReactGA.event({
|
|
||||||
category: following ? 'Tag-Follow' : 'Tag-Unfollow',
|
|
||||||
action: tag,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
channelBlockEvent: (uri, blocked, location) => {
|
channelBlockEvent: (uri, blocked, location) => {
|
||||||
if (analyticsEnabled) {
|
sendGaEvent(blocked ? 'Channel-Hidden' : 'Channel-Unhidden', uri);
|
||||||
ReactGA.event({
|
|
||||||
category: blocked ? 'Channel-Hidden' : 'Channel-Unhidden',
|
|
||||||
action: uri,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
emailProvidedEvent: () => {
|
emailProvidedEvent: () => {
|
||||||
if (analyticsEnabled && isProduction) {
|
sendGaEvent('Engagement', 'Email-Provided');
|
||||||
ReactGA.event({
|
|
||||||
category: 'Engagement',
|
|
||||||
action: 'Email-Provided',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
emailVerifiedEvent: () => {
|
emailVerifiedEvent: () => {
|
||||||
if (analyticsEnabled && isProduction) {
|
sendGaEvent('Engagement', 'Email-Verified');
|
||||||
ReactGA.event({
|
|
||||||
category: 'Engagement',
|
|
||||||
action: 'Email-Verified',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
rewardEligibleEvent: () => {
|
rewardEligibleEvent: () => {
|
||||||
if (analyticsEnabled && isProduction) {
|
sendGaEvent('Engagement', 'Reward-Eligible');
|
||||||
ReactGA.event({
|
|
||||||
category: 'Engagement',
|
|
||||||
action: 'Reward-Eligible',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function sendGaEvent(category, action) {
|
||||||
|
if (analyticsEnabled && isProduction) {
|
||||||
|
ReactGA.event({
|
||||||
|
category,
|
||||||
|
action,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize google analytics
|
// Initialize google analytics
|
||||||
// Set `debug: true` for debug info
|
// Set `debug: true` for debug info
|
||||||
// Will change once we have separate ids for desktop/web
|
// Will change once we have separate ids for desktop/web
|
||||||
|
@ -143,6 +124,8 @@ ElectronCookies.enable({
|
||||||
ReactGA.initialize(UA_ID, {
|
ReactGA.initialize(UA_ID, {
|
||||||
testMode: process.env.NODE_ENV !== 'production',
|
testMode: process.env.NODE_ENV !== 'production',
|
||||||
cookieDomain: 'auto',
|
cookieDomain: 'auto',
|
||||||
|
// un-comment to see events as they are sent to google
|
||||||
|
// debug: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Manually call the first page view
|
// Manually call the first page view
|
||||||
|
|
|
@ -75,6 +75,8 @@ function App(props: Props) {
|
||||||
}, [previousUserId, userId]);
|
}, [previousUserId, userId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Check that previousHasVerifiedEmail was not undefined instead of just not truthy
|
||||||
|
// This ensures we don't fire the emailVerified event on the initial user fetch
|
||||||
if (previousHasVerifiedEmail !== undefined && hasVerifiedEmail) {
|
if (previousHasVerifiedEmail !== undefined && hasVerifiedEmail) {
|
||||||
analytics.emailVerifiedEvent();
|
analytics.emailVerifiedEvent();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue