Skip to content

Commit

Permalink
support VIDEO feature flag in PubMatic bid adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcrute committed Apr 3, 2023
1 parent c16c389 commit fa9c33a
Show file tree
Hide file tree
Showing 2 changed files with 881 additions and 865 deletions.
23 changes: 13 additions & 10 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function _createNativeRequest(params) {
}
};
break;
case NATIVE_ASSETS.VIDEO.KEY:
case FEATURES.VIDEO && NATIVE_ASSETS.VIDEO.KEY:
assetObj = {
id: NATIVE_ASSETS.VIDEO.ID,
required: params[key].required ? 1 : 0,
Expand Down Expand Up @@ -529,7 +529,7 @@ function _createBannerRequest(bid) {

export function checkVideoPlacement(videoData, adUnitCode) {
// Check for video.placement property. If property is missing display log message.
if (!deepAccess(videoData, 'placement')) {
if (FEATURES.VIDEO && !deepAccess(videoData, 'placement')) {
logWarn(MSG_VIDEO_PLACEMENT_MISSING + ' for ' + adUnitCode);
};
}
Expand All @@ -538,7 +538,7 @@ function _createVideoRequest(bid) {
var videoData = mergeDeep(deepAccess(bid.mediaTypes, 'video'), bid.params.video);
var videoObj;

if (videoData !== UNDEFINED) {
if (FEATURES.VIDEO && videoData !== UNDEFINED) {
videoObj = {};
checkVideoPlacement(videoData, bid.adUnitCode);
for (var key in VIDEO_CUSTOM_PARAMS) {
Expand Down Expand Up @@ -664,7 +664,7 @@ function _createImpressionObject(bid, conf) {
logWarn(LOG_WARN_PREFIX + 'Error: Error in Native adunit ' + bid.params.adUnit + '. Ignoring the adunit. Refer to ' + PREBID_NATIVE_HELP_LINK + ' for more details.');
}
break;
case VIDEO:
case FEATURES.VIDEO && VIDEO:
videoObj = _createVideoRequest(bid);
if (videoObj !== UNDEFINED) {
impObj.video = videoObj;
Expand Down Expand Up @@ -700,7 +700,7 @@ function _createImpressionObject(bid, conf) {

return impObj.hasOwnProperty(BANNER) ||
impObj.hasOwnProperty(NATIVE) ||
impObj.hasOwnProperty(VIDEO) ? impObj : UNDEFINED;
(FEATURES.VIDEO && impObj.hasOwnProperty(VIDEO)) ? impObj : UNDEFINED;
}

function _addImpressionFPD(imp, bid) {
Expand Down Expand Up @@ -801,7 +801,7 @@ function _checkMediaType(bid, newBid) {
var videoRegex = new RegExp(/VAST\s+version/);
if (adm.indexOf('span class="PubAPIAd"') >= 0) {
newBid.mediaType = BANNER;
} else if (videoRegex.test(adm)) {
} else if (FEATURES.VIDEO && videoRegex.test(adm)) {
newBid.mediaType = VIDEO;
} else {
try {
Expand Down Expand Up @@ -926,7 +926,10 @@ function _assignRenderer(newBid, request) {
for (let bidderRequestBidsIndex = 0; bidderRequestBidsIndex < request.bidderRequest.bids.length; bidderRequestBidsIndex++) {
if (request.bidderRequest.bids[bidderRequestBidsIndex].bidId === newBid.requestId) {
bidParams = request.bidderRequest.bids[bidderRequestBidsIndex].params;
context = request.bidderRequest.bids[bidderRequestBidsIndex].mediaTypes[VIDEO].context;

if (FEATURES.VIDEO) {
context = request.bidderRequest.bids[bidderRequestBidsIndex].mediaTypes[VIDEO].context;
}
adUnitCode = request.bidderRequest.bids[bidderRequestBidsIndex].adUnitCode;
}
}
Expand All @@ -946,7 +949,7 @@ function _assignRenderer(newBid, request) {
* @returns
*/
export function assignDealTier(newBid, bid, request) {
if (!bid?.ext?.prebiddealpriority) return;
if (!bid?.ext?.prebiddealpriority || !FEATURES.VIDEO) return;
const bidRequest = getBidRequest(newBid.requestId, [request.bidderRequest]);
const videoObj = deepAccess(bidRequest, 'mediaTypes.video');
if (videoObj?.context != ADPOD) return;
Expand Down Expand Up @@ -1029,7 +1032,7 @@ export const spec = {
return false;
}
// video ad validation
if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
if (FEATURES.VIDEO && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) {
// bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array
let mediaTypesVideoMimes = deepAccess(bid.mediaTypes, 'video.mimes');
let paramsVideoMimes = deepAccess(bid, 'params.video.mimes');
Expand Down Expand Up @@ -1314,7 +1317,7 @@ export const spec = {
switch (newBid.mediaType) {
case BANNER:
break;
case VIDEO:
case FEATURES.VIDEO && VIDEO:
newBid.width = bid.hasOwnProperty('w') ? bid.w : req.video.w;
newBid.height = bid.hasOwnProperty('h') ? bid.h : req.video.h;
newBid.vastXml = bid.adm;
Expand Down
Loading

0 comments on commit fa9c33a

Please sign in to comment.