Skip to content

Commit

Permalink
fix(FEC-7598): widget loaded not sent when preload='none' (#29)
Browse files Browse the repository at this point in the history
do not wait for ready for sending WIDGET_LOADED, wait to sourceselected only
  • Loading branch information
yairans authored Feb 28, 2018
1 parent a0addec commit 5caa2f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/kanalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ export default class KAnalytics extends BasePlugin {
* @return {void}
*/
_onSourceSelected(): void {
if (!this._widgetLoadedEventSent) {
this._sendAnalytics(EventTypes.WIDGET_LOADED);
this._widgetLoadedEventSent = true
}
this.player.ready().then(() => {
if (!this._widgetLoadedEventSent) {
this._sendAnalytics(EventTypes.WIDGET_LOADED);
this._widgetLoadedEventSent = true
}
this._sendAnalytics(EventTypes.MEDIA_LOADED);
});
}
Expand Down
22 changes: 9 additions & 13 deletions test/src/kanalytics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,11 @@ describe('KAnalyticsPlugin', function () {
player = loadPlayer(config);
});

it('should send widget loaded', (done) => {
player.ready().then(() => {
const payload = sendSpy.firstCall.args[0];
verifyPayloadProperties(payload.ks, payload.event);
payload.event.seek.should.be.false;
payload.event.eventType.should.equal(1);
done();
});
player.load();
it('should send widget loaded before load', () => {
const payload = sendSpy.firstCall.args[0];
verifyPayloadProperties(payload.ks, payload.event);
payload.event.seek.should.be.false;
payload.event.eventType.should.equal(1);
});

it('should send media loaded', (done) => {
Expand Down Expand Up @@ -266,10 +262,10 @@ describe('KAnalyticsPlugin', function () {
it('should send 25% - 100%', (done) => {
const onTimeUpdate = () => {
player.removeEventListener(player.Event.TIME_UPDATE, onTimeUpdate);
const payload25 = sendSpy.getCall(0).args[0];
const payload50 = sendSpy.getCall(1).args[0];
const payload75 = sendSpy.getCall(2).args[0];
const payload100 = sendSpy.getCall(3).args[0];
const payload25 = sendSpy.getCall(1).args[0];
const payload50 = sendSpy.getCall(2).args[0];
const payload75 = sendSpy.getCall(3).args[0];
const payload100 = sendSpy.getCall(4).args[0];
payload25.event.eventType.should.equal(4);
payload50.event.eventType.should.equal(5);
payload75.event.eventType.should.equal(6);
Expand Down

0 comments on commit 5caa2f9

Please sign in to comment.