Skip to content

Commit abe2b34

Browse files
Merge pull request #30 from Eyevinn/frontend/update-epas-spec-compliance
fix: use correct TWarningEventPayload type for spec compliance
2 parents bce23ef + c9e7c26 commit abe2b34

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

spec/PlayerAnalyticsConnector.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,23 @@ describe("PlayerAnalyticsConnector", () => {
371371
expect(body.event).toBe("warning");
372372
expect(body.payload.category).toBe("player");
373373
});
374+
375+
it("should send warning event with all TWarningEventPayload fields", () => {
376+
connector.reportWarning({
377+
category: "decoder",
378+
code: "CODEC_FALLBACK",
379+
message: "Fell back to software decoding",
380+
data: { codec: "hevc", fallback: "avc1" },
381+
});
382+
383+
expect(mockFetch).toHaveBeenCalled();
384+
const body = JSON.parse(mockFetch.calls.argsFor(0)[1].body);
385+
expect(body.event).toBe("warning");
386+
expect(body.payload.category).toBe("decoder");
387+
expect(body.payload.code).toBe("CODEC_FALLBACK");
388+
expect(body.payload.message).toBe("Fell back to software decoding");
389+
expect(body.payload.data).toEqual({ codec: "hevc", fallback: "avc1" });
390+
});
374391
});
375392

376393
describe("deinit()", () => {

src/PlayerAnalyticsConnector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TErrorEventPayload,
1111
TEventType,
1212
TMetadataEventPayload,
13+
TWarningEventPayload,
1314
UUID,
1415
} from "@eyevinn/player-analytics-specification";
1516

@@ -187,7 +188,7 @@ export class PlayerAnalyticsConnector {
187188
});
188189
}
189190

190-
public reportWarning(payload: TErrorEventPayload) {
191+
public reportWarning(payload: TWarningEventPayload) {
191192
if (!this.analyticsInitiated) {
192193
console.warn("[PlayerAnalyticsConnector] Analytics not initiated");
193194
return;

0 commit comments

Comments
 (0)