Skip to content

Commit

Permalink
allow video cacheKey for outstream (prebid#8833)
Browse files Browse the repository at this point in the history
  • Loading branch information
renebaudisch authored and JacobKlein26 committed Feb 8, 2023
1 parent 3aa1714 commit 91c0f70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@ function tryAddVideoBid(auctionInstance, bidResponse, afterBidAdded, {index = au
transactionId: bidResponse.transactionId
}), 'video');
const context = videoMediaType && deepAccess(videoMediaType, 'context');
const useCacheKey = videoMediaType && deepAccess(videoMediaType, 'useCacheKey');

if (config.getConfig('cache.url') && context !== OUTSTREAM) {
if (config.getConfig('cache.url') && (useCacheKey || context !== OUTSTREAM)) {
if (!bidResponse.videoCacheKey || config.getConfig('cache.ignoreBidderCacheKey')) {
addBid = false;
callPrebidCache(auctionInstance, bidResponse, afterBidAdded, videoMediaType);
Expand Down
9 changes: 5 additions & 4 deletions src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ export const hasNonVideoBidder = adUnit =>
export function isValidVideoBid(bid, {index = auctionManager.index} = {}) {
const videoMediaType = deepAccess(index.getMediaTypes(bid), 'video');
const context = videoMediaType && deepAccess(videoMediaType, 'context');
const useCacheKey = videoMediaType && deepAccess(videoMediaType, 'useCacheKey');
const adUnit = index.getAdUnit(bid);

// if context not defined assume default 'instream' for video bids
// instream bids require a vast url or vast xml content
return checkVideoBidSetup(bid, adUnit, videoMediaType, context);
return checkVideoBidSetup(bid, adUnit, videoMediaType, context, useCacheKey);
}

export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaType, context) {
if (videoMediaType && context !== OUTSTREAM) {
export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaType, context, useCacheKey) {
if (videoMediaType && (useCacheKey || context !== OUTSTREAM)) {
// xml-only video bids require a prebid cache url
if (!config.getConfig('cache.url') && bid.vastXml && !bid.vastUrl) {
logError(`
Expand All @@ -57,7 +58,7 @@ export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaT
}

// outstream bids require a renderer on the bid or pub-defined on adunit
if (context === OUTSTREAM) {
if (context === OUTSTREAM && !useCacheKey) {
return !!(bid.renderer || (adUnit && adUnit.renderer) || videoMediaType.renderer);
}

Expand Down

0 comments on commit 91c0f70

Please sign in to comment.