send player events as timing events

This commit is contained in:
jessop 2020-01-26 18:34:36 -05:00 committed by Sean Yesmunt
parent 1adede3a33
commit 31fa714ef5
3 changed files with 13 additions and 6 deletions

View file

@ -910,5 +910,12 @@
"%claimsInChannel% publishes": "%claimsInChannel% publishes", "%claimsInChannel% publishes": "%claimsInChannel% publishes",
"%claimsInChannel% publish": "%claimsInChannel% publish", "%claimsInChannel% publish": "%claimsInChannel% publish",
"Publishing": "Publishing", "Publishing": "Publishing",
"Update published": "Update published" "Update published": "Update published",
} "Delete this file from my computer": "Delete this file from my computer",
"Are you sure you'd like to remove %title% from LBRY?": "Are you sure you'd like to remove %title% from LBRY?",
"This will increase the overall bid amount for %title%, which will boost its ability to be discovered while active.": "This will increase the overall bid amount for %title%, which will boost its ability to be discovered while active.",
"Support %amount% LBC": "Support %amount% LBC",
"You deposited %amount% LBC as a support!": "You deposited %amount% LBC as a support!",
"/wallet": "/wallet",
"LBRY Link": "LBRY Link"
}

View file

@ -130,10 +130,10 @@ const analytics: Analytics = {
} }
}, },
videoStartEvent: (claimId, duration) => { videoStartEvent: (claimId, duration) => {
sendGaEvent('Media', 'StartDelay', claimId, duration); sendGaTimingEvent('Media', 'StartDelay', Number((duration * 1000).toFixed(0)), claimId);
}, },
videoBufferEvent: (claimId, currentTime) => { videoBufferEvent: (claimId, currentTime) => {
sendGaEvent('Media', 'BufferTimestamp', claimId, currentTime); sendGaTimingEvent('Media', 'BufferTimestamp', currentTime * 1000, claimId);
}, },
tagFollowEvent: (tag, following, location) => { tagFollowEvent: (tag, following, location) => {
sendGaEvent(following ? 'Tag-Follow' : 'Tag-Unfollow', tag); sendGaEvent(following ? 'Tag-Follow' : 'Tag-Unfollow', tag);
@ -176,13 +176,14 @@ function sendGaEvent(category, action, label, value) {
} }
} }
function sendGaTimingEvent(category: string, action: string, timeInMs: number) { function sendGaTimingEvent(category: string, action: string, timeInMs: number, label?: string) {
if (analyticsEnabled && isProduction) { if (analyticsEnabled && isProduction) {
ReactGA.timing( ReactGA.timing(
{ {
category, category,
variable: action, variable: action,
value: timeInMs, value: timeInMs,
...(label ? { label } : {}),
}, },
[SECOND_TRACKER_NAME] [SECOND_TRACKER_NAME]
); );

View file

@ -222,7 +222,6 @@ function VideoViewer(props: Props) {
player.off(); player.off();
} }
}; };
// include requireRedraw here so the event listener is re-added when we need to manually remove/add the video player
}, [player]); }, [player]);
return ( return (