add analytics event for lbry:// links

This commit is contained in:
Sean Yesmunt 2019-11-04 10:55:02 -05:00
parent d1807f4fcf
commit 801e285260
2 changed files with 7 additions and 1 deletions

View file

@ -22,6 +22,7 @@ type Analytics = {
rewardEligibleEvent: () => void,
startupEvent: () => void,
readyEvent: number => void,
openUrlEvent: string => void,
};
type LogPublishParams = {
@ -124,6 +125,9 @@ const analytics: Analytics = {
rewardEligibleEvent: () => {
sendGaEvent('Engagement', 'Reward-Eligible');
},
openUrlEvent: (url: string) => {
sendGaEvent('Engagement', 'Open-Url', url);
},
startupEvent: () => {
sendGaEvent('Startup', 'Startup');
},
@ -133,11 +137,12 @@ const analytics: Analytics = {
},
};
function sendGaEvent(category, action) {
function sendGaEvent(category, action, label) {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category,
action,
...(label ? { label } : {}),
});
}
}

View file

@ -141,6 +141,7 @@ ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
} else if (isURIValid(uri)) {
const formattedUri = formatLbryUriForWeb(uri);
app.store.dispatch(push(formattedUri));
analytics.openUrlEvent(formattedUri);
} else {
app.store.dispatch(
doToast({