Skip to content

Commit

Permalink
feat(FEC-12923): Add missing applications data on kava beacons & conf…
Browse files Browse the repository at this point in the history
…ig (#134)

* feat(FEC-12923): Add missing applications data on kava  beacons & config

  application?: string,
  kalturaApplicationVersion?: string,
  kalturaApplication?: string,

add mapping for kalturaApplication param

const KalturaApplication: ApplicationType = {
  KMC: '0',
  KMS: '1',
  KAF: '2',
  PITCH: '3',
  KMS_GO: '4',
  WEBCASTING: '5',
  PERSONAL_CAPTURE: '6',
  KME: '7',
  KME_MOBILE_APP: '8',
  PATH: '9',
  LECTURE_CAPTURE: '10',
  EP: '11',
  CHAT_AND_COLLABORATION: '12',
  ANALYTICS: '13',
  EXPRESS_CAPTURE: '14',
  KPF: '15',
  KAF_GO: '16',
  SITES: '17',
  STUDIO: '18'
};
  • Loading branch information
giladna authored Feb 5, 2023
1 parent 158e715 commit 1c76ade
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
10 changes: 10 additions & 0 deletions flow-typed/types/kava-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @property {number} [resetSessionCountdown] - The interval in seconds that Kava session will be reset.
* @property {number} [dvrThreshold] - Threshold in seconds from the live edge.
* @property {string} [applicationVersion] - Used to send the application version from which the user is playing the entry.
* @property {string} [application] - Used to send the application from which the user is playing the entry.
* @property {string} [kalturaApplicationVersion] - KalturaApplication Used to send the kaltura application name KalturaApplication:(KMC,KMS,KAF,PITCH,KMS_GO,WEBCASTING,PERSONAL_CAPTURE,KME,KME_MOBILE_APP,PATH,LECTURE_CAPTURE,EP,CHAT_AND_COLLABORATION,ANALYTICS,EXPRESS_CAPTURE,KPF,KAF_GO,SITES,STUDIO
) from which the user is playing the entry.
* @property {string} [kalturaApplication] - Used to send the kaltura application version from which the user is playing the entry.
* @property {string} [playbackContext] - Used to send the id of the category from which the user is playing the entry.
* @property {Function} [tamperAnalyticsHandler] - An optional handler to implement. Can be used to manipulate the model data before analytics event sent, or to cancel a certain analytics request.
* @property {Object} [customVar1] - Custom objects field.
Expand All @@ -21,6 +25,9 @@
* resetSessionCountdown: 30,
* dvrThreshold: 120,
* applicationVersion: '',
* application: '',
* kalturaApplicationVersion: '',
* kalturaApplication: ''
* playbackContext: ''
* }
*/
Expand All @@ -34,6 +41,9 @@ type _KavaConfigObject = {
customVar2?: Object,
customVar3?: Object,
applicationVersion?: string,
application?: string,
kalturaApplicationVersion?: string,
kalturaApplication?: string,
playbackContext?: string,
userId?: string
};
Expand Down
28 changes: 28 additions & 0 deletions src/kaltura-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//@flow

type ApplicationType = {[app: string]: string};

const KalturaApplication: ApplicationType = {
KMC: '0',
KMS: '1',
KAF: '2',
PITCH: '3',
KMS_GO: '4',
WEBCASTING: '5',
PERSONAL_CAPTURE: '6',
KME: '7',
KME_MOBILE_APP: '8',
PATH: '9',
LECTURE_CAPTURE: '10',
EP: '11',
CHAT_AND_COLLABORATION: '12',
ANALYTICS: '13',
EXPRESS_CAPTURE: '14',
KPF: '15',
KAF_GO: '16',
SITES: '17',
STUDIO: '18'
};

export {KalturaApplication};
export type {ApplicationType};
9 changes: 9 additions & 0 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object {
if (model.getApplicationVersion()) {
commonModel.applicationVer = model.getApplicationVersion();
}
if (model.getApplication()) {
commonModel.application = model.getApplication();
}
if (model.getKalturaApplicationVersion()) {
commonModel.kalturaApplicationVer = model.getKalturaApplicationVersion();
}
if (model.getKalturaApplication()) {
commonModel.kalturaApplication = model.getKalturaApplication();
}
if (model.getUserId()) {
commonModel.userId = model.getUserId();
}
Expand Down
3 changes: 3 additions & 0 deletions src/kava-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class KavaModel {
getPlaybackType: Function;
getPlaybackContext: Function;
getApplicationVersion: Function;
getApplication: Function;
getKalturaApplicationVersion: Function;
getKalturaApplication: Function;
getUserId: Function;
getCanPlayTime: Function;
getPersistentSessionId: Function;
Expand Down
18 changes: 17 additions & 1 deletion src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {KavaRateHandler} from './kava-rate-handler';
import {KavaTimer} from './kava-timer';
import {ErrorPosition, KavaModel, SoundMode, TabMode, ScreenMode, ViewabilityMode} from './kava-model';
import {HttpMethodType} from './http-method-type';
import {KalturaApplication} from './kaltura-application';
//$FlowFixMe
import {RelatedEvent} from '@playkit-js/related';

Expand Down Expand Up @@ -57,7 +58,10 @@ class Kava extends BasePlugin {
resetSessionCountdown: 30,
dvrThreshold: 120,
playbackContext: '',
applicationVersion: ''
applicationVersion: '',
application: '',
kalturaApplicationVersion: '',
kalturaApplication: ''
};

/**
Expand Down Expand Up @@ -753,9 +757,21 @@ class Kava extends BasePlugin {
this._model.getPlaybackType = () => this._getPlaybackType();
this._model.getPlaybackContext = () => this.config.playbackContext;
this._model.getApplicationVersion = () => this.config.applicationVersion;
this._model.getApplication = () => this.config.application;
this._model.getKalturaApplicationVersion = () => this.config.kalturaApplicationVersion;
this._model.getKalturaApplication = () => this._getKalturaApplicationId(this.config.kalturaApplication);
this._model.getUserId = () => this.config.userId;
}

_getKalturaApplicationId(kalturaAppName: string): string {
if (kalturaAppName in KalturaApplication) {
return KalturaApplication[kalturaAppName];
} else {
this.logger.warn(`Kava analytics - unknon kalturaAppName: ` + kalturaAppName);
return '';
}
}

_getPosition(): number {
if (this.player.isLive()) {
if (!Number.isNaN(this.player.duration)) {
Expand Down
9 changes: 9 additions & 0 deletions test/src/kava-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const ab = 3,
tp = '12',
pc = 'pc',
av = 'av',
app = 'app',
kav = 'kav',
ka = 'ka',
usi = '1234',
pbs = 1,
psi = '1234-1234';
Expand Down Expand Up @@ -85,6 +88,9 @@ describe('KavaModel', () => {
model.getPlaybackType = () => pback;
model.getPlaybackContext = () => pc;
model.getApplicationVersion = () => av;
model.getApplication = () => app;
model.getKalturaApplicationVersion = () => kav;
model.getKalturaApplication = () => ka;
model.getUserId = () => usi;
model.getPlaybackSpeed = () => pbs;
model.getPersistentSessionId = () => psi;
Expand Down Expand Up @@ -122,6 +128,9 @@ describe('KavaModel', () => {
customVar2: cv2,
playbackContext: pc,
applicationVer: av,
application: app,
kalturaApplicationVer: kav,
kalturaApplication: ka,
userId: usi,
playbackSpeed: pbs,
caption: cap,
Expand Down

0 comments on commit 1c76ade

Please sign in to comment.