Skip to content

Commit

Permalink
Fix ignored label property in the startHtml5MediaTracking call (#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein authored Nov 11, 2024
1 parent e6e853a commit 7e6b787
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@snowplow/browser-plugin-media-tracking",
"comment": "Fix ignored label property in the startHtml5MediaTracking call",
"type": "none"
}
],
"packageName": "@snowplow/browser-plugin-media-tracking"
}
7 changes: 5 additions & 2 deletions plugins/browser-plugin-media-tracking/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ function htmlContext(el: HTMLMediaElement): (() => SelfDescribingJson)[] {
}

export function setUpListeners(config: ElementConfig) {
const { id, video } = config;
const { id, video, label } = config;

startMediaTracking({
...config,
id,
player: updatePlayer(video),
player: {
label,
...updatePlayer(video)
},
context: (config.context ?? []).concat(htmlContext(video)),
});

Expand Down
16 changes: 16 additions & 0 deletions plugins/browser-plugin-media-tracking/tests/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,20 @@ describe('MediaTrackingPlugin', () => {

expect(eventQueue.length).toBe(0);
});

it("adds label to tracked event", async () => {
const video = document.createElement('video');
video.id = id;
document.body.appendChild(video);

startHtml5MediaTracking({ id: 'id', label: 'foo', video, captureEvents: [MediaEventType.Play] });

video.play();

let playerContext = eventQueue[0].context.find(
(c) => c.schema === 'iglu:com.snowplowanalytics.snowplow/media_player/jsonschema/2-0-0'
)?.data;

expect(playerContext?.label).toEqual('foo');
});
});

0 comments on commit 7e6b787

Please sign in to comment.