Random fixes #2729

Merged
neb-b merged 12 commits from fixes into master 2019-08-15 05:11:48 +02:00
2 changed files with 19 additions and 34 deletions
Showing only changes of commit 88cd024c8c - Show all commits

View file

@ -36,10 +36,7 @@ const analytics: Analytics = {
// @if TARGET='app'
Native.getAppVersionInfo().then(({ localVersion }) => {
ReactGA.event({
category: 'Desktop-Version',
action: localVersion,
});
sendGaEvent('Desktop-Version', localVersion);
});
// @endif
}
@ -88,47 +85,31 @@ const analytics: Analytics = {
}
},
tagFollowEvent: (tag, following, location) => {
if (analyticsEnabled) {
ReactGA.event({
category: following ? 'Tag-Follow' : 'Tag-Unfollow',
action: tag,
});
}
sendGaEvent(following ? 'Tag-Follow' : 'Tag-Unfollow', tag);
},
channelBlockEvent: (uri, blocked, location) => {
if (analyticsEnabled) {
ReactGA.event({
category: blocked ? 'Channel-Hidden' : 'Channel-Unhidden',
action: uri,
});
}
sendGaEvent(blocked ? 'Channel-Hidden' : 'Channel-Unhidden', uri);
},
emailProvidedEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Email-Provided',
});
}
sendGaEvent('Engagement', 'Email-Provided');
},
emailVerifiedEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Email-Verified',
});
}
sendGaEvent('Engagement', 'Email-Verified');
},
rewardEligibleEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Reward-Eligible',
});
}
sendGaEvent('Engagement', 'Reward-Eligible');
},
};
kauffj commented 2019-08-15 00:26:25 +02:00 (Migrated from github.com)
Review

Making a sendReactGAEvent or equivalent function would eliminate these repeated if checks and could also help ensure the checks are not accidentally left out in the future.

Making a `sendReactGAEvent` or equivalent function would eliminate these repeated if checks and could also help ensure the checks are not accidentally left out in the future.
neb-b commented 2019-08-15 05:11:31 +02:00 (Migrated from github.com)
Review

Yeah I've been meaning to do this, just did and it's way nicer now.

Yeah I've been meaning to do this, just did and it's way nicer now.
function sendGaEvent(category, action) {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category,
action,
});
}
}
// Initialize google analytics
// Set `debug: true` for debug info
// Will change once we have separate ids for desktop/web
@ -143,6 +124,8 @@ ElectronCookies.enable({
ReactGA.initialize(UA_ID, {
testMode: process.env.NODE_ENV !== 'production',
cookieDomain: 'auto',
// un-comment to see events as they are sent to google
// debug: true,
});
// Manually call the first page view

View file

@ -75,6 +75,8 @@ function App(props: Props) {
}, [previousUserId, userId]);
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) {
analytics.emailVerifiedEvent();
}