Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in Conviva type definitions when Yospace is not installed #21

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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