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

bidderSettings: Allow Currency Code control through adjustCurrency #12645

Closed
wants to merge 14 commits into from

Conversation

hi-ubaid
Copy link

@hi-ubaid hi-ubaid commented Jan 13, 2025

Currently, bidCPMAdjustment receives bid.cpm and adjusts it according to the defined process. However, this change updates the behavior to allow passing the entire bid object. With this enhancement, not only will the bid.cpm be adjusted, but the bid's currency code will also be updated, as demonstrated in the Prebid Professor extension.

Previously, bidCPMAdjustment only adjusted the CPM value but did not account for changes to the currency code. This enhancement addresses that limitation.

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

@hi-ubaid
Copy link
Author

Do not know why the test is failing, One can reproduce by adding currency module in their build file, then set adServerCurrency in the pbjs.setConfig, set the bid.currency in the auction.js according to my commit and this will update currency code along with the bid cpm

@ChrisHuie
Copy link
Collaborator

ChrisHuie commented Jan 13, 2025

we updated this ad server currency pattern -> #12102

src/auction.js Outdated
@@ -910,8 +910,9 @@ function setKeys(keyValues, bidderSettings, custBidObj, bidReq) {
export function adjustBids(bid) {
let bidPriceAdjusted = adjustCpm(bid.cpm, bid);

if (bidPriceAdjusted >= 0) {
if (bidPriceAdjusted.cpm >= 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests right now are failing because of linting errors, however, I hope they'd fail on this as well. bidPriceAdjusted is the adjusted CPM, on its own this cannot make sense.

Copy link
Author

Choose a reason for hiding this comment

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

@dgirardi Kindly check it out again as I reverted bidPriceAdjusted as it was before. Now just fetching the adServerCurrency here for the currency code update

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • src/auction.js (+1 error)

@hi-ubaid
Copy link
Author

@dgirardi Now the lint error has also been fixed, kindly look into it now

@hi-ubaid
Copy link
Author

we updated this ad server currency pattern -> #12102

This one is for the teams using bidcpmadjustment function, in that case the currency code is not updated, however the cpm changes.

@hi-ubaid hi-ubaid requested a review from dgirardi January 14, 2025 09:17
@patmmccann
Copy link
Collaborator

@hi-ubaid why not use the currency module to adjust the bid currency instead of the bid adjustment function? Also it seems your change always adjusts the currency to the ad server currency when the bid adjustment function is used, and while it seems one may want that, certainly all cases of use of this function would not want it. Eg, suppose I have the currency module taking bids in Euros and converting them to USD and my bid adjustment function says to give the bid a 50% haircut because it is outstream competing with display. If the currency is adjusted here in the way it is in the pr, I would be required to have my bidadjustment cpm function be responsible for the currency value conversion as well, yet I am relying on another module to do that.

tl;dr: it seems like you're mandating everyone handle currency conversions in bidadjustment function; while that may work for you, your pr may not work for everyone.

Copy link

Tread carefully! This PR adds 4 linter errors (possibly disabled through directives):

  • src/auction.js (+2 errors)
  • src/bidderSettings.js (+2 errors)

@hi-ubaid
Copy link
Author

@patmmccann Can you take a look at it now, it's totally optional and addresses the concern of not making it mandatory for everyone, but it can be helpful for certain use cases as ours

@hi-ubaid hi-ubaid requested a review from dgirardi January 15, 2025 16:58
@hi-ubaid hi-ubaid changed the title bidCPMAdjustment: Convert currency code along with CPM adjustment bidderSettings: Allow Currency Code control through adjustCurrency Jan 16, 2025
@hi-ubaid hi-ubaid closed this Jan 16, 2025
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.

5 participants