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

Bugfix/comscore improvements #27

Merged
merged 26 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7ea36be
open existing test page in serve script
wjoosen Jun 8, 2024
8dd5dfe
provide ad duration in milliseconds
wjoosen Jun 8, 2024
c4ddb31
use rounded amount of milliseconds
wjoosen Jun 8, 2024
9d53084
catch undefined ad durations before conversion to ms
wjoosen Jun 8, 2024
75a512d
use rounded amount of milliseconds when reporting new playback position
wjoosen Jun 8, 2024
234d418
store the built ContentMetadata object in contentMetadata property
wjoosen Jun 9, 2024
20ebeb1
call notifyEnd and set new ad metadata after each ad
wjoosen Jun 9, 2024
9da96d0
introduce dvr window related properties
wjoosen Jun 13, 2024
bd490c0
store dvr window offset in ms
wjoosen Jun 13, 2024
c243056
store dvr window length in ms
wjoosen Jun 13, 2024
eab424d
report dvr window properties to comscore after setting main content m…
wjoosen Jun 13, 2024
e67c032
add changesets
wjoosen Sep 13, 2024
e40bdfa
Accept ComscoreConfiguration property to set the platform api
wjoosen Sep 13, 2024
173bfc0
add platform api example
wjoosen Sep 13, 2024
bfc6701
add changeset
wjoosen Sep 13, 2024
6180f4b
Extend README
wjoosen Sep 13, 2024
c4c6913
Fix typedoc warning
wjoosen Sep 13, 2024
d5703f7
use mapped platform api type
wjoosen Sep 14, 2024
d6b8e54
include tizen platform api
wjoosen Sep 14, 2024
04c4c9c
add changeset for missing related content metadata bugfix
wjoosen Sep 16, 2024
12f4d81
only ignore playing events before pre-roll breaks that have ads
wjoosen Sep 18, 2024
8b29b08
prettier
wjoosen Sep 18, 2024
ef6bfa3
add changeset for empty pre-roll issue
wjoosen Sep 18, 2024
04e1f18
remove empty comment
wjoosen Sep 26, 2024
56415d9
return early if the ads feature is not enabled on the player sdk
wjoosen Sep 26, 2024
955b853
separate function for setting dvr window length and offset
wjoosen Sep 26, 2024
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/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);
}
//
Copy link
Contributor

@Jeroen-Veltmans Jeroen-Veltmans Sep 25, 2024

Choose a reason for hiding this comment

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

Empty comment can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// 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)`.
MattiasBuelens marked this conversation as resolved.
Show resolved Hide resolved

#### `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