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

Feature/conviva device metadata #63

Merged
merged 20 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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/sixty-pots-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/conviva-connector-web": minor
---

Added `deviceMetadata` property to `ConvivaConfiguration`.
20 changes: 20 additions & 0 deletions conviva/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ First you need to define the Conviva metadata and configuration:
};
```

Optionally, you can include device metadata in the ConvivaConfiguration object

```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:
Expand Down
2 changes: 1 addition & 1 deletion conviva/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/main_umd.html",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to open the pages folder instead? Then they can choose our other pages more easily if they wanna test yospace for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"test": "jest"
},
"author": "THEO Technologies NV",
Expand Down
8 changes: 5 additions & 3 deletions conviva/src/integration/ConvivaHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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';
import {
calculateBufferLength,
calculateConvivaOptions,
collectContentMetadata,
collectDeviceMetadata,
collectDefaultDeviceMetadata,
collectPlayerInfo,
flattenErrorObject
} from '../utils/Utils';
Expand All @@ -25,6 +26,7 @@ export interface ConvivaConfiguration {
customerKey: string;
debug?: boolean;
gatewayUrl?: string;
deviceMetadata?: ConvivaDeviceMetadata;
}

export class ConvivaHandler {
Expand Down Expand Up @@ -52,7 +54,7 @@ export class ConvivaHandler {
this.convivaConfig = config;
this.currentSource = player.source;

Analytics.setDeviceMetadata(collectDeviceMetadata());
Analytics.setDeviceMetadata(this.convivaConfig.deviceMetadata ?? collectDefaultDeviceMetadata());
Analytics.init(
this.convivaConfig.customerKey,
CONVIVA_CALLBACK_FUNCTIONS,
Expand Down
2 changes: 1 addition & 1 deletion conviva/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion conviva/test/pages/main_umd.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@
const convivaConfig = {
debug: false,
gatewayUrl: 'CUSTOMER_GATEWAY_GOES_HERE',
customerKey: 'CUSTOMER_KEY_GOES_HERE' // Can be a test or production key.
customerKey: 'CUSTOMER_KEY_GOES_HERE', // Can be a test or production key.
deviceMetadata: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have this specific device metadata on our test page while we can't know the users setup? It is already mentioned in the README that it is an option to set this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Conviva.Constants.DeviceMetadata.BRAND]: "Chrome",
[Conviva.Constants.DeviceMetadata.MANUFACTURER]: "Apple",
[Conviva.Constants.DeviceMetadata.MODEL]: "MacBook Pro M2",
[Conviva.Constants.DeviceMetadata.TYPE]: Conviva.Client.DeviceType.DESKTOP,
[Conviva.Constants.DeviceMetadata.VERSION]: "131.0.6778.86",
[Conviva.Constants.DeviceMetadata.OS_NAME]: "macOS Sonoma",
[Conviva.Constants.DeviceMetadata.OS_VERSION]: "14.7.0",
[Conviva.Constants.DeviceMetadata.CATEGORY]: Conviva.Client.DeviceCategory.APPLE_DEVICE,
[Conviva.Constants.DeviceMetadata.SCREEN_RESOLUTION_WIDTH]: 3024,
[Conviva.Constants.DeviceMetadata.SCREEN_RESOLUTION_HEIGHT]: 1964,
[Conviva.Constants.DeviceMetadata.SCREEN_RESOLUTION_SCALE_FACTOR]: 1
}
};

const convivaIntegration = new THEOplayerConvivaConnector.ConvivaConnector(
Expand Down