Skip to content

Commit

Permalink
fix(FEC-8309): playTimeSum value in View event is incorrect (not accu…
Browse files Browse the repository at this point in the history
…mulative (#11)

Change playTimeSum calculation
  • Loading branch information
Dan Ziv authored Jun 13, 2018
1 parent a78647f commit e58a9e5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default class Kava extends BasePlugin {
_viewEventEnabled: boolean;
_firstPlayRequestTime: number;
_bufferStartTime: number;
_previousCurrentTime: number;
_isFirstPlay: boolean;
_isEnded: boolean;
_isPaused: boolean;
Expand Down Expand Up @@ -103,7 +102,6 @@ export default class Kava extends BasePlugin {
}

_resetFlags(): void {
this._previousCurrentTime = 0;
this._isFirstPlay = true;
this._isEnded = false;
this._isPaused = false;
Expand Down Expand Up @@ -131,7 +129,6 @@ export default class Kava extends BasePlugin {
return;
}

this._updatePlayTimeSumModel();
if (this._isBuffering) {
this._updateBufferModel();
this._bufferStartTime = Date.now();
Expand Down Expand Up @@ -214,6 +211,7 @@ export default class Kava extends BasePlugin {

_onReport(): void {
if (this._viewEventEnabled) {
this._updatePlayTimeSumModel();
this._sendAnalytics(KavaEventModel.VIEW);
} else {
this.logger.warn(`VIEW event blocked because server response of viewEventsEnabled=false`);
Expand Down Expand Up @@ -250,7 +248,6 @@ export default class Kava extends BasePlugin {
}

_onSeeking(): void {
this._previousCurrentTime = this.player.currentTime;
this._model.updateModel({targetPosition: this.player.currentTime});
this._sendAnalytics(KavaEventModel.SEEK);
}
Expand All @@ -268,7 +265,6 @@ export default class Kava extends BasePlugin {
}

_onTimeUpdate(): void {
this._updatePlayTimeSumModel();
if (!this.player.isLive()) {
const percent = this.player.currentTime / this.player.duration;
if (!this._timePercentEvent.PLAY_REACHED_25 && percent >= 0.25) {
Expand Down Expand Up @@ -364,9 +360,8 @@ export default class Kava extends BasePlugin {
}

_updatePlayTimeSumModel(): void {
const delta = this.player.currentTime - this._previousCurrentTime;
const delta = this.config.viewEventCountdown - this._model.getBufferTime();
this._model.updateModel({playTimeSum: this._model.getPlayTimeSum() + delta});
this._previousCurrentTime = this.player.currentTime;
}

_setModelDelegates() {
Expand Down

0 comments on commit e58a9e5

Please sign in to comment.