Skip to content

Commit 4fc8fa5

Browse files
matthewlanejaiminpanchal27
authored andcommitted
Clarify ad unit media filtering warning (#1903)
* Clarify ad unit media filtering warning * Update message for video too * Extract common message logic
1 parent 05e4853 commit 4fc8fa5

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/prebid.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,27 +384,19 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a
384384
adUnits.filter(videoAdUnit).filter(hasNonVideoBidder).forEach(adUnit => {
385385
const nonVideoBidders = adUnit.bids
386386
.filter(bid => !videoBidder(bid))
387-
.map(bid => bid.bidder)
388-
.join(', ');
387+
.map(bid => bid.bidder);
389388

390-
utils.logError(`
391-
${adUnit.code} is a 'video' ad unit but contains non-video bidder(s) ${nonVideoBidders}.
392-
No Prebid demand requests will be triggered for those bidders.
393-
`);
389+
utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonVideoBidders));
394390
adUnit.bids = adUnit.bids.filter(videoBidder);
395391
});
396392

397393
// for native-enabled adUnits, only request bids for bidders that support native
398394
adUnits.filter(nativeAdUnit).filter(hasNonNativeBidder).forEach(adUnit => {
399395
const nonNativeBidders = adUnit.bids
400396
.filter(bid => !nativeBidder(bid))
401-
.map(bid => bid.bidder)
402-
.join(', ');
397+
.map(bid => bid.bidder);
403398

404-
utils.logError(`
405-
${adUnit.code} is a 'native' ad unit but contains non-native bidder(s) ${nonNativeBidders}.
406-
No Prebid demand requests will be triggered for those bidders.
407-
`);
399+
utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonNativeBidders));
408400
adUnit.bids = adUnit.bids.filter(nativeBidder);
409401
});
410402

src/utils.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,20 @@ export function isValidMediaTypes(mediaTypes) {
794794

795795
return true;
796796
}
797+
798+
/**
799+
* Constructs warning message for when unsupported bidders are dropped from an adunit
800+
* @param {Object} adUnit ad unit from which the bidder is being dropped
801+
* @param {Array} unSupportedBidders arrary of bidder codes that are not compatible with the adUnit
802+
* @return {string} warning message to display when condition is met
803+
*/
804+
export function unsupportedBidderMessage(adUnit, unSupportedBidders) {
805+
const mediaType = adUnit.mediaType || Object.keys(adUnit.mediaTypes).join(', ');
806+
const plural = unSupportedBidders.length === 1 ? 'This bidder' : 'These bidders';
807+
808+
return `
809+
${adUnit.code} is a ${mediaType} ad unit
810+
containing bidders that don't support ${mediaType}: ${unSupportedBidders.join(', ')}.
811+
${plural} won't fetch demand.
812+
`;
813+
}

0 commit comments

Comments
 (0)