Skip to content

Commit f215991

Browse files
pm-harshad-manesa1omon
authored andcommitted
Making originalCpm and originalCurrency fields in bid object always available (prebid#4396)
* added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * moving originalCurrency declaration from currency to bidderFactory * added a comment * trying to re-run the CI job * added unit test case * trying to re-run the CI job
1 parent 4baaf27 commit f215991

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

modules/currency.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ export function addBidResponseHook(fn, adUnitCode, bid) {
185185
return (parseFloat(this.cpm) * getCurrencyConversion(this.currency, toCurrency)).toFixed(3);
186186
};
187187

188-
bid.originalCpm = bid.cpm;
189-
bid.originalCurrency = bid.currency;
190-
191188
// execute immediately if the bid is already in the desired currency
192189
if (bid.currency === adServerCurrency) {
193190
return fn.call(this, adUnitCode, bid);

src/adapters/bidderFactory.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ export function newBidder(spec) {
301301
function addBidUsingRequestMap(bid) {
302302
const bidRequest = bidRequestMap[bid.requestId];
303303
if (bidRequest) {
304+
// creating a copy of original values as cpm and currency are modified later
305+
bid.originalCpm = bid.cpm;
306+
bid.originalCurrency = bid.currency;
304307
const prebidBid = Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid);
305308
addBidWithCode(bidRequest.adUnitCode, prebidBid);
306309
} else {

test/spec/unit/core/bidderFactory_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ describe('bidders created by newBidder', function () {
364364

365365
expect(addBidResponseStub.calledOnce).to.equal(true);
366366
expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement');
367+
let bidObject = addBidResponseStub.firstCall.args[1];
368+
// checking the fields added by our code
369+
expect(bidObject.originalCpm).to.equal(bid.cpm);
370+
expect(bidObject.originalCurrency).to.equal(bid.currency);
367371
expect(doneStub.calledOnce).to.equal(true);
368372
expect(logErrorSpy.callCount).to.equal(0);
369373
});

0 commit comments

Comments
 (0)