Skip to content

Commit f578e0d

Browse files
committed
Add a default 0 value for start and end in the media_element entity time ranges (#1428)
1 parent e56256f commit f578e0d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-plugin-media-tracking",
5+
"comment": "Add a default 0 value for start and end in the media_element entity time ranges",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-plugin-media-tracking"
10+
}

plugins/browser-plugin-media-tracking/src/helperFunctions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ type TimeRange = { start: number; end: number };
5353
export function timeRangesToObjectArray(t: TimeRanges): TimeRange[] {
5454
const out: TimeRange[] = [];
5555
for (let i = 0; i < t.length; i++) {
56-
out.push({ start: t.start(i), end: t.end(i) });
56+
const start = t.start(i);
57+
const end = t.end(i);
58+
if (isFinite(start) && isFinite(end)) {
59+
out.push({ start: start || 0, end: end || 0 });
60+
}
5761
}
5862
return out;
5963
}

0 commit comments

Comments
 (0)