-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Prebid Core: Refine coordination of PBS+PBJS Floors #8865
Conversation
@@ -902,6 +902,20 @@ Object.assign(ORTB2.prototype, { | |||
addBidderFirstPartyDataToRequest(request, s2sBidRequest.ortb2Fragments?.bidder || {}); | |||
|
|||
request.imp.forEach((imp) => this.impRequested[imp.id] = imp); | |||
|
|||
if (typeof request.ext.prebid.floors === 'object' && request.ext.prebid.floors.enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typeof
check is not that useful because typeof null === 'object'
. IMO it's better to use if (request.ext?.prebid?.floors?.enabled)
.
bidfloorArray.push(imp.bidfloor); | ||
} | ||
}); | ||
request.ext.prebid.floors.floorMin = Math.min(...bidfloorArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this loops over floors twice more, which is rather inefficient compared to the zero that are required. You could keep track of the minimum as we calculate the floors, and here just append it to the request if ext.prebid.floors.enabled
is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @dgirardi. would the changes for my latest commit work? also, one additional question, for each imp would i still need to assign imp.ext.prebid.floors.floorMin = imp.bidfloor
? (as seen in the comment above)
@@ -728,6 +729,7 @@ Object.assign(ORTB2.prototype, { | |||
if (floor) { | |||
imp.bidfloor = floor.floor; | |||
imp.bidfloorcur = floor.currency; | |||
bidfloorArray.push(floor.floor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you should copy over to floorMin here, and still spare the Math.min
loop by just keeping the minimum here. (Instead of bidfloorArray = []
to start, you could set let floorMin = null
and here do if (floorMin == null || floorMin > imp.bidfloor) { floorMin = imp.bidfloor }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgirardi thanks, just made those changes to the PR
@@ -728,6 +729,8 @@ Object.assign(ORTB2.prototype, { | |||
if (floor) { | |||
imp.bidfloor = floor.floor; | |||
imp.bidfloorcur = floor.currency; | |||
imp.ext.prebid.floors = { floorMin: imp.bidfloor }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure imp.ext.prebid always exists at this point; I would prefer deepSetValue(imp, 'ext.prebid.floors.floorMin', imp.bidfloor)
.
(I believe in some cases, like stored impressions where no params were set in imp.ext.prebid.bidder
, this as it is would throw an error. Although thinking about it maybe floors would also never be present? maybe it's a bit overprudent).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I wonder - if the pub already set ortb2Imp.ext.prebid.floors.floorMin
, should we keep it or override it here? I think keeping it makes more sense but then that should also become the value you check against the request-wide floorMin
.
I still don't understand the difference between a floor and a floorMin, so I'm not completely sure sure what makes sense here. The floors module should respect ortb2Imp.ext.prebid.floors.floorMin
, but I think it may return a lower floor. Should floorMin be the pub-provided value or the actual floor in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, not sure. so the question is should imp.ext.prebid.floors.floorMin
be set to ortb2Imp.ext.prebid.floors.floorMin
(if exists) or imp.bidfloor
as a fallback?
inside of the description for #8749, it says if imp[n].bidfloor exists, copy it to imp[n].ext.prebid.floors.floorMin
. also states that imp[n].bidfloor
is the default floor and that imp-level minFloor is not yet supported server-side. does that mean (for now at least), that the logic should be if imp[n].bidfloor exists, copy it to imp[n].ext.prebid.floors.floorMin
?
maybe @bretg could provide some more clarity around this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion if the pub has provided ortb2Imp.ext.prebid.floors.floorMin
we should keep it and use that as the floorMin. But if the request-wide floor min is higher, than it should set it to the higher one.
The imp level floor mins should not overwrite the pub provided one if they are lower. Maybe I am misinterpreting though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgirardi @robertrmartinez could you review when you have time? Spoke with @bretg on the issue page for this ticket (https://github.com/prebid/Prebid.js/issues/8749
) and updated my PR just now.
Does this need to take floor currency into account? See #8938 |
@dgirardi updated the PR to address currency as we discussed. also updated the tests on this PR |
@@ -728,6 +730,13 @@ Object.assign(ORTB2.prototype, { | |||
if (floor) { | |||
imp.bidfloor = floor.floor; | |||
imp.bidfloorcur = floor.currency; | |||
|
|||
const ortb2ImpFloorMin = imp.ext?.prebid?.floors?.floorMin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should fall back to imp.ext?.prebid?.floorMin
(see #8938 (comment));
also, if we are considering the currency, this should be converted to floorMinCur
before the comparison with floorMin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, just pushed a new commit with the changes
554ea0b
to
36ebe93
Compare
const ortb2ImpFloorMin = imp.ext?.prebid?.floors?.floorMin || imp.ext?.prebid?.floorMin; | ||
const lowestImpFloorMin = ortb2ImpFloorMin && ortb2ImpFloorMin < convertedFloorValue ? ortb2ImpFloorMin : convertedFloorValue; | ||
|
||
deepSetValue(imp, 'ext.prebid.floors.floorMin', lowestImpFloorMin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a test case: you have a bidRequest with
getFloor() {return {currency: 'JPY', floor: 2}},
ortb2Imp: {
ext: { prebid: { floors: { floorMinCur: 'USD', floorMin: 1 }}}
}
Since 2 JPY is less than 1 USD, the expectation is that imp[].ext.prebid.floors
is set to either 2 JPY, or its equivalent in USD. I think this implementation would set 1 JPY.
e68a368
to
4316c49
Compare
…floorMinCur is set
2ffd355
to
de6864b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine.
My only suggestion is that maybe add some comments somewhere describing the behavior?
Maybe this behavior is outlined in the docs, but for someone who is looking at code and does not know much about prebid + floors this may be a confusing section of code. Comments get removed when we browserify so I do not see any harm in adding some.
@robertrmartinez thanks, and good call. Just added a few comments referencing the GH ticket and walking through the logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome looks great
* stronger coordination between pbs and pbjs floors * reverted changes for test page * spacing change * refactored code * reverted change to adunits html * refactored pbjs to pbs floormin logic * refactored pbjs to pbs floormin logic * removed comment * refactored code * updated logic * no longer ignoring currencies * added fallback to deprecating prebid.floorMin and repositioned where floorMinCur is set * progress * updated floorMinCur logic * reverted code on example pages * format adjustmnet * format adjustment * format adjustment * updated currency conversion logic * updated currency conversion logic * updated floorMinCur default for ortb2 * resolved conflicts * formatting * formatting * added few comments explaining the logic for this change Co-authored-by: Jason Quaccia <jasonquaccia@RWC-WS233.local>
* stronger coordination between pbs and pbjs floors * reverted changes for test page * spacing change * refactored code * reverted change to adunits html * refactored pbjs to pbs floormin logic * refactored pbjs to pbs floormin logic * removed comment * refactored code * updated logic * no longer ignoring currencies * added fallback to deprecating prebid.floorMin and repositioned where floorMinCur is set * progress * updated floorMinCur logic * reverted code on example pages * format adjustmnet * format adjustment * format adjustment * updated currency conversion logic * updated currency conversion logic * updated floorMinCur default for ortb2 * resolved conflicts * formatting * formatting * added few comments explaining the logic for this change Co-authored-by: Jason Quaccia <jasonquaccia@RWC-WS233.local>
Type of change
Description of change
Other information
Related Issue: #8749
@dgirardi could you review when you have time?