Skip to content

Commit a531208

Browse files
committed
Fix ignored label property in the startHtml5MediaTracking call (#1378)
1 parent eaa30fc commit a531208

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
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": "Fix ignored label property in the startHtml5MediaTracking call",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-plugin-media-tracking"
10+
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ function htmlContext(el: HTMLMediaElement): (() => SelfDescribingJson)[] {
5959
}
6060

6161
export function setUpListeners(config: ElementConfig) {
62-
const { id, video } = config;
62+
const { id, video, label } = config;
6363

6464
startMediaTracking({
6565
...config,
6666
id,
67-
player: updatePlayer(video),
67+
player: {
68+
label,
69+
...updatePlayer(video)
70+
},
6871
context: (config.context ?? []).concat(htmlContext(video)),
6972
});
7073

plugins/browser-plugin-media-tracking/tests/test.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,20 @@ describe('MediaTrackingPlugin', () => {
312312

313313
expect(eventQueue.length).toBe(0);
314314
});
315+
316+
it("adds label to tracked event", async () => {
317+
const video = document.createElement('video');
318+
video.id = id;
319+
document.body.appendChild(video);
320+
321+
startHtml5MediaTracking({ id: 'id', label: 'foo', video, captureEvents: [MediaEventType.Play] });
322+
323+
video.play();
324+
325+
let playerContext = eventQueue[0].context.find(
326+
(c) => c.schema === 'iglu:com.snowplowanalytics.snowplow/media_player/jsonschema/2-0-0'
327+
)?.data;
328+
329+
expect(playerContext?.label).toEqual('foo');
330+
});
315331
});

0 commit comments

Comments
 (0)