@playkit-js/playkit-js-kava 1.16.1 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/playkit-js-kava",
3
- "version": "1.16.1",
3
+ "version": "1.17.0",
4
4
  "main": "dist/playkit-kava.js",
5
5
  "scripts": {
6
6
  "disabled-preinstall": "npx --yes --prefer-online --registry=https://npm.pkg.github.com --package @kaltura/kaltura-tools@latest kaltura-tools check --root=.",
@@ -51,6 +51,11 @@ export function getApplicationEventsModel(eventObj: KavaEvent, model: KavaModel,
51
51
  namedEventModel['pageType'] = eventVar2;
52
52
  namedEventModel['pageValue'] = eventVar3;
53
53
  namedEventModel['pageInfo'] = eventVar4;
54
+ } else if (eventModel.eventType === ApplicationEventType.CONTENT_MILESTONE) {
55
+ namedEventModel['eventName'] = eventVar1;
56
+ if (typeof eventVar2 !== 'undefined') {
57
+ namedEventModel['completionThreshold'] = eventVar2;
58
+ }
54
59
  }
55
60
 
56
61
  return Object.assign(namedEventModel, commonModel);
@@ -1265,5 +1270,22 @@ export const ApplicationEventsModel: { [playerEventName: string]: KavaEvent } =
1265
1270
  eventVar4: '',
1266
1271
  applicationFeature: ApplicationFeature.GENIE
1267
1272
  })
1273
+ },
1274
+ [PluginsEvents.VOD_COMPLETION_VIDEO_STARTED]: {
1275
+ type: 'VOD_COMPLETION_VIDEO_STARTED',
1276
+ getEventModel: (): any => ({
1277
+ eventType: ApplicationEventType.CONTENT_MILESTONE,
1278
+ eventVar1: 'video_started',
1279
+ applicationFeature: ApplicationFeature.VOD_COMPLETION
1280
+ })
1281
+ },
1282
+ [PluginsEvents.VOD_COMPLETION_VIDEO_COMPLETED]: {
1283
+ type: 'VOD_COMPLETION_VIDEO_COMPLETED',
1284
+ getEventModel: ({ completionThreshold }: any): any => ({
1285
+ eventType: ApplicationEventType.CONTENT_MILESTONE,
1286
+ eventVar1: 'video_completed',
1287
+ eventVar2: completionThreshold,
1288
+ applicationFeature: ApplicationFeature.VOD_COMPLETION
1289
+ })
1268
1290
  }
1269
1291
  };
@@ -174,6 +174,11 @@ export const GenieEvents = {
174
174
  GENIE_NEW_THREAD: 'genie_new_thread'
175
175
  };
176
176
 
177
+ export const VodCompletionEvents = {
178
+ VOD_COMPLETION_VIDEO_STARTED: 'vod_completion_video_started',
179
+ VOD_COMPLETION_VIDEO_COMPLETED: 'vod_completion_video_completed'
180
+ };
181
+
177
182
  export const PluginsEvents = {
178
183
  ...NavigationEvents,
179
184
  ...DownloadEvents,
@@ -194,5 +199,6 @@ export const PluginsEvents = {
194
199
  ...AudioPlayerEvents,
195
200
  ...CpeTrackerEvents,
196
201
  ...BannerOverlayEvents,
197
- ...GenieEvents
202
+ ...GenieEvents,
203
+ ...VodCompletionEvents
198
204
  };
@@ -1,4 +1,5 @@
1
1
  export const ApplicationEventType = {
2
2
  BUTTON_CLICKED: 10002,
3
- PAGE_LOAD: 10003
3
+ PAGE_LOAD: 10003,
4
+ CONTENT_MILESTONE: 10004
4
5
  };
@@ -23,5 +23,6 @@ export enum ApplicationFeature {
23
23
  AUDIO_PLAYER = 'audio_player',
24
24
  CPE_TRACKER = 'cpe_tracker',
25
25
  BANNER_OVERLAY = 'banner_overlay',
26
- GENIE = 'genie'
26
+ GENIE = 'genie',
27
+ VOD_COMPLETION = 'vod_completion'
27
28
  }
package/src/kava.ts CHANGED
@@ -982,7 +982,7 @@ class Kava extends BasePlugin {
982
982
 
983
983
  private _isApplicationEventValid(event: FakeEvent): boolean {
984
984
  const model = getApplicationEventsModel(ApplicationEventsModel[event.type], this._model, event.payload);
985
- return !!model.buttonName || !!model.pageName;
985
+ return !!model.buttonName || !!model.pageName || !!model.eventName;
986
986
  }
987
987
 
988
988
  private _logMissingParam(missingParam: string): void {
@@ -75,6 +75,29 @@ describe('ApplicationEventsModel', () => {
75
75
  });
76
76
  });
77
77
  });
78
+ describe('Content Milestone parameters', () => {
79
+ it('Should return the correct Content Milestone params with completionThreshold', () => {
80
+ eventModel = { eventType: ApplicationEventType.CONTENT_MILESTONE, eventVar1: 'var1', eventVar2: 'var2' };
81
+
82
+ getApplicationEventsModel(eventObj, model).should.deep.equal({
83
+ ...commonModel,
84
+ eventType: ApplicationEventType.CONTENT_MILESTONE,
85
+ eventName: 'var1',
86
+ completionThreshold: 'var2'
87
+ });
88
+ });
89
+ it('Should return the correct Content Milestone params without completionThreshold', () => {
90
+ eventModel = { eventType: ApplicationEventType.CONTENT_MILESTONE, eventVar1: 'var1' };
91
+
92
+ const result = getApplicationEventsModel(eventObj, model);
93
+ result.should.deep.equal({
94
+ ...commonModel,
95
+ eventType: ApplicationEventType.CONTENT_MILESTONE,
96
+ eventName: 'var1'
97
+ });
98
+ result.should.not.have.property('completionThreshold');
99
+ });
100
+ });
78
101
  describe('Optional parameters', () => {
79
102
  it('Should return the correct event type value', () => {
80
103
  customModel = { application: 'abc' };