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-9247): add userId to kava reports #45

Merged
merged 6 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion flow-typed/types/kava-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
type _KavaConfigObject = {
serviceUrl?: string,
tamperAnalyticsHandler?: Function,
viewEventCountdown?: number,
resetSessionCountdown?: number,
dvrThreshold?: number,
Expand All @@ -33,7 +34,7 @@ type _KavaConfigObject = {
customVar3?: Object,
applicationVersion?: string,
playbackContext?: string,
tamperAnalyticsHandler?: Function
userId?: string
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object {
if (model.getApplicationVersion()) {
commonModel.applicationVersion = model.getApplicationVersion();
}
if (model.getUserId()) {
commonModel.userId = model.getUserId();
}
const eventModel = eventObj.getEventModel(model);
return Object.assign(eventModel, commonModel);
}
1 change: 1 addition & 0 deletions src/kava-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class KavaModel {
getPlaybackType: Function;
getPlaybackContext: Function;
getApplicationVersion: Function;
getUserId: Function;
getCanPlayTime: Function;

constructor(model?: Object) {
Expand Down
1 change: 1 addition & 0 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ class Kava extends BasePlugin {
this._model.getPlaybackType = () => this._getPlaybackType();
this._model.getPlaybackContext = () => this.config.playbackContext;
this._model.getApplicationVersion = () => this.config.applicationVersion;
this._model.getUserId = () => this.config.userId;
}

_getPosition(): number {
Expand Down
7 changes: 5 additions & 2 deletions test/src/kava-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const ab = 3,
jt = 1213,
tp = '12',
pc = 'pc',
av = 'av';
av = 'av',
usi = '1234';

describe('KavaModel', () => {
let model;
Expand Down Expand Up @@ -79,6 +80,7 @@ describe('KavaModel', () => {
model.getPlaybackType = () => pback;
model.getPlaybackContext = () => pc;
model.getApplicationVersion = () => av;
model.getUserId = () => usi;
});

it('should update the model', function() {
Expand Down Expand Up @@ -111,7 +113,8 @@ describe('KavaModel', () => {
sessionStartTime: sst,
customVar2: cv2,
playbackContext: pc,
applicationVersion: av
applicationVersion: av,
userId: usi
});
});
});
75 changes: 41 additions & 34 deletions test/src/kava.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ describe('KavaPlugin', function() {
playlistId: '12345678',
entryType: 'Vod',
sessionId: 'c15be273-0f1b-10a3-4fc9-d7a53eebee85:b66abd37-e2e2-a22e-86ac-7859592e754b',
ks: 'Njk0ZmI4MzBiOTJiMGZhN2NmNTAwYWQyZGM2M2Y0YjkxMGRiZGI3MXwxMDkxOzEwOTE7MTUxNzkyMjgxMzswOzE1MTc4MzY0MTMuMTM4OzA7dmlldzoqLHdpZGdldDoxOzs='
ks: 'Njk0ZmI4MzBiOTJiMGZhN2NmNTAwYWQyZGM2M2Y0YjkxMGRiZGI3MXwxMDkxOzEwOTE7MTUxNzkyMjgxMzswOzE1MTc4MzY0MTMuMTM4OzA7dmlldzoqLHdpZGdldDoxOzs=',
userId: '1234'
}
},
session: {
Expand Down Expand Up @@ -148,6 +149,7 @@ describe('KavaPlugin', function() {
params.clientVer.should.equal(config.plugins.kava.playerVersion);
params.clientTag.should.equal('html5:v' + config.plugins.kava.playerVersion);
params.position.should.exist;
params.userId.should.equal(config.plugins.kava.userId);
}

it('should send IMPRESSION event', done => {
Expand Down Expand Up @@ -480,40 +482,45 @@ describe('KavaPlugin', function() {
sandbox.stub(window.navigator.connection, 'effectiveType').value('2g');

sandbox.stub(OVPAnalyticsService, 'trackEvent').callsFake((serviceUrl, params) => {
if (params.eventType === KavaEventModel.VIEW.index) {
validateCommonParams(params, KavaEventModel.VIEW.index);
params.should.have.all.keys(
'audioLanguage',
'bufferTime',
'bufferTimeSum',
'actualBitrate',
'averageBitrate',
'captionsLanguage',
'clientTag',
'clientVer',
'deliveryType',
'droppedFramesRatio',
'entryId',
'eventIndex',
'eventType',
'ks',
'partnerId',
'playTimeSum',
'playbackType',
'playlistId',
'position',
'referrer',
'sessionId',
'soundMode',
'tabMode',
'networkConnectionType'
);
params.networkConnectionType.should.equal('2g');
params.tabMode.should.equal(TabMode.TAB_FOCUSED);
params.soundMode.should.equal(SoundMode.SOUND_ON);
done();
try {
if (params.eventType === KavaEventModel.VIEW.index) {
validateCommonParams(params, KavaEventModel.VIEW.index);
params.should.have.all.keys(
'audioLanguage',
'bufferTime',
'bufferTimeSum',
'actualBitrate',
'averageBitrate',
'captionsLanguage',
'clientTag',
'clientVer',
'deliveryType',
'droppedFramesRatio',
'entryId',
'eventIndex',
'eventType',
'ks',
'partnerId',
'playTimeSum',
'playbackType',
'playlistId',
'position',
'referrer',
'sessionId',
'soundMode',
'tabMode',
'networkConnectionType',
'userId'
);
params.networkConnectionType.should.equal('2g');
params.tabMode.should.equal(TabMode.TAB_FOCUSED);
params.soundMode.should.equal(SoundMode.SOUND_ON);
done();
}
return new RequestBuilder();
} catch (err) {
done(err);
}
return new RequestBuilder();
});
setupPlayer(config);
player.play();
Expand Down