Skip to content

Commit

Permalink
feat(FEC-13362): add new events (#154)
Browse files Browse the repository at this point in the history
### Description of the Changes

**add new events:**
- enter fullscreen
- exit fullscreen
- info clicked (info)
- download clicked (downloads)
- report clicked (moderation)
- report submitted (moderation)

**dependent on PRs:**
kaltura/playkit-js-info#86
kaltura/playkit-js-downloads#35
kaltura/playkit-js-moderation#67

Solves FEC-13362
  • Loading branch information
lianbenjamin authored Dec 11, 2023
1 parent 14935bc commit 6677f44
Show file tree
Hide file tree
Showing 6 changed files with 3,684 additions and 2,580 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
"@babel/preset-env": "^7.10.4",
"@babel/preset-flow": "^7.10.4",
"@babel/register": "^7.10.5",
"@playkit-js/info": "3.4.0-canary.0-c282105",
"@playkit-js/kaltura-player-js": "latest",
"@playkit-js/moderation": "3.2.13-canary.0-5376147",
"@playkit-js/playkit-js": "latest",
"@playkit-js/playkit-js-downloads": "1.1.0-canary.0-6acbd10",
"@playkit-js/playkit-js-providers": "2.39.4-canary.0-ab0b9a0",
"@playkit-js/related": "latest",
"@playkit-js/share": "https://github.com/kaltura/playkit-js-share.git#726fd2d383ee04c2889ec76ff390581998b339bb",
Expand Down
36 changes: 36 additions & 0 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,42 @@ export const KavaEventModel: {[event: string]: KavaEvent} = {
getEventModel: (model: KavaModel) => ({
socialNetwork: model.getShareNetworkName()
})
},
ENTER_FULLSCREEN: {
type: 'ENTER_FULLSCREEN',
index: 31,
getEventModel: (model: KavaModel) => ({
screenMode: model.getScreenMode()
})
},
EXIT_FULLSCREEN: {
type: 'EXIT_FULLSCREEN',
index: 32,
getEventModel: (model: KavaModel) => ({
screenMode: model.getScreenMode()
})
},
DOWNLOAD: {
type: 'DOWNLOAD',
index: 23,
getEventModel: () => ({})
},
REPORT_CLICKED: {
type: 'REPORT_CLICKED',
index: 24,
getEventModel: () => ({})
},
REPORT_SUBMITTED: {
type: 'REPORT_SUBMITTED',
index: 25,
getEventModel: (model: KavaModel) => ({
reportType: model.getReportType()
})
},
INFO: {
type: 'INFO',
index: 40,
getEventModel: () => ({})
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/kava-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class KavaModel {
networkConnectionType: string;
playerJSLoadTime: ?number = null;
shareNetworkName: string = '';
reportType: number = NaN;
getActualBitrate: Function;
getPlaybackSpeed: Function;
getAverageBitrate: Function;
Expand Down Expand Up @@ -357,6 +358,10 @@ class KavaModel {
return this.shareNetworkName;
}

getReportType(): number {
return this.reportType;
}

/**
* Updates the model.
* @param {Object} obj - A partial or full updated model.
Expand Down
38 changes: 34 additions & 4 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {KalturaApplication} from './kaltura-application';
//$FlowFixMe
import {RelatedEvent} from '@playkit-js/related';
import {ShareEvent} from '@playkit-js/share';
import {DownloadEvent} from '@playkit-js/playkit-js-downloads';
import {ModerationEvent} from '@playkit-js/moderation';
import {InfoEvent} from '@playkit-js/info';

const {Error: PKError, FakeEvent, Utils} = core;
const DIVIDER: number = 1024;
Expand Down Expand Up @@ -320,14 +323,16 @@ class Kava extends BasePlugin {
this.eventManager.listen(this.player, this.player.Event.VOLUME_CHANGE, () => this._updateSoundModeInModel());
this.eventManager.listen(this.player, this.player.Event.VISIBILITY_CHANGE, e => this._updateViewabilityModeInModel(e.payload.visible));
this.eventManager.listen(this.player, this.player.Event.MUTE_CHANGE, () => this._updateSoundModeInModel());
this.eventManager.listen(this.player, this.player.Event.ENTER_FULLSCREEN, () => this._model.updateModel({screenMode: ScreenMode.FULLSCREEN}));
this.eventManager.listen(this.player, this.player.Event.EXIT_FULLSCREEN, () =>
this._model.updateModel({screenMode: ScreenMode.NOT_IN_FULLSCREEN})
);
this.eventManager.listen(this.player, this.player.Event.ENTER_FULLSCREEN, () => this._onFullScreenChanged(ScreenMode.FULLSCREEN));
this.eventManager.listen(this.player, this.player.Event.EXIT_FULLSCREEN, () => this._onFullScreenChanged(ScreenMode.NOT_IN_FULLSCREEN));
this.eventManager.listen(this.player, RelatedEvent.RELATED_CLICKED, () => this._onRelatedClicked());
this.eventManager.listen(this.player, RelatedEvent.RELATED_SELECTED, () => this._onRelatedSelected());
this.eventManager.listen(this.player, ShareEvent.SHARE_CLICKED, () => this._onShareClicked());
this.eventManager.listen(this.player, ShareEvent.SHARE_NETWORK, event => this._onShareNetworkClicked(event));
this.eventManager.listen(this.player, DownloadEvent.DOWNLOAD_ITEM_CLICKED, () => this._onDownloadItemClicked());
this.eventManager.listen(this.player, InfoEvent.INFO_SCREEN_OPEN, () => this._onInfoScreenOpened());
this.eventManager.listen(this.player, ModerationEvent.REPORT_CLICKED, () => this._onReportClicked());
this.eventManager.listen(this.player, ModerationEvent.REPORT_SUBMITTED, event => this._onReportSubmitted(event));

this._initTabMode();
this._initNetworkConnectionType();
Expand Down Expand Up @@ -719,6 +724,31 @@ class Kava extends BasePlugin {
}
}

_onReportSubmitted(event: FakeEvent): void {
const reportType = event.payload.reportType;
if (reportType) {
this._model.updateModel({reportType});
this._sendAnalytics(KavaEventModel.REPORT_SUBMITTED);
}
}

_onReportClicked(): void {
this._sendAnalytics(KavaEventModel.REPORT_CLICKED);
}

_onInfoScreenOpened(): void {
this._sendAnalytics(KavaEventModel.INFO);
}

_onDownloadItemClicked(): void {
this._sendAnalytics(KavaEventModel.DOWNLOAD);
}

_onFullScreenChanged(screenMode: number): void {
this._model.updateModel({screenMode: screenMode});
this._sendAnalytics(screenMode === ScreenMode.FULLSCREEN ? KavaEventModel.ENTER_FULLSCREEN : KavaEventModel.EXIT_FULLSCREEN);
}

_updateSessionStartTimeModel(response: Object | number): void {
if (!this._model.getSessionStartTime() && response) {
if (typeof response === 'object') {
Expand Down
5 changes: 4 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ module.exports = {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
alias: {
'@playkit-js/related': path.resolve(`node_modules/@playkit-js/related/types`),
'@playkit-js/share': path.resolve(`node_modules/@playkit-js/share/types`)
'@playkit-js/share': path.resolve(`node_modules/@playkit-js/share/types`),
'@playkit-js/playkit-js-downloads': path.resolve(`node_modules/@playkit-js/playkit-js-downloads/types`),
'@playkit-js/info': path.resolve(`node_modules/@playkit-js/info/types`),
'@playkit-js/moderation': path.resolve(`node_modules/@playkit-js/moderation/types`)
},
extensions: ['.js']
},
Expand Down
Loading

0 comments on commit 6677f44

Please sign in to comment.