Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media/metrics: Avoid reporting preloadTime as 0 #406

Merged
merged 5 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/chatty-moons-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@livepeer/core': patch
'@livepeer/core-react': patch
'@livepeer/core-web': patch
'@livepeer/react': patch
'@livepeer/react-native': patch
---

**Fix:** fixed metrics to only send values when they are defined, to avoid filtering on the backend.
220 changes: 110 additions & 110 deletions packages/core-web/src/media/browser/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ describe('addMediaMetrics', () => {
}

expect(metricsSnapshot?.current).toMatchInlineSnapshot(`
{
"autoplay": "standard",
"duration": 0,
"firstPlayback": 0,
"nError": 0,
"nStalled": 0,
"nWaiting": 0,
"offset": 0,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": 0,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": 0,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
{
"autoplay": "standard",
"duration": null,
"firstPlayback": null,
"nError": null,
"nStalled": 0,
"nWaiting": 0,
"offset": null,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": null,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": null,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
});

it('should update time unpaused and first playback', async () => {
Expand All @@ -72,24 +72,24 @@ describe('addMediaMetrics', () => {
expect(metricsSnapshot?.current).toMatchInlineSnapshot(`
{
"autoplay": "standard",
"duration": 0,
"firstPlayback": 0,
"nError": 0,
"duration": null,
"firstPlayback": null,
"nError": null,
"nStalled": 0,
"nWaiting": 0,
"offset": 0,
"offset": null,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": 0,
"preloadTime": null,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": 0,
"ttff": null,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
Expand All @@ -115,32 +115,32 @@ describe('addMediaMetrics', () => {
}

expect(metricsSnapshot?.current).toMatchInlineSnapshot(`
{
"autoplay": "standard",
"duration": 0,
"firstPlayback": 0,
"nError": 0,
"nStalled": 0,
"nWaiting": 1,
"offset": 0,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": 0,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 1000,
"ttff": 0,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
{
"autoplay": "standard",
"duration": null,
"firstPlayback": null,
"nError": null,
"nStalled": 0,
"nWaiting": 1,
"offset": null,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": null,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 1000,
"ttff": null,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
});

it('should update time stalled and stalled count', async () => {
Expand All @@ -162,32 +162,32 @@ describe('addMediaMetrics', () => {
}

expect(metricsSnapshot?.current).toMatchInlineSnapshot(`
{
"autoplay": "standard",
"duration": 0,
"firstPlayback": 0,
"nError": 0,
"nStalled": 1,
"nWaiting": 0,
"offset": 0,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": 0,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 1000,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": 0,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
{
"autoplay": "standard",
"duration": null,
"firstPlayback": null,
"nError": null,
"nStalled": 1,
"nWaiting": 0,
"offset": null,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": null,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 1000,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": null,
"uid": "",
"userAgent": "UA",
"videoHeight": null,
"videoWidth": null,
}
`);
});
});

Expand All @@ -209,31 +209,31 @@ describe('addMediaMetrics', () => {
}

expect(metricsSnapshot?.current).toMatchInlineSnapshot(`
{
"autoplay": "standard",
"duration": 0,
"firstPlayback": 0,
"nError": 0,
"nStalled": 0,
"nWaiting": 0,
"offset": 0,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": 0,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": 0,
"uid": "",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36",
"videoHeight": null,
"videoWidth": null,
}
`);
{
"autoplay": "standard",
"duration": null,
"firstPlayback": null,
"nError": null,
"nStalled": 0,
"nWaiting": 0,
"offset": null,
"pageUrl": "http://localhost:3000/",
"playbackScore": null,
"player": "hls-1",
"playerHeight": null,
"playerWidth": null,
"preloadTime": null,
"sourceType": "unknown",
"sourceUrl": null,
"timeStalled": 0,
"timeUnpaused": 0,
"timeWaiting": 0,
"ttff": null,
"uid": "",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36",
"videoHeight": null,
"videoWidth": null,
}
`);
});
});
Loading
Loading