Skip to content

Commit

Permalink
fix(FEC-7207): fix buffering stats (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
yairans committed Sep 27, 2017
1 parent 606b21f commit ab934f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/kanalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ export default class KAnalytics extends BasePlugin {
* @return {void}
*/
_onPlayerStateChanged(event: any): void {
if (event.payload.newState === this.player.State.BUFFERING) {
if (event.payload.newState.type === this.player.State.BUFFERING) {
this._sendAnalytics(EventTypes.BUFFER_START);
}
if (event.payload.oldState === this.player.State.BUFFERING) {
if (event.payload.oldState.type === this.player.State.BUFFERING) {
this._sendAnalytics(EventTypes.BUFFER_END);
}
}
Expand Down
14 changes: 12 additions & 2 deletions test/src/kanalytics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ describe('KAnalyticsPlugin', function () {

it('should send buffer start', () => {
player.dispatchEvent({type: player.Event.PLAYER_STATE_CHANGED, payload:{
'newState': player.State.BUFFERING
'newState': {
'type': player.State.BUFFERING
},
'oldState': {
'type': player.State.PLAYING
}
}});
let payload = sendSpy.lastCall.args[0];
verifyPayloadProperties(payload.ks, payload.event);
Expand All @@ -154,7 +159,12 @@ describe('KAnalyticsPlugin', function () {

it('should send buffer end', () => {
player.dispatchEvent({type: player.Event.PLAYER_STATE_CHANGED, payload:{
'oldState': player.State.BUFFERING
'newState': {
'type': player.State.PLAYING
},
'oldState': {
'type': player.State.BUFFERING
}
}});
let payload = sendSpy.lastCall.args[0];
verifyPayloadProperties(payload.ks, payload.event);
Expand Down

0 comments on commit ab934f5

Please sign in to comment.