From 9bea384cba0d0cfa9e20ce2d2ca06e2fe0e44dd1 Mon Sep 17 00:00:00 2001 From: George Choustoulakis Date: Wed, 21 Feb 2024 12:43:08 +0100 Subject: [PATCH] Expose SessionErrorCode and use in conviva --- .changeset/poor-ads-explain.md | 5 +++++ .../src/integration/ads/YospaceAdReporter.ts | 18 ++++++++++++++---- yospace/src/index.ts | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 .changeset/poor-ads-explain.md diff --git a/.changeset/poor-ads-explain.md b/.changeset/poor-ads-explain.md new file mode 100644 index 00000000..a1ef4fdb --- /dev/null +++ b/.changeset/poor-ads-explain.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/yospace-connector-web": minor +--- + +Exposed SessionErrorCode. diff --git a/conviva/src/integration/ads/YospaceAdReporter.ts b/conviva/src/integration/ads/YospaceAdReporter.ts index 6b74d1fe..a7e72e92 100644 --- a/conviva/src/integration/ads/YospaceAdReporter.ts +++ b/conviva/src/integration/ads/YospaceAdReporter.ts @@ -1,6 +1,12 @@ import { ChromelessPlayer, VideoQuality } from 'theoplayer'; import { AdAnalytics, Constants, VideoAnalytics } from '@convivainc/conviva-js-coresdk'; -import { AdBreak, AdVert, AnalyticEventObserver, YospaceConnector } from '@theoplayer/yospace-connector-web'; +import { + AdBreak, + AdVert, + AnalyticEventObserver, + SessionErrorCode, + YospaceConnector +} from '@theoplayer/yospace-connector-web'; import { collectPlayerInfo, collectYospaceAdMetadata } from '../../utils/Utils'; export class YospaceAdReporter { @@ -30,7 +36,7 @@ export class YospaceAdReporter { onAdvertBreakEnd: this.onYospaceAdBreakEnd, onAdvertStart: this.onYospaceAdvertStart, onAdvertEnd: this.onYospaceAdvertEnd, - onSessionError: () => this.onYospaceError, + onSessionError: this.onYospaceSessionError, onTrackingError: () => {}, onTrackingEvent: (_: string) => {} }; @@ -92,8 +98,12 @@ export class YospaceAdReporter { this.convivaAdAnalytics.reportAdEnded(); }; - private readonly onYospaceError = () => { - this.convivaVideoAnalytics.reportPlaybackError('The Yospace session has timed out.'); + private readonly onYospaceSessionError = (code: SessionErrorCode) => { + if (code === SessionErrorCode.TIMEOUT) { + this.convivaVideoAnalytics.reportPlaybackError('The Yospace session has timed out.'); + } else { + this.convivaVideoAnalytics.reportPlaybackError('The Yospace session has errored.'); + } }; private addEventListeners(): void { diff --git a/yospace/src/index.ts b/yospace/src/index.ts index df949b39..899d3ddd 100644 --- a/yospace/src/index.ts +++ b/yospace/src/index.ts @@ -1,4 +1,4 @@ export * from './integration/YospaceConnector'; -export { AnalyticEventObserver } from './yospace/AnalyticEventObserver'; +export { AnalyticEventObserver, SessionErrorCode } from './yospace/AnalyticEventObserver'; export * from './yospace/AdBreak'; export { SessionProperties } from './yospace/SessionProperties';