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

Update floors module for #5511 #5538

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ export function updateAdUnitsForAuction(adUnits, floorData, auctionId) {
bid.auctionId = auctionId;
bid.floorData = {
skipped: floorData.skipped,
modelVersion: utils.deepAccess(floorData, 'data.modelVersion'),
location: utils.deepAccess(floorData, 'data.location'),
skipRate: floorData.skipRate,
modelVersion: utils.deepAccess(floorData, 'data.modelVersion'),
location: utils.deepAccess(floorData, 'data.location', 'noData'),
diDNA-matt marked this conversation as resolved.
Show resolved Hide resolved
fetchStatus: _floorsConfig.fetchStatus
diDNA-matt marked this conversation as resolved.
Show resolved Hide resolved
}
});
Expand Down Expand Up @@ -568,8 +568,9 @@ export function handleSetFloorsConfig(config) {
_floorsConfig = utils.pick(config, [
'enabled', enabled => enabled !== false, // defaults to true
'auctionDelay', auctionDelay => auctionDelay || 0,
'floorProvider', floorProvider => String(floorProvider) || '',
diDNA-matt marked this conversation as resolved.
Show resolved Hide resolved
'endpoint', endpoint => endpoint || {},
'skipRate', () => !isNaN(utils.deepAccess(config, 'data.skipRate')) ? config.data.skipRate : config.skipRate || 0,
'skipRate', () => !isNaN(utils.deepAccess(config, 'data.skipRate')) ? config.data.skipRate : config.skipRate || undefined,
diDNA-matt marked this conversation as resolved.
Show resolved Hide resolved
'enforcement', enforcement => utils.pick(enforcement || {}, [
'enforceJS', enforceJS => enforceJS !== false, // defaults to true
'enforcePBS', enforcePBS => enforcePBS === true, // defaults to false
Expand Down
4 changes: 3 additions & 1 deletion modules/priceFloors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pbjs.setConfig({
enforceJS: true //defaults to true
},
auctionDelay: 150, // in milliseconds defaults to 0
floorProvider: '', //defaults to en empty string
diDNA-matt marked this conversation as resolved.
Show resolved Hide resolved
endpoint: {
url: 'http://localhost:1500/floor-domains',
method: 'GET' // Only get supported for now
Expand Down Expand Up @@ -40,6 +41,7 @@ pbjs.setConfig({
| enabled | Wether to turn off or on the floors module |
| enforcement | object of booleans which control certain features of the module |
| auctionDelay | The time to suspend and auction while waiting for a real time price floors fetch to come back |
| floorProvider | A string identifying the floor provider.|
| endpoint | An object describing the endpoint to retrieve floor data from. GET only |
| data | The data to be used to select appropriate floors. See schema for more detail |
| additionalSchemaFields | An object of additional fields to be used in a floor data object. The schema is KEY: function to retrieve the match |
Expand All @@ -59,4 +61,4 @@ This function can takes in an object with the following optional parameters:

If a bid adapter passes in `*` as an attribute, then the `priceFloors` module will attempt to select the best rule based on context.

For example, if an adapter passes in a `*`, but the bidRequest only has a single size and a single mediaType, then the `getFloor` function will attempt to get a rule for that size before matching with the `*` catch-all. Similarily, if mediaType can be inferred on the bidRequest, it will use it.
For example, if an adapter passes in a `*`, but the bidRequest only has a single size and a single mediaType, then the `getFloor` function will attempt to get a rule for that size before matching with the `*` catch-all. Similarily, if mediaType can be inferred on the bidRequest, it will use it.
27 changes: 14 additions & 13 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('the price floors module', function () {
const basicFloorConfig = {
enabled: true,
auctionDelay: 0,
floorProvider: '',
endpoint: {},
enforcement: {
enforceJS: true,
Expand Down Expand Up @@ -314,8 +315,8 @@ describe('the price floors module', function () {
validateBidRequests(false, {
skipped: true,
modelVersion: undefined,
location: undefined,
skipRate: 0,
location: 'noData',
skipRate: undefined,
fetchStatus: undefined
});
});
Expand Down Expand Up @@ -347,7 +348,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'adUnit Model Version',
location: 'adUnit',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});
});
Expand All @@ -358,7 +359,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});
});
Expand Down Expand Up @@ -403,7 +404,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});
});
Expand Down Expand Up @@ -464,7 +465,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'model-1',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});

Expand All @@ -475,7 +476,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'model-2',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});

Expand All @@ -486,7 +487,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'model-3',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});
});
Expand All @@ -513,7 +514,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: undefined
});
});
Expand Down Expand Up @@ -590,7 +591,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: 'timeout'
});
fakeFloorProvider.respond();
Expand Down Expand Up @@ -626,7 +627,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'fetch model name',
location: 'fetch',
skipRate: 0,
skipRate: undefined,
fetchStatus: 'success'
});
});
Expand Down Expand Up @@ -684,7 +685,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: 'error'
});
});
Expand All @@ -706,7 +707,7 @@ describe('the price floors module', function () {
skipped: false,
modelVersion: 'basic model',
location: 'setConfig',
skipRate: 0,
skipRate: undefined,
fetchStatus: 'success'
});
});
Expand Down