Skip to content

Commit

Permalink
display bidder in utils.logs and disable bidder config on auction end (
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and idettman committed May 21, 2021
1 parent f451224 commit 6e0907c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request
bidRequest.start = timestamp();
// TODO : Do we check for bid in pool from here and skip calling adapter again ?
const adapter = _bidderRegistry[bidRequest.bidderCode];
utils.logMessage(`CALLING BIDDER ======= ${bidRequest.bidderCode}`);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
config.runWithBidder(bidRequest.bidderCode, () => {
utils.logMessage(`CALLING BIDDER`);
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest);
});
let ajax = ajaxBuilder(requestBidsTimeout, requestCallbacks ? {
request: requestCallbacks.request.bind(null, bidRequest.bidderCode),
done: requestCallbacks.done
Expand Down
6 changes: 4 additions & 2 deletions src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ export function newBidder(spec) {
const responses = [];
function afterAllResponses() {
done();
events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest);
registerSyncs(responses, bidderRequest.gdprConsent, bidderRequest.uspConsent);
config.runWithBidder(spec.code, () => {
events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest);
registerSyncs(responses, bidderRequest.gdprConsent, bidderRequest.uspConsent);
});
}

const validBidRequests = bidderRequest.bids.filter(filterAndWarn);
Expand Down
1 change: 1 addition & 0 deletions src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a
}

function auctionDone() {
config.resetBidder();
// when all bidders have called done callback atleast once it means auction is complete
utils.logInfo(`Bids Received for Auction with id: ${_auctionId}`, _bidsReceived);
_auctionStatus = AUCTION_COMPLETED;
Expand Down
7 changes: 6 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export function newConfig() {
try {
return fn();
} finally {
currBidder = null;
resetBidder();
}
}
function callbackWithBidder(bidder) {
Expand All @@ -614,10 +614,15 @@ export function newConfig() {
return currBidder;
}

function resetBidder() {
currBidder = null;
}

resetConfig();

return {
getCurrentBidder,
resetBidder,
getConfig,
setConfig,
setDefaults,
Expand Down
13 changes: 11 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,19 @@ export function logError() {

function decorateLog(args, prefix) {
args = [].slice.call(args);
let bidder = config.getCurrentBidder();

prefix && args.unshift(prefix);
args.unshift('display: inline-block; color: #fff; background: #3b88c3; padding: 1px 4px; border-radius: 3px;');
args.unshift('%cPrebid');
if (bidder) {
args.unshift(label('#aaa'));
}
args.unshift(label('#3b88c3'));
args.unshift('%cPrebid' + (bidder ? `%c${bidder}` : ''));
return args;

function label(color) {
return `display: inline-block; color: #fff; background: ${color}; padding: 1px 4px; border-radius: 3px;`
}
}

export function hasConsoleLogger() {
Expand Down

0 comments on commit 6e0907c

Please sign in to comment.