diff --git a/.changeset/rare-readers-talk.md b/.changeset/rare-readers-talk.md new file mode 100644 index 0000000..1307894 --- /dev/null +++ b/.changeset/rare-readers-talk.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/conviva-connector-web": patch +--- + +Fixed an issue where an asset name, provided via a `ConvivaMetadata` object in the `ConvivaConnector` initialization, stops getting reported after a `sourcechange` event. diff --git a/.changeset/sixty-pots-teach.md b/.changeset/sixty-pots-teach.md new file mode 100644 index 0000000..a6e5c9f --- /dev/null +++ b/.changeset/sixty-pots-teach.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/conviva-connector-web": minor +--- + +Added `deviceMetadata` property to `ConvivaConfiguration`. diff --git a/conviva/README.md b/conviva/README.md index 9a3d23c..536aac3 100644 --- a/conviva/README.md +++ b/conviva/README.md @@ -43,6 +43,26 @@ First you need to define the Conviva metadata and configuration: }; ``` +Optionally, you can include device metadata in the ConvivaConfiguration object. Note that `SCREEN_RESOLUTION_WIDTH`, `SCREEN_RESOLUTION_HEIGHT` and `SCREEN_RESOLUTION_SCALE_FACTOR` are the only fields that Conviva will auto-collect on most web-based platforms. + +```typescript +const exampleDeviceMetadata: ConvivaDeviceMetadata = { + [Constants.DeviceMetadata.BRAND]: "Samsung", + [Constants.DeviceMetadata.MANUFACTURER]: "Samsung", + [Constants.DeviceMetadata.MODEL]: "QE43Q64BAUXXN", + [Constants.DeviceMetadata.TYPE]: Constants.DeviceType.SMARTTV, + [Constants.DeviceMetadata.VERSION]: "6.5.0", + [Constants.DeviceMetadata.OS_NAME]: "Tizen", + [Constants.DeviceMetadata.OS_VERSION]: "6.5.0", + [Constants.DeviceMetadata.CATEGORY]: Constants.DeviceCategory.SAMSUNG_TV, + [Constants.DeviceMetadata.SCREEN_RESOLUTION_WIDTH]: 3840, + [Constants.DeviceMetadata.SCREEN_RESOLUTION_HEIGHT]: 2160, + [Constants.DeviceMetadata.SCREEN_RESOLUTION_SCALE_FACTOR]: 1 +} + +convivaMetadata.deviceMetadata = exampleDeviceMetadata +``` + Using these configs you can create the Conviva connector with THEOplayer. * Add as a regular script: @@ -71,6 +91,13 @@ Using these configs you can create the Conviva connector with THEOplayer. The Conviva connector is now ready to start a session once THEOplayer starts playing a source. +Note that the `convivaMetadata` provided to the `ConvivaConnector` constructor is primarily used to pass on to the Conviva SDK's `reportPlaybackRequested`. If a source is set to the player after initializing the connector, you should always provide the corresponding metadata (again) through the connector's `setContentInfo` method. + +```js +player.source = exampleSource; +convivaIntegration.setContentInfo(exampleSourceMetadata); +``` + ## Usage with Yospace connector If you have a Yospace SSAI stream and want to also report ad related events to Conviva, you can use this connector in combination with the Yospace connector: [@theoplayer/yospace-connector-web](https://www.npmjs.com/package/@theoplayer/yospace-connector-web) diff --git a/conviva/package.json b/conviva/package.json index 93a4b87..69ea396 100644 --- a/conviva/package.json +++ b/conviva/package.json @@ -21,7 +21,7 @@ "bundle": "rollup -c rollup.config.mjs", "watch": "npm run bundle -- --watch", "build": "npm run clean && npm run bundle", - "serve": "http-server", + "serve": "http-server ./.. -o /conviva/test/pages/", "test": "jest" }, "author": "THEO Technologies NV", diff --git a/conviva/src/integration/ConvivaConnector.ts b/conviva/src/integration/ConvivaConnector.ts index 9d6787a..54b10c7 100644 --- a/conviva/src/integration/ConvivaConnector.ts +++ b/conviva/src/integration/ConvivaConnector.ts @@ -20,7 +20,8 @@ export class ConvivaConnector { } /** - * Sets Conviva metadata on the Conviva video analytics. + * Sets Conviva metadata on the Conviva video analytics. Use this method to set source + * specific metadata after setting a source to the player. * @param metadata object of key value pairs */ setContentInfo(metadata: ConvivaMetadata): void { diff --git a/conviva/src/integration/ConvivaHandler.ts b/conviva/src/integration/ConvivaHandler.ts index 93c3bf1..d2c474e 100644 --- a/conviva/src/integration/ConvivaHandler.ts +++ b/conviva/src/integration/ConvivaHandler.ts @@ -4,7 +4,8 @@ import { Analytics, Constants, type ConvivaMetadata, - type VideoAnalytics + type VideoAnalytics, + ConvivaDeviceMetadata } from '@convivainc/conviva-js-coresdk'; import type { YospaceConnector } from '@theoplayer/yospace-connector-web'; import { CONVIVA_CALLBACK_FUNCTIONS } from './ConvivaCallbackFunctions'; @@ -12,7 +13,7 @@ import { calculateBufferLength, calculateConvivaOptions, collectContentMetadata, - collectDeviceMetadata, + collectDefaultDeviceMetadata, collectPlayerInfo, flattenErrorObject } from '../utils/Utils'; @@ -25,6 +26,7 @@ export interface ConvivaConfiguration { customerKey: string; debug?: boolean; gatewayUrl?: string; + deviceMetadata?: ConvivaDeviceMetadata; } export class ConvivaHandler { @@ -48,11 +50,10 @@ export class ConvivaHandler { constructor(player: ChromelessPlayer, convivaMetaData: ConvivaMetadata, config: ConvivaConfiguration) { this.player = player; this.convivaMetadata = convivaMetaData; - this.customMetadata = convivaMetaData; this.convivaConfig = config; this.currentSource = player.source; - Analytics.setDeviceMetadata(collectDeviceMetadata()); + Analytics.setDeviceMetadata(this.convivaConfig.deviceMetadata ?? collectDefaultDeviceMetadata()); Analytics.init( this.convivaConfig.customerKey, CONVIVA_CALLBACK_FUNCTIONS, @@ -243,7 +244,11 @@ export class ConvivaHandler { private reportMetadata() { const src = this.player.src ?? ''; const streamType = this.player.duration === Infinity ? Constants.StreamType.LIVE : Constants.StreamType.VOD; - const assetName = this.customMetadata[Constants.ASSET_NAME] ?? this.currentSource?.metadata?.title ?? 'NA'; + const assetName = + this.customMetadata[Constants.ASSET_NAME] ?? + this.convivaMetadata[Constants.ASSET_NAME] ?? + this.currentSource?.metadata?.title ?? + 'NA'; const playerName = this.customMetadata[Constants.PLAYER_NAME] ?? 'THEOplayer'; const metadata = { [Constants.STREAM_URL]: src, diff --git a/conviva/src/utils/Utils.ts b/conviva/src/utils/Utils.ts index 0340074..c9aeda6 100644 --- a/conviva/src/utils/Utils.ts +++ b/conviva/src/utils/Utils.ts @@ -21,7 +21,7 @@ import { } from 'theoplayer'; import { ConvivaConfiguration } from '../integration/ConvivaHandler'; -export function collectDeviceMetadata(): ConvivaDeviceMetadata { +export function collectDefaultDeviceMetadata(): ConvivaDeviceMetadata { // Most device metadata is auto-collected by Conviva. return { [Constants.DeviceMetadata.CATEGORY]: Constants.DeviceCategory.WEB diff --git a/conviva/test/pages/main_esm.html b/conviva/test/pages/main_esm.html index 36b0356..f84f420 100644 --- a/conviva/test/pages/main_esm.html +++ b/conviva/test/pages/main_esm.html @@ -4,16 +4,23 @@ Connector test page - - -
+