From e1f9c2c3a59cc0bdd4ea66bff6fbd4ea7f27dfa6 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Thu, 30 Nov 2017 10:26:14 -0800 Subject: [PATCH 1/3] Clarify ad unit media filtering warning --- src/prebid.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index f0c9c561819..df1bf253ff4 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -401,9 +401,9 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a .map(bid => bid.bidder) .join(', '); - utils.logError(` - ${adUnit.code} is a 'native' ad unit but contains non-native bidder(s) ${nonNativeBidders}. - No Prebid demand requests will be triggered for those bidders. + utils.logWarn(` + ${adUnit.code} is a 'native' ad unit that contains non-native bidder(s): ${nonNativeBidders}. + Those bidders won't fetch demand. `); adUnit.bids = adUnit.bids.filter(nativeBidder); }); From dbfedeedddca90e39ff16a4fe7ef7ed7cdfb1988 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Thu, 30 Nov 2017 10:33:31 -0800 Subject: [PATCH 2/3] Update message for video too --- src/prebid.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index df1bf253ff4..2773008e622 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -387,9 +387,9 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a .map(bid => bid.bidder) .join(', '); - utils.logError(` - ${adUnit.code} is a 'video' ad unit but contains non-video bidder(s) ${nonVideoBidders}. - No Prebid demand requests will be triggered for those bidders. + utils.logWarn(` + ${adUnit.code} is a 'video' ad unit that contains non-video bidder(s): ${nonVideoBidders}. + Those bidders won't fetch demand. `); adUnit.bids = adUnit.bids.filter(videoBidder); }); From 17885d70fa72c8a82d7278266d447e0fd8838e9b Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Thu, 30 Nov 2017 14:09:21 -0800 Subject: [PATCH 3/3] Extract common message logic --- src/prebid.js | 16 ++++------------ src/utils.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 2773008e622..2b61a839b5e 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -384,13 +384,9 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a adUnits.filter(videoAdUnit).filter(hasNonVideoBidder).forEach(adUnit => { const nonVideoBidders = adUnit.bids .filter(bid => !videoBidder(bid)) - .map(bid => bid.bidder) - .join(', '); + .map(bid => bid.bidder); - utils.logWarn(` - ${adUnit.code} is a 'video' ad unit that contains non-video bidder(s): ${nonVideoBidders}. - Those bidders won't fetch demand. - `); + utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonVideoBidders)); adUnit.bids = adUnit.bids.filter(videoBidder); }); @@ -398,13 +394,9 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a adUnits.filter(nativeAdUnit).filter(hasNonNativeBidder).forEach(adUnit => { const nonNativeBidders = adUnit.bids .filter(bid => !nativeBidder(bid)) - .map(bid => bid.bidder) - .join(', '); + .map(bid => bid.bidder); - utils.logWarn(` - ${adUnit.code} is a 'native' ad unit that contains non-native bidder(s): ${nonNativeBidders}. - Those bidders won't fetch demand. - `); + utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonNativeBidders)); adUnit.bids = adUnit.bids.filter(nativeBidder); }); diff --git a/src/utils.js b/src/utils.js index 039282c5f30..e0f727b054e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -793,3 +793,20 @@ export function isValidMediaTypes(mediaTypes) { return true; } + +/** + * Constructs warning message for when unsupported bidders are dropped from an adunit + * @param {Object} adUnit ad unit from which the bidder is being dropped + * @param {Array} unSupportedBidders arrary of bidder codes that are not compatible with the adUnit + * @return {string} warning message to display when condition is met + */ +export function unsupportedBidderMessage(adUnit, unSupportedBidders) { + const mediaType = adUnit.mediaType || Object.keys(adUnit.mediaTypes).join(', '); + const plural = unSupportedBidders.length === 1 ? 'This bidder' : 'These bidders'; + + return ` + ${adUnit.code} is a ${mediaType} ad unit + containing bidders that don't support ${mediaType}: ${unSupportedBidders.join(', ')}. + ${plural} won't fetch demand. + `; +}