Skip to content

Commit

Permalink
Add option for no signal bidders (#10867)
Browse files Browse the repository at this point in the history
  • Loading branch information
apukh-magnite authored Jan 11, 2024
1 parent c94eb4e commit 28ba8bc
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 2 deletions.
22 changes: 20 additions & 2 deletions modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,37 @@ export function getFloorDataFromAdUnits(adUnits) {
}, {});
}

function getNoFloorSignalBidersArray(floorData) {
const { data, enforcement } = floorData
// The data.noFloorSignalBidders higher priority then the enforcment
if (data?.noFloorSignalBidders?.length > 0) {
return data.noFloorSignalBidders
} else if (enforcement?.noFloorSignalBidders?.length > 0) {
return enforcement.noFloorSignalBidders
}
return []
}

/**
* @summary This function takes the adUnits for the auction and update them accordingly as well as returns the rules hashmap for the auction
*/
export function updateAdUnitsForAuction(adUnits, floorData, auctionId) {
const noFloorSignalBiddersArray = getNoFloorSignalBidersArray(floorData)

adUnits.forEach((adUnit) => {
adUnit.bids.forEach(bid => {
if (floorData.skipped) {
// check if the bidder is in the no signal list
const isNoFloorSignaled = noFloorSignalBiddersArray.some(bidderName => bidderName === bid.bidder)
if (floorData.skipped || isNoFloorSignaled) {
isNoFloorSignaled && logInfo(`noFloorSignal to ${bid.bidder}`)
delete bid.getFloor;
} else {
bid.getFloor = getFloor;
}
// information for bid and analytics adapters
bid.auctionId = auctionId;
bid.floorData = {
noFloorSignaled: isNoFloorSignaled,
skipped: floorData.skipped,
skipRate: deepAccess(floorData, 'data.skipRate') ?? floorData.skipRate,
floorMin: floorData.floorMin,
Expand Down Expand Up @@ -663,7 +680,8 @@ export function handleSetFloorsConfig(config) {
'enforceJS', enforceJS => enforceJS !== false, // defaults to true
'enforcePBS', enforcePBS => enforcePBS === true, // defaults to false
'floorDeals', floorDeals => floorDeals === true, // defaults to false
'bidAdjustment', bidAdjustment => bidAdjustment !== false, // defaults to true
'bidAdjustment', bidAdjustment => bidAdjustment !== false, // defaults to true,
'noFloorSignalBidders', noFloorSignalBidders => noFloorSignalBidders || []
]),
'additionalSchemaFields', additionalSchemaFields => typeof additionalSchemaFields === 'object' && Object.keys(additionalSchemaFields).length > 0 ? addFieldOverrides(additionalSchemaFields) : undefined,
'data', data => (data && parseFloorData(data, 'setConfig')) || undefined
Expand Down
118 changes: 118 additions & 0 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,124 @@ describe('the price floors module', function () {
floorProvider: undefined
});
});
it('should not do floor stuff if floors.data is defined by noFloorSignalBidders[]', function() {
handleSetFloorsConfig({
...basicFloorConfig,
data: {
...basicFloorDataLow,
noFloorSignalBidders: ['someBidder', 'someOtherBidder']
}});
runStandardAuction();
validateBidRequests(false, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: undefined,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined,
noFloorSignaled: true
})
});
it('should not do floor stuff if floors.enforcement is defined by noFloorSignalBidders[]', function() {
handleSetFloorsConfig({ ...basicFloorConfig,
enforcement: {
enforceJS: true,
noFloorSignalBidders: ['someBidder', 'someOtherBidder']
},
data: basicFloorDataLow
});
runStandardAuction();
validateBidRequests(false, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: undefined,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined,
noFloorSignaled: true
})
});
it('should not do floor stuff and use first floors.data.noFloorSignalBidders if its defined betwen enforcement.noFloorSignalBidders', function() {
handleSetFloorsConfig({ ...basicFloorConfig,
enforcement: {
enforceJS: true,
noFloorSignalBidders: ['someBidder']
},
data: {
...basicFloorDataLow,
noFloorSignalBidders: ['someBidder', 'someOtherBidder']
}
});
runStandardAuction();
validateBidRequests(false, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: undefined,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined,
noFloorSignaled: true
})
});
it('it shouldn`t return floor stuff for bidder in the noFloorSignalBidders list', function() {
handleSetFloorsConfig({ ...basicFloorConfig,
enforcement: {
enforceJS: true,
},
data: {
...basicFloorDataLow,
noFloorSignalBidders: ['someBidder']
}
});
runStandardAuction()
const bidRequestData = exposedAdUnits[0].bids.find(bid => bid.bidder === 'someBidder');
expect(bidRequestData.hasOwnProperty('getFloor')).to.equal(false);
sinon.assert.match(bidRequestData.floorData, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: undefined,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined,
noFloorSignaled: true
});
})
it('it should return floor stuff if we defined wrong bidder name in data.noFloorSignalBidders', function() {
handleSetFloorsConfig({ ...basicFloorConfig,
enforcement: {
enforceJS: true,
},
data: {
...basicFloorDataLow,
noFloorSignalBidders: ['randomBiider']
}
});
runStandardAuction();
validateBidRequests(true, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: undefined,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined,
noFloorSignaled: false
})
});
it('should use adUnit level data if not setConfig or fetch has occured', function () {
handleSetFloorsConfig({
...basicFloorConfig,
Expand Down

0 comments on commit 28ba8bc

Please sign in to comment.