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

Rubicon Analytics: Handle PBS Sending Bid ID 0 #6584

Merged
merged 2 commits into from
Apr 13, 2021
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
5 changes: 3 additions & 2 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) {
const height = bid.height || bid.playerHeight;
return (width && height) ? {width, height} : undefined;
},
'pbsBidId',
'seatBidId',
// Handling use case where pbs sends back 0 or '0' bidIds
'pbsBidId', pbsBidId => pbsBidId == 0 ? utils.generateUUID() : pbsBidId,
bretg marked this conversation as resolved.
Show resolved Hide resolved
'seatBidId', seatBidId => seatBidId == 0 ? utils.generateUUID() : seatBidId,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this logic would be as follows:

If set and is 0 or '0'

then overwrite it

else pass it along

If it is undefined (most often case) it will be ignored downstream and not set.

'floorValue', () => utils.deepAccess(bid, 'floorData.floorValue'),
'floorRuleValue', () => utils.deepAccess(bid, 'floorData.floorRuleValue'),
'floorRule', () => utils.debugTurnedOn() ? utils.deepAccess(bid, 'floorData.floorRule') : undefined,
Expand Down
34 changes: 34 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,40 @@ describe('rubicon analytics adapter', function () {
expect(message.bidsWon[0].bidId).to.equal('zzzz-yyyy-xxxx-wwww');
});

it('should correctly generate new bidId if it is 0', function () {
// Only want one bid request in our mock auction
let bidRequested = utils.deepClone(MOCK.BID_REQUESTED);
bidRequested.bids.shift();
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.adUnits.shift();

// clone the mock bidResponse and duplicate
let seatBidResponse = utils.deepClone(BID4);
seatBidResponse.pbsBidId = '0';

const setTargeting = {
[seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting
};

const bidWon = Object.assign({}, seatBidResponse, {
'status': 'rendered'
});

// spoof the auction with just our duplicates
events.emit(AUCTION_INIT, auctionInit);
events.emit(BID_REQUESTED, bidRequested);
events.emit(BID_RESPONSE, seatBidResponse);
events.emit(AUCTION_END, MOCK.AUCTION_END);
events.emit(SET_TARGETING, setTargeting);
events.emit(BID_WON, bidWon);

let message = JSON.parse(server.requests[0].requestBody);

validate(message);
expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal(STUBBED_UUID);
expect(message.bidsWon[0].bidId).to.equal(STUBBED_UUID);
});

it('should pick the highest cpm bid if more than one bid per bidRequestId', function () {
// Only want one bid request in our mock auction
let bidRequested = utils.deepClone(MOCK.BID_REQUESTED);
Expand Down