Skip to content

Commit

Permalink
Clarify ad unit media filtering warning (#1903)
Browse files Browse the repository at this point in the history
* Clarify ad unit media filtering warning

* Update message for video too

* Extract common message logic
  • Loading branch information
matthewlane authored and jaiminpanchal27 committed Dec 4, 2017
1 parent 05e4853 commit 4fc8fa5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,19 @@ $$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.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(utils.unsupportedBidderMessage(adUnit, nonVideoBidders));
adUnit.bids = adUnit.bids.filter(videoBidder);
});

// for native-enabled adUnits, only request bids for bidders that support native
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.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(utils.unsupportedBidderMessage(adUnit, nonNativeBidders));
adUnit.bids = adUnit.bids.filter(nativeBidder);
});

Expand Down
17 changes: 17 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,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.
`;
}

0 comments on commit 4fc8fa5

Please sign in to comment.