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

Price Floors: Add option for no signal bidders #10867

Merged
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
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
Copy link
Collaborator

@dgirardi dgirardi Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reasoning for the duplicate option? I can think of why you might want to override it when you get it through dynamic data, but the priority should be inverted for that. What's the use case for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the issue:
image

If the dynamic or data object contains it, we should use what is set there, otherwise fallback.

If a pub uses some floor provider, the floor provider's dynamic endpoint may want the most control over this, which is why data is chosen first.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I somehow missed that - thanks!

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: 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 @@ -689,6 +689,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