diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 5d23a0366eab..7a1ff94644d6 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -355,10 +355,8 @@ const LEGACY_PROTOCOL = { * Protocol spec for OpenRTB endpoint * e.g., https:///v1/openrtb2/auction */ +let bidIdMap = {}; const OPEN_RTB_PROTOCOL = { - - bidMap: {}, - buildRequest(s2sBidRequest, bidRequests, adUnits) { let imps = []; let aliases = {}; @@ -368,8 +366,7 @@ const OPEN_RTB_PROTOCOL = { adUnit.bids.forEach(bid => { // OpenRTB response contains the adunit code and bidder name. These are // combined to create a unique key for each bid since an id isn't returned - const key = `${adUnit.code}${bid.bidder}`; - this.bidMap[key] = bid; + bidIdMap[`${adUnit.code}${bid.bidder}`] = bid.bid_id; // check for and store valid aliases to add to the request if (adaptermanager.aliasRegistry[bid.bidder]) { @@ -481,17 +478,22 @@ const OPEN_RTB_PROTOCOL = { // a seatbid object contains a `bid` array and a `seat` string response.seatbid.forEach(seatbid => { (seatbid.bid || []).forEach(bid => { - const bidRequest = utils.getBidRequest( - this.bidMap[`${bid.impid}${seatbid.seat}`].bid_id, - bidderRequests - ); + let bidRequest; + let key = `${bid.impid}${seatbid.seat}`; + if (bidIdMap[key]) { + bidRequest = utils.getBidRequest( + bidIdMap[key], + bidderRequests + ); + } const cpm = bid.price; const status = cpm !== 0 ? STATUS.GOOD : STATUS.NO_BID; - let bidObject = bidfactory.createBid(status, bidRequest); + let bidObject = bidfactory.createBid(status, bidRequest || { + bidder: seatbid.seat, + src: TYPE + }); - bidObject.source = TYPE; - bidObject.bidderCode = seatbid.seat; bidObject.cpm = cpm; let serverResponseTimeMs = utils.deepAccess(response, ['ext', 'responsetimemillis', seatbid.seat].join('.')); diff --git a/src/adaptermanager.js b/src/adaptermanager.js index 32cbc55cd8fe..8d07e0ccacc5 100644 --- a/src/adaptermanager.js +++ b/src/adaptermanager.js @@ -47,7 +47,7 @@ function getLabels(bidOrAdUnit, activeLabels) { return {labelAll: false, labels: bidOrAdUnit.labelAny, activeLabels}; } -function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) { +function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels, src}) { return adUnits.reduce((result, adUnit) => { let { active, @@ -111,6 +111,7 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) { bidId: bid.bid_id || utils.getUniqueIdentifierStr(), bidderRequestId, auctionId, + src, bidRequestsCount: adunitCounter.getCounter(adUnit.code), })); } @@ -207,7 +208,7 @@ exports.makeBidRequests = function(adUnits, auctionStart, auctionId, cbTimeout, auctionId, bidderRequestId, tid, - bids: getBids({bidderCode, auctionId, bidderRequestId, 'adUnits': utils.deepClone(adUnitsS2SCopy), labels}), + bids: getBids({bidderCode, auctionId, bidderRequestId, 'adUnits': utils.deepClone(adUnitsS2SCopy), labels, src: CONSTANTS.S2S.SRC}), auctionStart: auctionStart, timeout: _s2sConfig.timeout, src: CONSTANTS.S2S.SRC, @@ -242,7 +243,7 @@ exports.makeBidRequests = function(adUnits, auctionStart, auctionId, cbTimeout, bidderCode, auctionId, bidderRequestId, - bids: getBids({bidderCode, auctionId, bidderRequestId, 'adUnits': utils.deepClone(adUnitsClientCopy), labels}), + bids: getBids({bidderCode, auctionId, bidderRequestId, 'adUnits': utils.deepClone(adUnitsClientCopy), labels, src: 'client'}), auctionStart: auctionStart, timeout: cbTimeout, refererInfo