Skip to content

Commit

Permalink
feat(FEC-11789): Update to the latest IMA SDK OMID API (#215)
Browse files Browse the repository at this point in the history
Update to the latest IMA SDK OMID API

solves: FEC-11789
  • Loading branch information
JonathanTGold authored Jan 16, 2022
1 parent bf2ecc4 commit ccd1331
Show file tree
Hide file tree
Showing 8 changed files with 3,490 additions and 2,988 deletions.
376 changes: 206 additions & 170 deletions docs/api.md

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions flow-typed/types/ima-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
* @param {boolean} [showAdBreakCuePoint] - Whether to show the ad breaks cue points.
* @param {Object} [adBreakCuePointStyle] - Style options for the ad breaks cue points - See the options {@link https://github.com/kaltura/playkit-js-timeline/blob/main/docs/types.md#cuepointoptionsobject|Here}.
* @param {string} [sessionId] - a temporary random ID. It is used exclusively for frequency capping. A session ID must be a UUID.
* @param {boolean} [enableOmidBeta] - enable the Open Measurement (OM) SDK, (optional, default `false`).
* @param {OmSdkAccessModesConfig} [omSdkAccessModes] - The OM SDK verification scripts access modes.
* @param {OmidAccessModesConfig} [omidAccessModes] - A dictionary that maps each {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima#.OmidVerificationVendor OmidVerificationVendor} to one of the {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/omsdk#access_modes access modes}
* @example
*/
Expand All @@ -55,8 +54,7 @@ type _ImaConfigObject = {
showAdBreakCuePoint: boolean,
adBreakCuePointStyle: Object,
sessionId: string,
enableOmidBeta: boolean,
omSdkAccessModes: OmSdkAccessModesConfig
omidAccessModes: OmidAccessModesConfig
};

declare type ImaConfigObject = _ImaConfigObject;
8 changes: 0 additions & 8 deletions flow-typed/types/omSdkAccessModesConfig.js

This file was deleted.

22 changes: 22 additions & 0 deletions flow-typed/types/omid-access-modes-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @flow

/**
* {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/omsdk#access_modes different access modes for verification scripts}
* @typedef AccessMode
* @type { 'FULL' | 'CREATIVE' | 'DOMAIN' | 'LIMITED'}
*/
declare type AccessMode = 'FULL' | 'CREATIVE' | 'DOMAIN' | 'LIMITED';

/**
* A dictionary that maps each {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima#.OmidVerificationVendor OmidVerificationVendor} to one of the {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/omsdk#access_modes available access modes}
* @typedef OmidAccessModesConfig
* @example
* {
* MOAT: 'FULL'
* PIXELATE: 'CREATIVE'
* OTHER: 'DOMAIN'
* }
*/
declare type OmidAccessModesConfig = {
[string]: AccessMode
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
"peerDependencies": {
"@playkit-js/playkit-js": "0.63.0",
"kaltura-player-js": "https://github.com/kaltura/kaltura-player-js.git#v1.0.0"
"kaltura-player-js": "https://github.com/kaltura/kaltura-player-js.git#master"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 5 additions & 8 deletions src/ima.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Ima extends BasePlugin implements IMiddlewareProvider, IAdsControllerProvi
return true;
}

constructor(name: string, player: KalturaPlayer, config: Object) {
constructor(name: string, player: KalturaPlayer, config: ImaConfigObject) {
super(name, player, config);
this._stateMachine = new ImaStateMachine(this);
this._initMembers();
Expand Down Expand Up @@ -799,9 +799,6 @@ class Ima extends BasePlugin implements IMiddlewareProvider, IAdsControllerProvi
if (typeof this.config.sessionId === 'string') {
this._sdk.settings.setSessionId(this.config.sessionId);
}
if (typeof this.config.enableOmidBeta === 'boolean') {
this._sdk.settings.setFeatureFlags({enableOmidBeta: this.config.enableOmidBeta});
}
}

/**
Expand Down Expand Up @@ -886,10 +883,10 @@ class Ima extends BasePlugin implements IMiddlewareProvider, IAdsControllerProvi
if (typeof this.config.vastLoadTimeout === 'number') {
adsRequest.vastLoadTimeout = this.config.vastLoadTimeout;
}
if (typeof this.config.omSdkAccessModes === 'object') {
Object.keys(this.config.omSdkAccessModes).forEach(accessMode => {
adsRequest.omidAccessModeRules[accessMode] = this.config.omSdkAccessModes[accessMode];
});
if (typeof this.config.omidAccessModes === 'object') {
for (const [vendor: OmidVendor, accessMode: AccessMode] of Object.entries(this.config.omidAccessModes)) {
adsRequest.omidAccessModeRules[this._sdk.OmidVerificationVendor[vendor]] = this._sdk.OmidAccessMode[accessMode];
}
}
adsRequest.linearAdSlotWidth = this.player.dimensions.width;
adsRequest.linearAdSlotHeight = this.player.dimensions.height;
Expand Down
3 changes: 1 addition & 2 deletions test/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ function loadPlayerWithAds(targetId, imaConfig, playbackConfig) {
progressive: [
{
mimetype: 'video/mp4',
url:
'https://cfvod.kaltura.com/pd/p/1726172/sp/172617200/serveFlavor/entryId/1_po3v31zx/v/1/ev/7/flavorId/1_67zt1djx/fileName/BBB_(Basic_Small_-_WEB_MBL_(H264_400)).mp4/name/a.mp4'
url: 'https://cfvod.kaltura.com/pd/p/1726172/sp/172617200/serveFlavor/entryId/1_po3v31zx/v/1/ev/7/flavorId/1_67zt1djx/fileName/BBB_(Basic_Small_-_WEB_MBL_(H264_400)).mp4/name/a.mp4'
}
]
},
Expand Down
Loading

0 comments on commit ccd1331

Please sign in to comment.