Skip to content

Commit

Permalink
feat(FEC-13771): Application events analytics reporting to kava - Phase
Browse files Browse the repository at this point in the history
#3 (#159)

feat(FEC-13771): Application events analytics reporting to kava Phase #3

---------

Co-authored-by: JonathanTGold <jonathan.gold@[email protected]>
  • Loading branch information
JonathanTGold and JonathanTGold authored Mar 18, 2024
1 parent 21ce85b commit ac2234e
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 13 deletions.
103 changes: 95 additions & 8 deletions src/application-events-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ import { KavaEvent } from './types';
import { ButtonType } from './enums/button-type';
import { ApplicationEventType } from './enums/application-event-type';
import { PageLoadType } from './enums/page-load-type';
import { PluginsEvents } from './applications-events';
import { PlaykitUIEvents, PluginsEvents } from './applications-events';

export function getApplicationEventsModel(eventObj: KavaEvent, model: KavaModel, innerEventPayload: any): any {
const commonModel = {
partnerId: model.getPartnerId(),
entryId: model.getEntryId(),
sessionId: model.getSessionId(),
kalturaApplication: model.getKalturaApplication()
kalturaApplication: model.getKalturaApplication(),
kalturaApplicationVer: model.getKalturaApplicationVersion(),
application: model.getApplication(),
applicationVer: model.getApplicationVersion(),
virtualEventId: model.getVirtualEventId()
};

if (model.getUserId()) {
commonModel['userId'] = model.getUserId();
}

const eventModel = eventObj.getEventModel(innerEventPayload);
return Object.assign(eventModel, commonModel);
}
Expand All @@ -25,7 +31,7 @@ export const ApplicationEventsModel: { [playerEventName: string]: KavaEvent } =
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Dual__screen_change_layout',
buttonType: ButtonType.Unknown,
buttonType: ButtonType.Choose,
buttonValue: payload.layout
})
},
Expand Down Expand Up @@ -356,29 +362,47 @@ export const ApplicationEventsModel: { [playerEventName: string]: KavaEvent } =
type: 'RELATED_OPEN',
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Related_open',
buttonName: 'Related_open_manual',
buttonType: ButtonType.Open,
buttonValue: payload['expandMode']
})
},
[PluginsEvents.RELATED_CLOSE]: {
type: 'RELATED_CLOSE',
getEventModel: (payload: any): any => ({
getEventModel: (): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Related_close',
buttonType: ButtonType.Close,
buttonValue: payload['expandMode']
buttonValue: ''
})
},
[PluginsEvents.RELATED_SELECTED]: {
type: 'RELATED_SELECTED',
[PluginsEvents.RELATED_ENTRY_SELECTED]: {
type: 'RELATED_ENTRY_SELECTED',
getEventModel: (): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Related_entry_click',
buttonType: ButtonType.Navigate,
buttonValue: ''
})
},
[PluginsEvents.RELATED_ENTRY_AUTO_PLAYED]: {
type: 'RELATED_ENTRY_AUTO_PLAYED',
getEventModel: (): any => ({
eventType: ApplicationEventType.PAGE_LOAD,
buttonName: 'Related_entry_auto_continue',
buttonType: PageLoadType.View,
buttonValue: ''
})
},
[PluginsEvents.RELATED_GRID_DISPLAYED]: {
type: 'RELATED_GRID_DISPLAYED',
getEventModel: (): any => ({
eventType: ApplicationEventType.PAGE_LOAD,
buttonName: 'Related_open_auto',
buttonType: PageLoadType.View,
buttonValue: ''
})
},
[PluginsEvents.CALL_TO_ACTION_BUTTON_CLICK]: {
type: 'CALL_TO_ACTION_BUTTON_CLICK',
getEventModel: (payload: any): any => ({
Expand All @@ -387,5 +411,68 @@ export const ApplicationEventsModel: { [playerEventName: string]: KavaEvent } =
buttonType: ButtonType.Link,
buttonName: payload['type'] === 'primary' ? 'CTA_primary_button_click' : 'CTA_secondary_button_click'
})
},
[PluginsEvents.HOTSPOT_DISPLAYED]: {
type: 'HOTSPOT_DISPLAYED',
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.PAGE_LOAD,
buttonName: 'Hotspot_displayed',
buttonType: PageLoadType.View,
buttonValue: payload['label']
})
},
[PluginsEvents.HOTSPOT_CLICK]: {
type: 'HOTSPOT_CLICK',
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Hotspot_click',
buttonType: ButtonType.Link,
buttonValue: payload['label']
})
},
[PluginsEvents.QUIZ_STARTED]: {
type: 'QUIZ_STARTED',
getEventModel: (): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Quiz_start',
buttonType: ButtonType.Load,
buttonValue: ''
})
},
[PluginsEvents.QUIZ_SUBMITTED]: {
type: 'QUIZ_SUBMITTED',
getEventModel: (): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Quiz_submit',
buttonType: ButtonType.Send,
buttonValue: ''
})
},
[PluginsEvents.QUIZ_SKIPPED]: {
type: 'QUIZ_SKIPPED',
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Quiz_skip_question',
buttonType: ButtonType.Navigate,
buttonValue: payload['id']
})
},
[PluginsEvents.QUIZ_SEEK]: {
type: 'QUIZ_SEEK',
getEventModel: (): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Quiz_nav_click',
buttonType: ButtonType.Navigate,
buttonValue: ''
})
},
[PlaykitUIEvents.USER_CLICKED_LOGO]: {
type: 'USER_CLICKED_LOGO',
getEventModel: (payload: any): any => ({
eventType: ApplicationEventType.BUTTON_CLICKED,
buttonName: 'Logo_click',
buttonType: ButtonType.Link,
buttonValue: payload['logoUrl']
})
}
};
29 changes: 26 additions & 3 deletions src/applications-events.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const PlaykitUIEvents = {
USER_CLICKED_LOGO: 'playkit-ui-userclickedlogo'
};

export const NavigationEvents = {
NAVIGATION_OPEN: 'navigation_open',
NAVIGATION_CLOSE: 'navigation_close',
Expand Down Expand Up @@ -44,15 +48,32 @@ export const PlaylistEvents = {
};

export const RelatedEvents = {
RELATED_SELECTED: 'related_selected',
RELATED_OPEN: 'related_open',
RELATED_CLOSE: 'related_close'
RELATED_CLOSE: 'related_close',
RELATED_ENTRY_SELECTED: 'related_entry_selected',
RELATED_ENTRY_AUTO_PLAYED: 'related_entry_auto_played',
RELATED_GRID_DISPLAYED: 'related_grid_displayed'
};

export const CallToActionEvents = {
CALL_TO_ACTION_BUTTON_CLICK: 'call_to_action_button_click'
};

export const HotspotsEvents = {
HOTSPOT_CLICK: 'hotspot_click',
HOTSPOT_DISPLAYED: 'hotspot_displayed'
};

export const IvqEventTypes = {
QUIZ_STARTED: 'QuizStarted',
QUIZ_SKIPPED: 'QuizSkipped',
QUIZ_SEEK: 'QuizSeek',
QUESTION_ANSWERED: 'QuestionAnswered',
QUIZ_SUBMITTED: 'QuizSubmitted',
QUIZ_RETAKE: 'QuizRetake',
QUIZ_QUESTION_CHANGED: 'QuizQuestionChanged'
};

export const PluginsEvents = {
...NavigationEvents,
...DownloadEvents,
Expand All @@ -63,5 +84,7 @@ export const PluginsEvents = {
...SkipEvents,
...PlaylistEvents,
...RelatedEvents,
...CallToActionEvents
...CallToActionEvents,
...HotspotsEvents,
...IvqEventTypes
};
3 changes: 1 addition & 2 deletions src/enums/button-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ export enum ButtonType {
Toggle = 26,
Thumbnail = 27,
Download = 28,
Share = 29,
Unknown = 'Unknown'
Share = 29
}

0 comments on commit ac2234e

Please sign in to comment.