Skip to content

Commit

Permalink
separate function for setting dvr window length and offset
Browse files Browse the repository at this point in the history
  • Loading branch information
wjoosen committed Sep 26, 2024
1 parent 56415d9 commit 955b853
Showing 1 changed file with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,7 @@ export class ComscoreStreamingAnalyticsTHEOIntegration {
console.log(`[COMSCORE - STATE] State change ${this.state} -> VIDEO`);
this.state = ComscoreState.VIDEO;
this.setContentMetadata();
if (this.dvrWindowLengthMs) {
this.streamingAnalytics.setDvrWindowLength(this.dvrWindowLengthMs);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(`[COMSCORE - StreamingAnalytics] setDvrWindowLength ${this.dvrWindowLengthMs}`);
this.streamingAnalytics.startFromDvrWindowOffset(this.dvrWindowOffsetMs ?? 0);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(
`[COMSCORE - StreamingAnalytics] startFromDvrWindowOffset ${this.dvrWindowOffsetMs}`
);
}
this.maybeReportDvrFields();
break;
case ComscoreState.ADVERTISEMENT:
case ComscoreState.ADVERTISEMENT_PAUSED:
Expand All @@ -196,16 +187,7 @@ export class ComscoreStreamingAnalyticsTHEOIntegration {
console.log(`[COMSCORE - STATE] State change ${this.state} -> VIDEO`);
this.state = ComscoreState.VIDEO;
this.setContentMetadata();
if (this.dvrWindowLengthMs) {
this.streamingAnalytics.setDvrWindowLength(this.dvrWindowLengthMs);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(`[COMSCORE - StreamingAnalytics] setDvrWindowLength ${this.dvrWindowLengthMs}`);
this.streamingAnalytics.startFromDvrWindowOffset(this.dvrWindowOffsetMs ?? 0);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(
`[COMSCORE - StreamingAnalytics] startFromDvrWindowOffset ${this.dvrWindowOffsetMs}`
);
}
this.maybeReportDvrFields();
break;
case ComscoreState.VIDEO_PAUSED:
if (this.configuration.debug && LOG_STATE_CHANGES)
Expand Down Expand Up @@ -519,6 +501,17 @@ export class ComscoreStreamingAnalyticsTHEOIntegration {
}
};

private maybeReportDvrFields = () => {
if (this.dvrWindowLengthMs) {
this.streamingAnalytics.setDvrWindowLength(this.dvrWindowLengthMs);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(`[COMSCORE - StreamingAnalytics] setDvrWindowLength ${this.dvrWindowLengthMs}`);
this.streamingAnalytics.startFromDvrWindowOffset(this.dvrWindowOffsetMs ?? 0);
if (this.configuration.debug && LOG_STREAMINGANALYTICS)
console.log(`[COMSCORE - StreamingAnalytics] startFromDvrWindowOffset ${this.dvrWindowOffsetMs}`);
}
};

private findAdBreakType = (offset: number, maxDuration: number, integration: string): AdBreakType => {
if (offset === 0) {
if (this.configuration.debug) console.log('[COMSCORE] Mark as PRE_ROLL');
Expand Down

0 comments on commit 955b853

Please sign in to comment.