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

Drop non-video bidders from video ad units #1815

Merged
merged 3 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a
// for video-enabled adUnits, only request bids if all bidders support video
const invalidVideoAdUnits = adUnits.filter(videoAdUnit).filter(hasNonVideoBidder);
invalidVideoAdUnits.forEach(adUnit => {
utils.logError(`adUnit ${adUnit.code} has 'mediaType' set to 'video' but contains a bidder that doesn't support video. No Prebid demand requests will be triggered for this adUnit.`);
utils.logError(`adUnit ${adUnit.code} is of type 'video' but contains a bidder that doesn't support video. No Prebid demand requests will be triggered for this adUnit.`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that we call the demand that is enabled for video instead of just dropping it completely. Is it hard to make that change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense, I can do it. I'll update the PR to do that when either mediaType or mediaTypes is used to configure 'video'

for (let i = 0; i < adUnits.length; i++) {
if (adUnits[i].code === adUnit.code) { adUnits.splice(i, 1); }
}
Expand Down
6 changes: 5 additions & 1 deletion src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const OUTSTREAM = 'outstream';
/**
* Helper functions for working with video-enabled adUnits
*/
export const videoAdUnit = adUnit => adUnit.mediaType === VIDEO_MEDIA_TYPE;
export const videoAdUnit = adUnit => {
const mediaTypes = deepAccess(adUnit, 'mediaTypes.video');
return !!mediaTypes || adUnit.mediaType === VIDEO_MEDIA_TYPE;
};

const nonVideoBidder = bid => !videoAdapters.includes(bid.bidder);
export const hasNonVideoBidder = adUnit =>
adUnit.bids.filter(nonVideoBidder).length;
Expand Down
20 changes: 20 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,26 @@ describe('Unit: Prebid Module', function () {
adaptermanager.videoAdapters = videoAdaptersBackup;
});

it('should not callBids if a video adUnit defined with mediaTypes has non-video bidders', () => {
sinon.spy(adaptermanager, 'callBids');
const videoAdaptersBackup = adaptermanager.videoAdapters;
adaptermanager.videoAdapters = ['appnexusAst'];
const adUnits = [{
code: 'adUnit-code',
mediaTypes: {video: {context: 'instream'}},
bids: [
{bidder: 'appnexus', params: {placementId: 'id'}},
{bidder: 'appnexusAst', params: {placementId: 'id'}}
]
}];

$$PREBID_GLOBAL$$.requestBids({adUnits});
sinon.assert.notCalled(adaptermanager.callBids);

adaptermanager.callBids.restore();
adaptermanager.videoAdapters = videoAdaptersBackup;
});

it('should callBids if a video adUnit has all video bidders', () => {
sinon.spy(adaptermanager, 'callBids');
const videoAdaptersBackup = adaptermanager.videoAdapters;
Expand Down