From 601d6e877de96178077fff4e4c25c86974c67fed Mon Sep 17 00:00:00 2001 From: robertrmartinez Date: Tue, 13 Apr 2021 11:49:26 -0700 Subject: [PATCH 1/2] if pbs sends bad bidId, overwrite it --- modules/rubiconAnalyticsAdapter.js | 4 +-- .../modules/rubiconAnalyticsAdapter_spec.js | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index 90575cf8cf1..5b3fa4b4b7c 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -363,8 +363,8 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) { const height = bid.height || bid.playerHeight; return (width && height) ? {width, height} : undefined; }, - 'pbsBidId', - 'seatBidId', + '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, diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index 0239eff5883..84315dd1eba 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -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); From 142e45976b77c1cbe704f8eddac49c11ee0793e5 Mon Sep 17 00:00:00 2001 From: robertrmartinez Date: Tue, 13 Apr 2021 12:01:08 -0700 Subject: [PATCH 2/2] add comment! --- modules/rubiconAnalyticsAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index 5b3fa4b4b7c..74f098c0292 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -363,6 +363,7 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) { const height = bid.height || bid.playerHeight; return (width && height) ? {width, height} : undefined; }, + // 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'),