Skip to content

Commit

Permalink
support VIDEO feature flag in PubMatic bid adapter (prebid#9744)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcrute authored and jorgeluisrocha committed May 18, 2023
1 parent 67cf6d3 commit c33c468
Show file tree
Hide file tree
Showing 2 changed files with 880 additions and 864 deletions.
21 changes: 12 additions & 9 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,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 @@ -543,7 +543,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 @@ -673,7 +673,7 @@ function _createImpressionObject(bid) {
isInvalidNativeRequest = false;
}
break;
case VIDEO:
case FEATURES.VIDEO && VIDEO:
videoObj = _createVideoRequest(bid);
if (videoObj !== UNDEFINED) {
impObj.video = videoObj;
Expand Down Expand Up @@ -709,7 +709,7 @@ function _createImpressionObject(bid) {

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 @@ -810,7 +810,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 @@ -896,7 +896,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 @@ -916,7 +919,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 @@ -999,7 +1002,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 @@ -1284,7 +1287,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 c33c468

Please sign in to comment.