Skip to content

Commit

Permalink
Merge pull request #21 from THEOplayer/fix-yospace-in-conviva-types
Browse files Browse the repository at this point in the history
Fix error in Conviva type definitions when Yospace is not installed
  • Loading branch information
MattiasBuelens authored Apr 9, 2024
2 parents da2555a + 8044537 commit 4437786
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-buckets-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/conviva-connector-web": patch
---

Fixed an issue where TypeScript could throw a TS2307 type error on the generated type definitions when the optional `@theoplayer/yospace-connector-web` peer dependency is not installed.
5 changes: 5 additions & 0 deletions .changeset/proud-bottles-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/conviva-connector-web": minor
---

Changed Conviva SDK to a peer dependency, enabling users to update it independently from the Conviva connector.
7 changes: 4 additions & 3 deletions conviva/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
"LICENSE.md",
"package.json"
],
"dependencies": {
"@convivainc/conviva-js-coresdk": "^4.7.4"
},
"peerDependencies": {
"@convivainc/conviva-js-coresdk": "^4.7.4",
"@theoplayer/yospace-connector-web": "^2.1.1",
"theoplayer": "^5.0.0 || ^6.0.0 || ^7.0.0"
},
"peerDependenciesMeta": {
"@theoplayer/yospace-connector-web": {
"optional": true
}
},
"devDependencies": {
"@convivainc/conviva-js-coresdk": "^4.7.4"
}
}
1 change: 1 addition & 0 deletions conviva/src/integration/ConvivaConnector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ChromelessPlayer } from 'theoplayer';
import type { ConvivaMetadata } from '@convivainc/conviva-js-coresdk';
/** @ts-ignore Optional dependency, will become `any` if not installed. */
import type { YospaceConnector } from '@theoplayer/yospace-connector-web';
import { ConvivaConfiguration, ConvivaHandler } from './ConvivaHandler';

Expand Down
8 changes: 7 additions & 1 deletion conviva/src/integration/ads/YospaceAdReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class YospaceAdReporter {
};

private readonly onYospaceSessionError = (code: SessionErrorCode) => {
if (code === SessionErrorCode.TIMEOUT) {
const yospaceCode = code as number as YospaceSessionErrorCode;
if (yospaceCode === YospaceSessionErrorCode.TIMEOUT) {
this.convivaVideoAnalytics.reportPlaybackError('The Yospace session has timed out.');
} else {
this.convivaVideoAnalytics.reportPlaybackError('The Yospace session has errored.');
Expand All @@ -121,3 +122,8 @@ export class YospaceAdReporter {
this.yospaceConnector.unregisterAnalyticEventObserver(this.observer);
}
}

// Keep this in sync with SessionErrorCode from yospace-connector-web
enum YospaceSessionErrorCode {
TIMEOUT = 0
}
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion yospace/src/yospace/AnalyticEventObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { AdBreak, AdVert } from './AdBreak';
import { TrackingError } from './TrackingError';
import { YospaceSessionManager } from './YospaceSessionManager';

// Keep this in sync with YospaceSessionErrorCode from conviva-connector-web
export enum SessionErrorCode {
TIMEOUT
TIMEOUT = 0
}

export interface AnalyticEventObserver {
Expand Down

0 comments on commit 4437786

Please sign in to comment.