-
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
Bug: bid.getCpmInNewCurrency does not use latest bid.cpm value and returns value as per original bid value. #3837
Comments
I don't like the idea of modifying I might be okay with having I guess I'm not totally opposed to the idea of exposing our currency conversion as a public API on the pbjs namespace; however there's only few places where it's really applicable and I'd prefer we provide helpers to use the currency conversion in appropriate ways as opposed to opening the floodgates for users who want to use it for everything and anywhere. We aren't a currency conversion library. So I guess I'm interested in knowing where you'd be interested in using Prebid's currency conversion generically as a public API? |
Hello @snapwich , Thank you for your feedback. I also agree that if someone changes bid.currency upon getting the bid it may be a very messy scenario, let's exclude this scenario in the discussion. Why I need this API? |
Hello @snapwich , This is a bug when one uses bidCpmAdjustment to update the bid.cpm. |
Test Page: http://jsfiddle.net/tfsercgk/ |
Description
Bug: bid.getCpmInNewCurrency does not use the latest bid.cpm value and returns value as per original bid value.
We need an API to convert bid from one currency to another.
Scenario
I have set ad-server-currency in the config to INR, let's say USD to INR rate is 1:100.
I want to send bid value in INR to my ad-server but I want to send bid value in USD to my analytics.
The partner sends bid of $5.
I have put a hook on "bidResponse" so when my handler gets a bid object
I do not have a way to convert the 100INR to equivalent $
I think the bug is introduced due to keeping the actual value of bid.cpm in a variable at https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L184 and keeping the actual currency value in https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L183 which are refered in function getCpmInNewCurrency @ https://github.com/prebid/Prebid.js/blob/master/modules/currency.js#L187
Expected results
Approach 1: Quick fix: Can we extend getCpmInNewCurrency which has only one argument (toCurrency) to have multiple arguments (toCurrency, fromCurrency = fromCurrency (var on line 183), cpm = cpm (var on line 184) )
This will help publisher to change bids and also get corresponding bid value in othe currency (USD). Here still all attributes related to cpm (originalCpm etc.) are not updated and publisher will need to update those manually.
Approach 2:
Provide a separate API to do bid conversion in pbjs name-space.
Approach 3:
Provide an API to set the bid cpm value again in bid object which will recalculate values for all cpm related attributes.
The text was updated successfully, but these errors were encountered: