From 187e5e09409bb202f63931aff133e4c9870f67dd Mon Sep 17 00:00:00 2001 From: Marsel Date: Fri, 11 Feb 2022 19:07:50 +0300 Subject: [PATCH] Kubient Bid Adapter: update if bidfloor is zero (#8008) * add uspConsent to sunc URL * kubient: add coppa * added test for coppa * fix-test * replace kdmp.kbntx.ch by matching.kubient.net remove iframe pixel support rename us_privacy -> usp rename consent_str -> consent use URLSearchParams for GET params * fix-test-and-code * removed URLSearchParams * early exit for getUserSyncs, updated test * test-back * test-filter-settings * test-filter-settings * test-filter-settings * test-filter-settings * fix for review * fix for review * fix test for ci passing * fix 2 for ci passing * refactored-test-for-ci * fix-for-review * fix * fix * avoid sending zero bid floor if it is not defined * do not send 0 bidfloor Co-authored-by: Artem Aleksashkin Co-authored-by: Artem Aleksashkin --- modules/kubientBidAdapter.js | 19 ++++++++++--------- test/spec/modules/kubientBidAdapter_spec.js | 8 +++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index fd776793d91..46360572576 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -24,22 +24,23 @@ export const spec = { return; } return validBidRequests.map(function (bid) { - let floor = 0.0; + let adSlot = { + bidId: bid.bidId, + zoneId: bid.params.zoneid || '' + }; + if (typeof bid.getFloor === 'function') { const mediaType = (Object.keys(bid.mediaTypes).length == 1) ? Object.keys(bid.mediaTypes)[0] : '*'; const sizes = bid.sizes || '*'; const floorInfo = bid.getFloor({currency: 'USD', mediaType: mediaType, size: sizes}); - if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - floor = parseFloat(floorInfo.floor); + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD') { + let floor = parseFloat(floorInfo.floor) + if (!isNaN(floor) && floor > 0) { + adSlot.floor = parseFloat(floorInfo.floor); + } } } - let adSlot = { - bidId: bid.bidId, - zoneId: bid.params.zoneid || '', - floor: floor || 0.0 - }; - if (bid.mediaTypes.banner) { adSlot.banner = bid.mediaTypes.banner; } diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index 2d3801450ba..f7afc709564 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -19,7 +19,7 @@ describe('KubientAdapter', function () { }, getFloor: function(params) { return { - floor: 0.05, + floor: 0, currency: 'USD' }; }, @@ -127,10 +127,9 @@ describe('KubientAdapter', function () { expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain'); expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); - expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); } @@ -202,10 +201,9 @@ describe('KubientAdapter', function () { expect(data.uspConsent).to.exist.and.to.equal(uspConsentData); for (let j = 0; j < data['adSlots'].length; j++) { let adSlot = data['adSlots'][i]; - expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain'); + expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain'); expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId); expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid); - expect(adSlot.floor).to.be.a('number'); expect(adSlot.schain).to.be.an('object'); expect(adSlot.banner).to.be.an('object'); }