Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-8309): playTimeSum value in View event is incorrect (not accumulative) #11

Merged
merged 2 commits into from
Jun 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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