Skip to content

Commit

Permalink
Base CSAI vs SSAI conviva reporting on ad(break) integration
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesMoris-Dolby committed Aug 28, 2024
1 parent 49b1b3f commit c4faa68
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
7 changes: 4 additions & 3 deletions conviva/src/integration/ads/AdReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export class AdReporter {

private readonly onAdBreakBegin = (event: any) => {
this.currentAdBreak = event.ad as AdBreak;
this.currentAdBreak.integration;
this.convivaVideoAnalytics.reportAdBreakStarted(
calculateAdType(this.player),
calculateAdType(this.currentAdBreak),
Constants.AdPlayer.CONTENT,
calculateCurrentAdBreakInfo(this.currentAdBreak, this.adBreakCounter)
);
Expand Down Expand Up @@ -67,7 +68,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 +81,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
22 changes: 20 additions & 2 deletions conviva/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,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.CLIENT_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

0 comments on commit c4faa68

Please sign in to comment.