Skip to content

Commit

Permalink
feat(FEC-8452): playlist (#25)
Browse files Browse the repository at this point in the history
report `playlistId` when existing
  • Loading branch information
yairans authored Oct 25, 2018
1 parent 0b03e4a commit d0363fe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object {
if (model.getUIConfId()) {
commonModel.uiConfId = model.getUIConfId();
}
if (model.getPlaylistId()) {
commonModel.playlistId = model.getPlaylistId();
}
if (model.getCustomVar1()) {
commonModel.customVar1 = model.getCustomVar1();
}
Expand Down
1 change: 1 addition & 0 deletions src/kava-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class KavaModel {
getAverageBitrate: Function;
getPartnerId: Function;
getEntryId: Function;
getPlaylistId: Function;
getSessionId: Function;
getClientVer: Function;
getClientTag: Function;
Expand Down
13 changes: 7 additions & 6 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class Kava extends BasePlugin {
this._model.getAverageBitrate = () => this._rateHandler.getAverage();
this._model.getPartnerId = () => this.config.partnerId;
this._model.getEntryId = () => this.config.entryId;
this._model.getPlaylistId = () => this.config.playlistId;
this._model.getSessionId = () => this.config.sessionId;
this._model.getClientVer = () => this.config.playerVersion;
this._model.getClientTag = () => 'html5:v' + this.config.playerVersion;
Expand Down Expand Up @@ -413,22 +414,22 @@ class Kava extends BasePlugin {

_validate(): boolean {
if (!this.config.partnerId) {
Kava._logMissingParam('partnerId');
this._logMissingParam('partnerId');
return false;
}
if (!this.config.entryId) {
Kava._logMissingParam('entryId');
this._logMissingParam('entryId');
return false;
}
return true;
}

static _getTimeDifferenceInSeconds(time): number {
return (Date.now() - time) / 1000.0;
_logMissingParam(missingParam: string): void {
this.logger.warn(`Kava analytics block report because of missing param ${missingParam}`);
}

static _logMissingParam(missingParam: string): void {
this.logger.warn(`Kava analytics block report because of missing param ${missingParam}`);
static _getTimeDifferenceInSeconds(time): number {
return (Date.now() - time) / 1000.0;
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/src/kava-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const ab = 3,
avb = 5,
pid = 'partner',
eid = 'entry',
plid = 'playlist',
sid = 'session',
referrer = 'http://referrer',
cv = 'version',
Expand Down Expand Up @@ -62,6 +63,7 @@ describe('KavaModel', () => {
model.getAverageBitrate = () => avb;
model.getPartnerId = () => pid;
model.getEntryId = () => eid;
model.getPlaylistId = () => plid;
model.getSessionId = () => sid;
model.getReferrer = () => referrer;
model.getClientVer = () => cv;
Expand Down Expand Up @@ -95,6 +97,7 @@ describe('KavaModel', () => {
eventType: eventModel.MY_EVENT.index,
partnerId: pid,
entryId: eid,
playlistId: plid,
sessionId: sid,
eventIndex: ei,
referrer: referrer,
Expand Down
2 changes: 2 additions & 0 deletions test/src/kava.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('KavaPlugin', function() {
playerName: 'kaltura-player-js',
partnerId: '1091',
entryId: '0_wifqaipd',
playlistId: '12345678',
entryType: 'Vod',
sessionId: 'c15be273-0f1b-10a3-4fc9-d7a53eebee85:b66abd37-e2e2-a22e-86ac-7859592e754b',
ks: 'Njk0ZmI4MzBiOTJiMGZhN2NmNTAwYWQyZGM2M2Y0YjkxMGRiZGI3MXwxMDkxOzEwOTE7MTUxNzkyMjgxMzswOzE1MTc4MzY0MTMuMTM4OzA7dmlldzoqLHdpZGdldDoxOzs='
Expand Down Expand Up @@ -136,6 +137,7 @@ describe('KavaPlugin', function() {
params.eventType.should.equal(eventIndex);
params.partnerId.should.equal(config.session.partnerId.toString());
params.entryId.should.equal(config.id);
params.playlistId.should.equal(config.plugins.kava.playlistId);
params.sessionId.should.equal(config.session.id);
params.eventIndex.should.equal(1);
params.ks.should.equal(config.session.ks);
Expand Down

0 comments on commit d0363fe

Please sign in to comment.