Skip to content

Commit

Permalink
PubMatic: if multi-format ad-unit does not have outstreamAU or render…
Browse files Browse the repository at this point in the history
…er (for out-stream) then continue w/o video (#7275)

* Bug fix to still bid banner and/or native when no outstream renderer is available
  • Loading branch information
pm-harshad-mane authored Aug 10, 2021
1 parent e679fe7 commit 11df18d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,19 @@ export const spec = {
!utils.isStr(bid.params.outstreamAU) &&
!bid.hasOwnProperty('renderer') &&
!bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) {
utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid);
return false;
// we are here since outstream ad-unit is provided without outstreamAU and renderer
// so it is not a valid video ad-unit
// but it may be valid banner or native ad-unit
// so if mediaType banner or Native is present then we will remove media-type video and return true

if (bid.mediaTypes.hasOwnProperty(BANNER) || bid.mediaTypes.hasOwnProperty(NATIVE)) {
delete bid.mediaTypes[VIDEO];
utils.logWarn(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting mediatype Video of bid: `, bid);
return true;
} else {
utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid);
return false;
}
}
}
return true;
Expand Down
83 changes: 83 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,89 @@ describe('PubMatic adapter', function () {
delete bid.params.video.mimes; // Undefined
expect(spec.isBidRequestValid(bid)).to.equal(false);
});

it('checks on bid.params.outstreamAU & bid.renderer & bid.mediaTypes.video.renderer', function() {
const getThebid = function() {
let bid = utils.deepClone(validOutstreamBidRequest.bids[0]);
bid.params.outstreamAU = 'pubmatic-test';
bid.renderer = ' '; // we are only checking if this key is set or not
bid.mediaTypes.video.renderer = ' '; // we are only checking if this key is set or not
return bid;
}

// true: when all are present
// mdiatype: outstream
// bid.params.outstreamAU : Y
// bid.renderer : Y
// bid.mediaTypes.video.renderer : Y
let bid = getThebid();
expect(spec.isBidRequestValid(bid)).to.equal(true);

// true: atleast one is present; 3 cases
// mdiatype: outstream
// bid.params.outstreamAU : Y
// bid.renderer : N
// bid.mediaTypes.video.renderer : N
bid = getThebid();
delete bid.renderer;
delete bid.mediaTypes.video.renderer;
expect(spec.isBidRequestValid(bid)).to.equal(true);

// true: atleast one is present; 3 cases
// mdiatype: outstream
// bid.params.outstreamAU : N
// bid.renderer : Y
// bid.mediaTypes.video.renderer : N
bid = getThebid();
delete bid.params.outstreamAU;
delete bid.mediaTypes.video.renderer;
expect(spec.isBidRequestValid(bid)).to.equal(true);

// true: atleast one is present; 3 cases
// mdiatype: outstream
// bid.params.outstreamAU : N
// bid.renderer : N
// bid.mediaTypes.video.renderer : Y
bid = getThebid();
delete bid.params.outstreamAU;
delete bid.renderer;
expect(spec.isBidRequestValid(bid)).to.equal(true);

// false: none present; only outstream
// mdiatype: outstream
// bid.params.outstreamAU : N
// bid.renderer : N
// bid.mediaTypes.video.renderer : N
bid = getThebid();
delete bid.params.outstreamAU;
delete bid.renderer;
delete bid.mediaTypes.video.renderer;
expect(spec.isBidRequestValid(bid)).to.equal(false);

// true: none present; outstream + Banner
// mdiatype: outstream, banner
// bid.params.outstreamAU : N
// bid.renderer : N
// bid.mediaTypes.video.renderer : N
bid = getThebid();
delete bid.params.outstreamAU;
delete bid.renderer;
delete bid.mediaTypes.video.renderer;
bid.mediaTypes.banner = {sizes: [ [300, 250], [300, 600] ]};
expect(spec.isBidRequestValid(bid)).to.equal(true);

// true: none present; outstream + Native
// mdiatype: outstream, native
// bid.params.outstreamAU : N
// bid.renderer : N
// bid.mediaTypes.video.renderer : N
bid = getThebid();
delete bid.params.outstreamAU;
delete bid.renderer;
delete bid.mediaTypes.video.renderer;
bid.mediaTypes.native = {}
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
});

describe('Request formation', function () {
Expand Down

0 comments on commit 11df18d

Please sign in to comment.