Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sovrn Bid Adapter : fix bidfloor param type #11208

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,11 @@ export const spec = {
}
iv = iv || getBidIdParameter('iv', bid.params)

const floorInfo = (bid.getFloor && typeof bid.getFloor === 'function') ? bid.getFloor({
currency: 'USD',
mediaType: bid.mediaTypes && bid.mediaTypes.banner ? 'banner' : 'video',
size: '*'
}) : {}
floorInfo.floor = floorInfo.floor || getBidIdParameter('bidfloor', bid.params)

const imp = {
adunitcode: bid.adUnitCode,
id: bid.bidId,
tagid: String(getBidIdParameter('tagid', bid.params)),
bidfloor: floorInfo.floor
bidfloor: _getBidFloors(bid)
}

if (deepAccess(bid, 'mediaTypes.banner')) {
Expand Down Expand Up @@ -332,4 +325,18 @@ function _buildVideoRequestObj(bid) {
return videoObj
}

function _getBidFloors(bid) {
const floorInfo = (bid.getFloor && typeof bid.getFloor === 'function') ? bid.getFloor({
currency: 'USD',
mediaType: bid.mediaTypes && bid.mediaTypes.banner ? 'banner' : 'video',
size: '*'
}) : {}
const floorModuleValue = parseFloat(floorInfo.floor)
if (!isNaN(floorModuleValue)) {
return floorModuleValue
}
const paramValue = parseFloat(getBidIdParameter('bidfloor', bid.params))
return !isNaN(paramValue) ? paramValue : undefined
}

registerBidder(spec)
39 changes: 39 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,45 @@ describe('sovrnBidAdapter', function() {

expect(impression.bidfloor).to.equal(2.00)
})
it('floor should be undefined if there is no floor from the floor module and params', function() {
const floorBid = {
...baseBidRequest
}
floorBid.params = {
tagid: 1234
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
it('floor should be undefined if there is incorrect floor value from the floor module', function() {
const floorBid = {
...baseBidRequest,
getFloor: () => ({currency: 'USD', floor: 'incorrect_value'}),
params: {
tagid: 1234
}
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
it('floor should be undefined if there is incorrect floor value from the params', function() {
const floorBid = {
...baseBidRequest,
getFloor: () => ({})
}
floorBid.params = {
tagid: 1234,
bidfloor: 'incorrect_value'
}
const request = spec.buildRequests([floorBid], baseBidderRequest)
const impression = JSON.parse(request.data).imp[0]

expect(impression.bidfloor).to.be.undefined
})
describe('First Party Data', function () {
it('should provide first party data if provided', function() {
const ortb2 = {
Expand Down