Skip to content

Commit

Permalink
Merge pull request #46 from THEOplayer/feature/slate-reporting
Browse files Browse the repository at this point in the history
Feature/slate reporting
  • Loading branch information
GillesMoris-Dolby authored Oct 16, 2024
2 parents e8480a1 + 34521b2 commit 190ada7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-knives-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/conviva-connector-web": minor
---

Added reporting of slate for THEOads.
6 changes: 3 additions & 3 deletions conviva/src/integration/ads/AdReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AdReporter {
private readonly onAdBreakBegin = (event: any) => {
this.currentAdBreak = event.ad as AdBreak;
this.convivaVideoAnalytics.reportAdBreakStarted(
calculateAdType(this.player),
calculateAdType(this.currentAdBreak),
Constants.AdPlayer.CONTENT,
calculateCurrentAdBreakInfo(this.currentAdBreak, this.adBreakCounter)
);
Expand Down Expand Up @@ -67,7 +67,7 @@ export class AdReporter {
this.contentInfo()[Constants.ASSET_NAME] ?? this.player.source?.metadata?.title ?? 'NA';

// [Required] The ad technology as CLIENT_SIDE/SERVER_SIDE
adMetadata['c3.ad.technology'] = calculateAdType(this.player);
adMetadata['c3.ad.technology'] = calculateAdType(currentAd);

this.convivaAdAnalytics.setAdInfo(adMetadata);
this.convivaAdAnalytics.reportAdLoaded(adMetadata);
Expand All @@ -80,7 +80,7 @@ export class AdReporter {
this.convivaAdAnalytics.reportAdMetric(Constants.Playback.BITRATE, (currentAd as GoogleImaAd).bitrate || 0);

// Report playing state in case of SSAI.
if (calculateAdType(this.player) === Constants.AdType.SERVER_SIDE) {
if (calculateAdType(currentAd) === Constants.AdType.SERVER_SIDE) {
this.convivaAdAnalytics.reportAdMetric(Constants.Playback.PLAYER_STATE, Constants.PlayerState.PLAYING);
}
};
Expand Down
24 changes: 21 additions & 3 deletions conviva/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,26 @@ export function collectDeviceMetadata(): ConvivaDeviceMetadata {
};
}

export function calculateAdType(player: ChromelessPlayer) {
return player.source?.ads?.length ? Constants.AdType.CLIENT_SIDE : Constants.AdType.SERVER_SIDE;
export function calculateAdType(adOrBreak: Ad | AdBreak) {
switch (adOrBreak.integration) {
case 'theoads': {
// TODO: THEOads is a Server-Guided Ad Insertion (SGAI) solution, which can't be reported to Conviva as such yet.
return Constants.AdType.SERVER_SIDE;
}
case undefined:
case '':
case 'csai':
case 'theo': // Deprecated
case 'google-ima':
case 'spotx':
case 'freewheel': {
return Constants.AdType.CLIENT_SIDE;
}
default: {
// CustomAdIntegrationKinds are server side ad connectors.
return Constants.AdType.SERVER_SIDE;
}
}
}

export function calculateVerizonAdBreakInfo(adBreak: VerizonMediaAdBreak, adBreakIndex: number): ConvivaAdBreakInfo {
Expand Down Expand Up @@ -181,7 +199,7 @@ export function collectAdMetadata(ad: Ad): ConvivaMetadata {

// [Preferred] A boolean value that indicates whether this ad is a Slate or not.
// Set to "true" for Slate and "false" for a regular ad. By default, set to "false"
adMetadata['c3.ad.isSlate'] = 'false';
adMetadata['c3.ad.isSlate'] = `${Boolean(ad.isSlate)}`;

// [Preferred] Only valid for wrapper VAST responses.
// This tag must capture the "first" Ad Id in the wrapper chain when a Linear creative is available or there is
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"prettier": "^3.2.4",
"rimraf": "^5.0.5",
"rollup": "^4.14.0",
"theoplayer": "^7.4.1",
"theoplayer": "^7.12.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
Expand Down

0 comments on commit 190ada7

Please sign in to comment.