Skip to content

Commit

Permalink
fix(FEC-8029): play reached 100% event sent before ended (#30)
Browse files Browse the repository at this point in the history
sending play reached 100% event only when currentTime equals the duration
  • Loading branch information
yairans committed Apr 16, 2018
1 parent df9b884 commit bb062b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/kanalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class KAnalytics extends BasePlugin {
this._timePercentEvent.PLAY_REACHED_75 = true;
this._sendAnalytics(EventTypes.PLAY_REACHED_75);
}
if (!this._timePercentEvent.PLAY_REACHED_100 && percent >= .98) {
if (!this._timePercentEvent.PLAY_REACHED_100 && percent >= 1) {
this._timePercentEvent.PLAY_REACHED_100 = true;
this._sendAnalytics(EventTypes.PLAY_REACHED_100);
}
Expand Down
8 changes: 4 additions & 4 deletions test/src/kanalytics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe('KAnalyticsPlugin', function () {

it('should send 100%', (done) => {
player.addEventListener(player.Event.LOADED_METADATA, () => {
player.currentTime = 12.5;
player.getVideoElement().currentTime = 12.7;
});
player.addEventListener(player.Event.TIME_UPDATE, () => {
const payload = sendSpy.lastCall.args[0];
Expand All @@ -274,7 +274,7 @@ describe('KAnalyticsPlugin', function () {
};
player.addEventListener(player.Event.LOADED_METADATA, () => {
player.addEventListener(player.Event.TIME_UPDATE, onTimeUpdate);
player.currentTime = 12.5;
player.getVideoElement().currentTime = 12.7;
});
player.load();
});
Expand Down Expand Up @@ -469,10 +469,10 @@ describe('KAnalyticsPlugin', function () {
done();
};
player.addEventListener(player.Event.TIME_UPDATE, onTimeUpdate);
player.currentTime = 12.5;
player.getVideoElement().currentTime = 12.7;
});
player.load();
});
player.load();
});

player.addEventListener(player.Event.FIRST_PLAY, () => {
Expand Down

0 comments on commit bb062b9

Please sign in to comment.