diff --git a/ui/analytics.js b/ui/analytics.js index a9bea13fd..c880cf7e4 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -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); diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index 5a3c4b15d..7b719f910 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -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) { diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js index 7b9eeef0c..6501970e9 100644 --- a/ui/redux/actions/app.js +++ b/ui/redux/actions/app.js @@ -491,6 +491,7 @@ export function doAnalyticsBuffer(uri, bufferData) { bitRate, userIdHash, duration: fileDurationInSeconds, + playerPoweredBy: bufferData.playerPoweredBy, }); }; }