Skip to content

Commit

Permalink
Expose SessionErrorCode and use in conviva
Browse files Browse the repository at this point in the history
  • Loading branch information
georgechoustoulakis committed Feb 21, 2024
1 parent 7b6dd04 commit 9bea384
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-ads-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/yospace-connector-web": minor
---

Exposed SessionErrorCode.
18 changes: 14 additions & 4 deletions conviva/src/integration/ads/YospaceAdReporter.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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) => {}
};
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion yospace/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 9bea384

Please sign in to comment.