Skip to content

Commit

Permalink
Merge pull request #27 from THEOplayer/bugfix/comscore-improvements
Browse files Browse the repository at this point in the history
Bugfix/comscore improvements
  • Loading branch information
wjoosen authored Sep 27, 2024
2 parents 7aeaedb + 955b853 commit c5969f2
Show file tree
Hide file tree
Showing 14 changed files with 445 additions and 274 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-gorillas-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": patch
---

Fixed an issue where DVR window length and offsets were incorrectly reported.
5 changes: 5 additions & 0 deletions .changeset/chilled-lamps-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": patch
---

Fixed an issue where playhead positions or content/ad durations were not reported in (rounded) milliseconds.
5 changes: 5 additions & 0 deletions .changeset/kind-pugs-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": patch
---

Fixed an issue where only one ad in an adbreak would be reported.
5 changes: 5 additions & 0 deletions .changeset/metal-ties-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": patch
---

Fixed an issue where playback of the main content wouldn't get reported if Google IMA returned an empty pre-roll ad break.
5 changes: 5 additions & 0 deletions .changeset/rare-cycles-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": patch
---

Fixed an issue where no content metadata was reported during a pre-roll ad.
5 changes: 5 additions & 0 deletions .changeset/wise-vans-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/comscore-connector-web": minor
---

Add the option to inform the ComScore library of the environment it is running in through the `setPlatformAPI`.
38 changes: 38 additions & 0 deletions comscore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const comscoreConfig = {
publisherId: '<your publisher id>',
applicationName: 'Test App',
userConsent: '1',
platformApi: ns_.analytics.PlatformAPIs.WebBrowser,
debug: true
};
Expand All @@ -47,6 +48,43 @@ const comscoreMetadata = {
const comscoreConnector = new ComscoreConnector(player, comscoreConfig, comscoreMetadata);
```
### Optional ComscoreConfiguration properties
#### `usagePropertiesAutoUpdateMode`
When omitted this wil default to foregroundOnly.
#### `skeleton`
Pass an interface object with target platform specific implementations for the necessary Platform APIs. E.g.
```js
analytics.PlatformApi.setPlatformApi(analytics.PlatformApi.PlatformApis.Skeleton, {
onDataFetch: function (onSuccessCallback, onErrorCallback) {
// Execute a function with platform-specific code to retrieve up-to-date information.
runPlatformSpecificCodeToRetrieveValues(onSuccessCallback, onErrorCallback);
}
// Other overridden PlatformAPI methods, as needed.
});
```
For more information, please consult the [Skeleton PlatformAPI Implementation Guide](https://mymetrix-support.comscore.com/hc/en-us/article_attachments/19635711827867)
Note that if the skeleton property is defined, the connector will always use `setPlatformAPI(ns_.analytics.PlatformAPIs.Skeleton)`.
#### `platformApi`
Pass a valid value from `ns_.analytics.PlatformAPIs`. When omitted, the connector will report `setPlatformAPI(ns_.analytics.PlatformAPIs.html5)`.
#### `adIdProcessor`
Pass a function with the following signature if you require custom ad id handling: `(ad: Ad) => string`. When omitted, the connector will use `(ad) => ad.id`. Consult THEOplayer's types for more info about the `Ad` interface.
#### `debug`
A flag to enable verbose logging.
### Passing metadata dynamically
The connector allows updating the current asset's metadata at any time. Do it when setting a new source to the player.
Expand Down
2 changes: 1 addition & 1 deletion comscore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"bundle": "rollup -c rollup.config.mjs",
"watch": "npm run bundle -- --watch",
"build": "npm run clean && npm run bundle",
"serve": "http-server ./.. -o /comscore/test/pages/main.html",
"serve": "http-server ./.. -o /comscore/test/pages/main_umd.html",
"test": "echo \"No tests yet\""
},
"repository": {
Expand Down
22 changes: 22 additions & 0 deletions comscore/src/api/ComscoreConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ export enum ComscoreUsagePropertiesAutoUpdateMode {
disabled = "disabled"
}

export enum ComscorePlatformAPIs {
SmartTV = 0,
Netcast = 1,
Cordova = 2,
Trilithium = 3,
AppleTV = 4,
Chromecast = 5,
Xbox = 6,
webOS = 7,
tvOS = 8,
nodejs = 9,
html5 = 10,
JSMAF = 11,
Skeleton = 12,
WebBrowser = 13,
SamsungTizenTV = 14
}

export interface ComscoreConfiguration {
/**
* Also known as the c2 value
Expand All @@ -24,6 +42,10 @@ export interface ComscoreConfiguration {
*/
usagePropertiesAutoUpdateMode?: ComscoreUsagePropertiesAutoUpdateMode;
skeleton?: any;
/**
* Defaults to ns_.analytics.PlatformAPIs.html5 if no skeleton is provided or ns_.analytics.PlatformAPIs.Skeleton if a skeleton is provided.
*/
platformApi?: ComscorePlatformAPIs;
adIdProcessor?: (ad: Ad) => string;
debug?: boolean;
}
Expand Down
46 changes: 43 additions & 3 deletions comscore/src/api/ComscoreConnector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChromelessPlayer } from 'theoplayer';
import type { ComscoreConfiguration, ComscoreUserConsent } from './ComscoreConfiguration';
import { ComscoreConfiguration, ComscorePlatformAPIs, ComscoreUserConsent } from './ComscoreConfiguration';
import type { ComscoreMetadata } from './ComscoreMetadata';
import { ComscoreStreamingAnalyticsTHEOIntegration } from '../integration/ComscoreStreamingAnalyticsTHEOIntegration';

Expand Down Expand Up @@ -28,7 +28,10 @@ export class ComscoreConnector {
// Set platform API
if (this.configuration.skeleton) {
this.analytics.PlatformApi.setPlatformAPI(this.analytics.PlatformAPIs.Skeleton, this.configuration.skeleton)
} else {
} else if (this.configuration.platformApi){
this.analytics.PlatformApi.setPlatformAPI(mapPlatformAPI(this.configuration.platformApi))
if (this.configuration.debug) console.log(`[COMSCORE] Set the Platform API to ${this.configuration.platformApi}`)
} else {
this.analytics.PlatformApi.setPlatformAPI(this.analytics.PlatformAPIs.html5)
}

Expand Down Expand Up @@ -96,4 +99,41 @@ export class ComscoreConnector {
destroy(): void {
this.streamingAnalyticsIntegration.destroy();
}
}
}

function mapPlatformAPI(platformApi: ComscorePlatformAPIs): ns_.analytics.PlatformAPIs {
switch (platformApi) {
case ComscorePlatformAPIs.SmartTV:
return ns_.analytics.PlatformAPIs.SmartTV;
case ComscorePlatformAPIs.Netcast:
return ns_.analytics.PlatformAPIs.Netcast;
case ComscorePlatformAPIs.Cordova:
return ns_.analytics.PlatformAPIs.Cordova;
case ComscorePlatformAPIs.Trilithium:
return ns_.analytics.PlatformAPIs.Trilithium;
case ComscorePlatformAPIs.AppleTV:
return ns_.analytics.PlatformAPIs.AppleTV;
case ComscorePlatformAPIs.Chromecast:
return ns_.analytics.PlatformAPIs.Chromecast;
case ComscorePlatformAPIs.Xbox:
return ns_.analytics.PlatformAPIs.Xbox;
case ComscorePlatformAPIs.webOS:
return ns_.analytics.PlatformAPIs.webOS;
case ComscorePlatformAPIs.tvOS:
return ns_.analytics.PlatformAPIs.tvOS;
case ComscorePlatformAPIs.nodejs:
return ns_.analytics.PlatformAPIs.nodejs;
case ComscorePlatformAPIs.html5:
return ns_.analytics.PlatformAPIs.html5;
case ComscorePlatformAPIs.JSMAF:
return ns_.analytics.PlatformAPIs.JSMAF;
case ComscorePlatformAPIs.Skeleton:
return ns_.analytics.PlatformAPIs.Skeleton;
case ComscorePlatformAPIs.WebBrowser:
return ns_.analytics.PlatformAPIs.WebBrowser;
case ComscorePlatformAPIs.SamsungTizenTV:
return ns_.analytics.PlatformAPIs.SamsungTizenTV;
default:
return ns_.analytics.PlatformAPIs.html5;
}
}
Loading

0 comments on commit c5969f2

Please sign in to comment.