Skip to content

Commit

Permalink
Rubicon Analytics: Handle PBS Sending Bid ID 0 (#6584)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Apr 13, 2021
1 parent c83bc53 commit 41e050a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
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,
'seatBidId', seatBidId => seatBidId == 0 ? utils.generateUUID() : seatBidId,
'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

0 comments on commit 41e050a

Please sign in to comment.