Skip to content

Commit

Permalink
review comment for make function
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez committed Nov 13, 2020
1 parent c9532b5 commit 06bb14e
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,18 @@ function addWurl(auctionId, adId, wurl) {
}
}

function getPbsResponseData(bidderRequests, response, pbsName, pbjsName) {
const bidderValues = utils.deepAccess(response, `ext.${pbsName}`);
if (bidderValues) {
Object.keys(bidderValues).forEach(bidder => {
let biddersReq = find(bidderRequests, bidderReq => bidderReq.bidderCode === bidder);
if (biddersReq) {
biddersReq[pbjsName] = bidderValues[bidder];
}
});
}
}

/**
* @param {string} auctionId
* @param {string} adId generated value set to bidObject.adId by bidderFactory Bid()
Expand Down Expand Up @@ -676,27 +688,9 @@ const OPEN_RTB_PROTOCOL = {
interpretResponse(response, bidderRequests) {
const bids = [];

// Should log all bidders server response times, not only if they had successful seatBid
const serverResponseTimeMs = utils.deepAccess(response, 'ext.responsetimemillis');
if (serverResponseTimeMs) {
Object.keys(serverResponseTimeMs).forEach(bidder => {
let biddersReq = find(bidderRequests, bidderReq => bidderReq.bidderCode === bidder);
if (biddersReq) {
biddersReq.serverResponseTimeMs = serverResponseTimeMs[bidder];
}
});
}
[('errors', 'serverErrors'), ('responsetimemillis', 'serverResponseTimeMs')]
.forEach(info => getPbsResponseData(bidderRequests, response, info[0], info[1]))

// Attach any errors to a biddersRequest object
const bidderErrors = utils.deepAccess(response, 'ext.errors');
if (bidderErrors) {
Object.keys(bidderErrors).forEach(bidder => {
let biddersReq = find(bidderRequests, bidderReq => bidderReq.bidderCode === bidder);
if (biddersReq) {
biddersReq.serverErrors = bidderErrors[bidder];
}
});
}
if (response.seatbid) {
// a seatbid object contains a `bid` array and a `seat` string
response.seatbid.forEach(seatbid => {
Expand Down

0 comments on commit 06bb14e

Please sign in to comment.