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

Prebid Core: Refine coordination of PBS+PBJS Floors #8865

Merged
merged 25 commits into from
Oct 6, 2022

Conversation

jlquaccia
Copy link
Collaborator

Type of change

  • Enhancement

Description of change

  • stronger coordination between pbs and pbjs floors
  • will set the floorMins pbs if bidfloor values within imp's are detected

Other information

Related Issue: #8749
@dgirardi could you review when you have time?

@@ -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) {
Copy link
Collaborator

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);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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)

@patmmccann patmmccann changed the title Issue 8749 - Refine coordination of PBS+PBJS Floors Prebid Core: Refine coordination of PBS+PBJS Floors Aug 19, 2022
@@ -728,6 +729,7 @@ Object.assign(ORTB2.prototype, {
if (floor) {
imp.bidfloor = floor.floor;
imp.bidfloorcur = floor.currency;
bidfloorArray.push(floor.floor);
Copy link
Collaborator

@dgirardi dgirardi Aug 19, 2022

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 }.

Copy link
Collaborator Author

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 };
Copy link
Collaborator

@dgirardi dgirardi Aug 19, 2022

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).

Copy link
Collaborator

@dgirardi dgirardi Aug 19, 2022

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

@dgirardi
Copy link
Collaborator

dgirardi commented Sep 1, 2022

Does this need to take floor currency into account? See #8938

@patmmccann patmmccann linked an issue Sep 7, 2022 that may be closed by this pull request
@jlquaccia
Copy link
Collaborator Author

@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;
Copy link
Collaborator

@dgirardi dgirardi Sep 16, 2022

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.

Copy link
Collaborator Author

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

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);
Copy link
Collaborator

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.

Copy link
Collaborator

@robertrmartinez robertrmartinez left a 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.

@jlquaccia
Copy link
Collaborator Author

@robertrmartinez thanks, and good call. Just added a few comments referencing the GH ticket and walking through the logic

Copy link
Collaborator

@robertrmartinez robertrmartinez left a comment

Choose a reason for hiding this comment

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

Awesome looks great

@ChrisHuie ChrisHuie merged commit 17b9b32 into prebid:master Oct 6, 2022
JacobKlein26 pushed a commit to nextmillenniummedia/Prebid.js that referenced this pull request Feb 9, 2023
* 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>
jorgeluisrocha pushed a commit to jwplayer/Prebid.js that referenced this pull request May 23, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refine coordination of PBS+PBJS Floors
5 participants