Skip to content

Commit

Permalink
calling adapter after all bidrequests are pushed to pbjs._bidsRequest…
Browse files Browse the repository at this point in the history
…ed. fixes #1603
  • Loading branch information
jaiminpanchal27 committed Oct 13, 2017
1 parent fc9cbfb commit 6713f2d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ exports.callBids = ({adUnits, cbTimeout}) => {
}
}

let _bidderRequests = [];
bidderCodes.forEach(bidderCode => {
const adapter = _bidderRegistry[bidderCode];
if (adapter) {
Expand All @@ -165,20 +166,29 @@ exports.callBids = ({adUnits, cbTimeout}) => {
requestId,
bidderRequestId,
bids: getBids({bidderCode, requestId, bidderRequestId, adUnits}),
start: new Date().getTime(),
auctionStart: auctionStart,
timeout: cbTimeout
};
if (bidderRequest.bids && bidderRequest.bids.length !== 0) {
utils.logMessage(`CALLING BIDDER ======= ${bidderCode}`);
$$PREBID_GLOBAL$$._bidsRequested.push(bidderRequest);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidderRequest);
adapter.callBids(bidderRequest);
_bidderRequests.push(bidderRequest);
}
} else {
utils.logError(`Adapter trying to be called which does not exist: ${bidderCode} adaptermanager.callBids`);
}
});

_bidderRequests.forEach(bidRequest => {
bidRequest.start = new Date().getTime();
const adapter = _bidderRegistry[bidRequest.bidderCode];
if (adapter) {
if (bidRequest.bids && bidRequest.bids.length !== 0) {
utils.logMessage(`CALLING BIDDER ======= ${bidRequest.bidderCode}`);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
adapter.callBids(bidRequest);
}
} else {
utils.logError(`Adapter trying to be called which does not exist: ${bidRequest.bidderCode} adaptermanager.callBids`);
}
})
};

function transformHeightWidth(adUnit) {
Expand Down

0 comments on commit 6713f2d

Please sign in to comment.