Skip to content

Commit

Permalink
Add ad analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
karpov-kir committed May 15, 2024
1 parent 182466e commit 7c82809
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ts/ConvivaAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class ConvivaAnalytics {
private readonly logger: Conviva.LoggingInterface;
private sessionKey: number;
private convivaVideoAnalytics: Conviva.VideoAnalytics;
private convivaAdAnalytics: Conviva.AdAnalytics;

/**
* Tracks the ad playback status and is true between ON_AD_STARTED and ON_AD_FINISHED/SKIPPED/ERROR.
Expand Down Expand Up @@ -442,6 +443,7 @@ export class ConvivaAnalytics {

// Create a Conviva monitoring session.
this.convivaVideoAnalytics = Conviva.Analytics.buildVideoAnalytics();
this.convivaAdAnalytics = Conviva.Analytics.buildAdAnalytics(this.convivaVideoAnalytics);
this.convivaVideoAnalytics.reportPlaybackRequested(this.contentMetadataBuilder.build());
this.sessionKey = this.convivaVideoAnalytics.getSessionId();
this.convivaVideoAnalytics.setCallback(() => {
Expand Down Expand Up @@ -692,10 +694,13 @@ export class ConvivaAnalytics {
return;
}

this.debugLog('[ ConvivaAnalytics ] reportng adbreak started', event);

this.convivaVideoAnalytics.reportAdBreakStarted(
Conviva.Constants.AdType.CLIENT_SIDE,
Conviva.Constants.AdPlayer.SEPARATE,
);
this.convivaAdAnalytics.reportAdStarted();
};

private onAdBreakFinished = (event: AdBreakEvent | ErrorEvent) => {
Expand All @@ -707,7 +712,10 @@ export class ConvivaAnalytics {
return;
}

this.debugLog('[ ConvivaAnalytics ] reportng adbreak finished', event);

this.convivaVideoAnalytics.reportAdBreakEnded();
this.convivaAdAnalytics.reportAdEnded();
this.convivaVideoAnalytics.reportPlaybackMetric(
Conviva.Constants.Playback.PLAYER_STATE,
Conviva.Constants.PlayerState.PLAYING,
Expand Down

0 comments on commit 7c82809

Please sign in to comment.