Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid Core: Display bidder in utils.logs and disable bidder config on auction end #6683

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,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