Revert "Revert "add logging of player point of presence""

This reverts commit 4067e1ffd8.
This commit is contained in:
Sean Yesmunt 2020-09-09 14:54:51 -04:00
parent 799c0c1f11
commit bba539f846
3 changed files with 35 additions and 24 deletions

View file

@ -38,7 +38,14 @@ type Analytics = {
videoStartEvent: (string, number) => void,
videoBufferEvent: (
StreamClaim,
{ timeAtBuffer: number, bufferDuration: number, bitRate: number, duration: number, userIdHash: string }
{
timeAtBuffer: number,
bufferDuration: number,
bitRate: number,
duration: number,
userIdHash: string,
playerPoweredBy: string,
}
) => void,
emailProvidedEvent: () => void,
emailVerifiedEvent: () => void,
@ -185,32 +192,32 @@ const analytics: Analytics = {
sendPromMetric('time_to_start', duration);
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
},
videoBufferEvent: (claim, data) => {
// @if TARGET='web'
sendPromMetric('buffer');
// @endif
videoBufferEvent: (claim, data) => {
sendMatomoEvent('Media', 'BufferTimestamp', claim.claim_id, data.timeAtBuffer);
fetch(LBRY_WEB_BUFFER_API, {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
device: 'web',
type: 'buffering',
client: data.userIdHash,
data: {
url: claim.canonical_url,
position: data.timeAtBuffer,
duration: data.bufferDuration,
stream_duration: data.duration,
stream_bitrate: data.bitRate,
if (LBRY_WEB_BUFFER_API) {
fetch(LBRY_WEB_BUFFER_API, {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}),
});
body: JSON.stringify({
device: 'web',
type: 'buffering',
client: data.userIdHash,
data: {
url: claim.canonical_url,
position: data.timeAtBuffer,
duration: data.bufferDuration,
player: data.playerPoweredBy,
stream_duration: data.duration,
stream_bitrate: data.bitRate,
},
}),
});
}
},
tagFollowEvent: (tag, following) => {
sendMatomoEvent('Tag', following ? 'Tag-Follow' : 'Tag-Unfollow', tag);

View file

@ -87,7 +87,10 @@ function VideoViewer(props: Props) {
}, [uri, previousUri]);
function doTrackingBuffered(e: Event, data: any) {
doAnalyticsBuffer(uri, data);
fetch(source, { method: 'HEAD' }).then(response => {
data.playerPoweredBy = response.headers.get('x-powered-by');
doAnalyticsBuffer(uri, data);
});
}
function doTrackingFirstPlay(e: Event, data: any) {

View file

@ -491,6 +491,7 @@ export function doAnalyticsBuffer(uri, bufferData) {
bitRate,
userIdHash,
duration: fileDurationInSeconds,
playerPoweredBy: bufferData.playerPoweredBy,
});
};
}