diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 6891285fcc22..c791acd94852 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -511,7 +511,7 @@ function _createImpressionObject(bid, conf) { impObj = { id: bid.bidId, - tagid: bid.params.adUnit, + tagid: bid.params.adUnit || undefined, bidfloor: _parseSlotParam('kadfloor', bid.params.kadfloor), secure: window.location.protocol === 'https:' ? 1 : 0, ext: { @@ -746,10 +746,6 @@ export const spec = { utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be numeric. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); return false; } - if (!utils.isStr(bid.params.adSlot)) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: adSlotId is mandatory and cannot be numeric. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); - return false; - } // video ad validation if (bid.params.hasOwnProperty('video')) { if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { @@ -783,17 +779,11 @@ export const spec = { var blockedIabCategories = []; validBidRequests.forEach(originalBid => { bid = utils.deepClone(originalBid); + bid.params.adSlot = bid.params.adSlot || ''; _parseAdSlot(bid); if (bid.params.hasOwnProperty('video')) { - if (!(bid.params.adSlot && bid.params.adUnit && bid.params.adUnitIndex)) { - utils.logWarn(LOG_WARN_PREFIX + 'Skipping the non-standard adslot: ', bid.params.adSlot, JSON.stringify(bid)); - return; - } + // Nothing to do } else { - if (!(bid.params.adSlot && bid.params.adUnit && bid.params.adUnitIndex)) { - utils.logWarn(LOG_WARN_PREFIX + 'Skipping the non-standard adslot: ', bid.params.adSlot, JSON.stringify(bid)); - return; - } // If we have a native mediaType configured alongside banner, its ok if the banner size is not set in width and height // The corresponding banner imp object will not be generated, but we still want the native object to be sent, hence the following check if (!(bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(NATIVE)) && bid.params.width === 0 && bid.params.height === 0) { diff --git a/modules/pubmaticBidAdapter.md b/modules/pubmaticBidAdapter.md index 16a3b203e202..1948acba40fa 100644 --- a/modules/pubmaticBidAdapter.md +++ b/modules/pubmaticBidAdapter.md @@ -25,7 +25,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156209', // required - adSlot: 'pubmatic_test2', // required + adSlot: 'pubmatic_test2', // optional pmzoneid: 'zone1, zone11', // optional lat: '40.712775', // optional lon: '-74.005973', // optional @@ -56,7 +56,7 @@ var adVideoAdUnits = [ bidder: 'pubmatic', params: { publisherId: '156209', // required - adSlot: 'pubmatic_video1', // required + adSlot: 'pubmatic_video1', // optional video: { mimes: ['video/mp4','video/x-flv'], // required skippable: true, // optional @@ -104,7 +104,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156295', // required - adSlot: 'pubmatic_test2@1x1', // required + adSlot: 'pubmatic_test2@1x1', // optional } }] }]; @@ -146,7 +146,7 @@ var adUnits = [ bidder: 'pubmatic', params: { publisherId: '156209', // required - adSlot: 'pubmatic_test2@300x250', // required + adSlot: 'pubmatic_test2@300x250', // optional pmzoneid: 'zone1, zone11', // optional lat: '40.712775', // optional lon: '-74.005973', // optional diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index bf008574027e..b25fd22f822f 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -668,27 +668,15 @@ describe('PubMatic adapter', function () { expect(isValid).to.equal(false); }); - it('invalid bid case: adSlot not passed', function () { - let validBid = { - bidder: 'pubmatic', - params: { - publisherId: '301' - } - }, - isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); - }); - - it('invalid bid case: adSlot is not string', function () { + it('valid bid case: adSlot is not passed', function () { let validBid = { bidder: 'pubmatic', params: { - publisherId: '301', - adSlot: 15671365 + publisherId: '301' } }, isValid = spec.isBidRequestValid(validBid); - expect(isValid).to.equal(false); + expect(isValid).to.equal(true); }); }); @@ -742,6 +730,39 @@ describe('PubMatic adapter', function () { expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); }); + it('Request params check: without adSlot', function () { + delete bidRequests[0].params.adSlot; + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.at).to.equal(1); // auction type + expect(data.cur[0]).to.equal('USD'); // currency + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL + expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id + expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter + expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); + expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB + expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender + expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude + expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID + expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID + expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID + + expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id + expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.kadfloor)); // kadfloor + expect(data.imp[0].tagid).to.deep.equal(undefined); // tagid + expect(data.imp[0].banner.w).to.equal(728); // width + expect(data.imp[0].banner.h).to.equal(90); // height + expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]); + expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + }); + it('Request params multi size format object check', function () { let bidRequests = [ {