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

add meta key to interpreted bid response #5358

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export function newBidder(spec) {
// creating a copy of original values as cpm and currency are modified later
bid.originalCpm = bid.cpm;
bid.originalCurrency = bid.currency;
bid.meta = bid.meta || Object.assign({}, bid[bidRequest.bidder]);
Copy link
Collaborator

@robertrmartinez robertrmartinez Jun 15, 2020

Choose a reason for hiding this comment

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

Took me a couple minutes to realize what bid[bidRequest.bidder] was. Figured it out, then noticed you explained it in the PR text as well haha 🤦

Looks good!

const prebidBid = Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid);
addBidWithCode(bidRequest.adUnitCode, prebidBid);
} else {
Expand Down
10 changes: 8 additions & 2 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,12 @@ describe('bidders created by newBidder', function () {
adUnitCode: 'mock/placement',
currency: 'USD',
netRevenue: true,
ttl: 300
ttl: 300,
bidderCode: 'sampleBidder',
sampleBidder: {advertiserId: '12345', networkId: '111222'}
};
const bidderRequest = Object.assign({}, MOCK_BIDS_REQUEST);
bidderRequest.bids[0].bidder = 'sampleBidder';
spec.isBidRequestValid.returns(true);
spec.buildRequests.returns({
method: 'POST',
Expand All @@ -413,7 +417,7 @@ describe('bidders created by newBidder', function () {

spec.interpretResponse.returns(bid);

bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);
bidder.callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback);

expect(addBidResponseStub.calledOnce).to.equal(true);
expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement');
Expand All @@ -423,6 +427,8 @@ describe('bidders created by newBidder', function () {
expect(bidObject.originalCurrency).to.equal(bid.currency);
expect(doneStub.calledOnce).to.equal(true);
expect(logErrorSpy.callCount).to.equal(0);
expect(bidObject.meta).to.exist;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a separate unit test. Assert that values are being copied properly

expect(bidObject.meta).to.deep.equal({advertiserId: '12345', networkId: '111222'});
});

it('should call spec.getUserSyncs() with the response', function () {
Expand Down