-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
allow outstream video, remove parsePosition method, simplify code #2683
Changes from 2 commits
0ad6cfd
f05e790
1c872b6
94e337b
71c486c
6200e66
2c8a204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,32 +93,33 @@ export const spec = { | |
return false; | ||
} | ||
|
||
// Log warning if context is 'outstream', is not currently supported | ||
if (utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`) === 'outstream') { | ||
utils.logWarn('Warning: outstream video for Rubicon Client Adapter is not supported yet'); | ||
} | ||
|
||
// Log warning if mediaTypes contains both 'banner' and 'video' | ||
if (spec.hasVideoMediaType(bid) && typeof utils.deepAccess(bid, `mediaTypes.${BANNER}`) !== 'undefined') { | ||
utils.logWarn('Warning: instream video and banner requested for same ad unit, continuing with video instream request'); | ||
} | ||
|
||
// Bid is invalid if legacy video is set but params video is missing size_id | ||
if (bid.mediaType === 'video' && typeof utils.deepAccess(bid, 'params.video.size_id') === 'undefined') { | ||
return false; | ||
} | ||
|
||
// Bid is invalid if mediaTypes video is invalid and a mediaTypes banner property is not defined | ||
if (bid.mediaTypes && !spec.hasVideoMediaType(bid) && typeof bid.mediaTypes.banner === 'undefined') { | ||
if (hasVideoMediaType(bid)) { | ||
// Log warning if mediaTypes contains both 'banner' and 'video' | ||
if (utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`) === 'instream') { | ||
if (typeof utils.deepAccess(bid, `mediaTypes.${BANNER}`) !== 'undefined') { | ||
utils.logWarn('Warning: instream video and banner requested for same ad unit, continuing with video instream request'); | ||
} | ||
// Bid is invalid if video is set but params video is missing size_id | ||
if (typeof utils.deepAccess(bid, 'params.video.size_id') === 'undefined') { | ||
utils.logError('Error: size id is missing for instream video request.'); | ||
return false; | ||
} | ||
return true; | ||
} else if (utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`) === 'outstream') { | ||
if (utils.deepAccess(bid, 'params.video.size_id') !== 203) { | ||
utils.logWarn('Warning: outstream video is sending invalid size id, converting size id to 203.'); | ||
} | ||
return true; | ||
} | ||
// video context is neither instream nor outstream | ||
utils.logError('Error: video context is neither instream nor outstream.'); | ||
return false; | ||
} | ||
|
||
let parsedSizes = parseSizes(bid); | ||
if (parsedSizes.length < 1) { | ||
} else if (bid.mediaTypes && typeof utils.deepAccess(bid, `mediaTypes.${BANNER}`) === 'undefined') { | ||
// Bid is invalid if mediaTypes video is invalid and a mediaTypes banner property is not defined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Let me know if I am missing something, but I would think we want to still continue with banner if mediaTypes is declared but banner is not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adUnit.sizes will eventually be deprecated, but we still are allowing it for now, and should continue to do so as long as Prebid Core does. |
||
return false; | ||
} | ||
|
||
return true; | ||
return parseSizes(bid).length > 0; | ||
}, | ||
/** | ||
* @param {BidRequest[]} bidRequests | ||
|
@@ -128,7 +129,7 @@ export const spec = { | |
buildRequests: function (bidRequests, bidderRequest) { | ||
// separate video bids because the requests are structured differently | ||
let requests = []; | ||
const videoRequests = bidRequests.filter(spec.hasVideoMediaType).map(bidRequest => { | ||
const videoRequests = bidRequests.filter(hasVideoMediaType).map(bidRequest => { | ||
bidRequest.startTime = new Date().getTime(); | ||
|
||
let params = bidRequest.params; | ||
|
@@ -150,14 +151,14 @@ export const spec = { | |
let slotData = { | ||
site_id: params.siteId, | ||
zone_id: params.zoneId, | ||
position: parsePosition(params.position), | ||
position: params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why undo this? I think this logic was purposely moved into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to follow openRTB standard and remove parsePosition for video: after the video endpoint migrated to PBS Java openRTB, the new endpoint runs auction with OpenRTB 2.5 bid request, which uses integer values for ads position. |
||
floor: parseFloat(params.floor) > 0.01 ? params.floor : 0.01, | ||
element_id: bidRequest.adUnitCode, | ||
name: bidRequest.adUnitCode, | ||
language: params.video.language, | ||
width: size[0], | ||
height: size[1], | ||
size_id: params.video.size_id | ||
size_id: utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}.context`) === 'outstream' ? 203 : params.video.size_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are setting the Above at line 102 we reject a video bid request if it does not contain So are we requiring that anyone who uses outstream with us place Looks to me like if we are just always changing it to |
||
}; | ||
|
||
if (params.inventory && typeof params.inventory === 'object') { | ||
|
@@ -192,7 +193,7 @@ export const spec = { | |
|
||
if (config.getConfig('rubicon.singleRequest') !== true) { | ||
// bids are not grouped if single request mode is not enabled | ||
requests = videoRequests.concat(bidRequests.filter(bidRequest => !spec.hasVideoMediaType(bidRequest)).map(bidRequest => { | ||
requests = videoRequests.concat(bidRequests.filter(bidRequest => !hasVideoMediaType(bidRequest)).map(bidRequest => { | ||
const bidParams = spec.createSlotParams(bidRequest, bidderRequest); | ||
return { | ||
method: 'GET', | ||
|
@@ -207,7 +208,7 @@ export const spec = { | |
} else { | ||
// single request requires bids to be grouped by site id into a single request | ||
// note: utils.groupBy wasn't used because deep property access was needed | ||
const nonVideoRequests = bidRequests.filter(bidRequest => !spec.hasVideoMediaType(bidRequest)); | ||
const nonVideoRequests = bidRequests.filter(bidRequest => !hasVideoMediaType(bidRequest)); | ||
const groupedBidRequests = nonVideoRequests.reduce((groupedBids, bid) => { | ||
(groupedBids[bid.params['siteId']] = groupedBids[bid.params['siteId']] || []).push(bid); | ||
return groupedBids; | ||
|
@@ -297,7 +298,7 @@ export const spec = { | |
'zone_id': params.zoneId, | ||
'size_id': parsedSizes[0], | ||
'alt_size_ids': parsedSizes.slice(1).join(',') || undefined, | ||
'p_pos': parsePosition(params.position), | ||
'p_pos': params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', | ||
'rp_floor': (params.floor = parseFloat(params.floor)) > 0.01 ? params.floor : 0.01, | ||
'rp_secure': isSecure() ? '1' : '0', | ||
'tk_flint': INTEGRATION, | ||
|
@@ -340,17 +341,6 @@ export const spec = { | |
return data; | ||
}, | ||
|
||
/** | ||
* Test if bid has mediaType or mediaTypes set for video. | ||
* note: 'mediaType' has been deprecated, however support will remain for a transitional period | ||
* @param {BidRequest} bidRequest | ||
* @returns {boolean} | ||
*/ | ||
hasVideoMediaType: function (bidRequest) { | ||
return (typeof utils.deepAccess(bidRequest, 'params.video.size_id') !== 'undefined' && | ||
(bidRequest.mediaType === VIDEO || utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}.context`) === 'instream')); | ||
}, | ||
|
||
/** | ||
* @param {*} responseObj | ||
* @param {BidRequest|Object.<string, BidRequest[]>} bidRequest - if request was SRA the bidRequest argument will be a keyed BidRequest array object, | ||
|
@@ -368,7 +358,7 @@ export const spec = { | |
let ads = responseObj.ads; | ||
|
||
// video ads array is wrapped in an object | ||
if (typeof bidRequest === 'object' && !Array.isArray(bidRequest) && spec.hasVideoMediaType(bidRequest) && typeof ads === 'object') { | ||
if (typeof bidRequest === 'object' && !Array.isArray(bidRequest) && hasVideoMediaType(bidRequest) && typeof ads === 'object') { | ||
ads = ads[bidRequest.adUnitCode]; | ||
} | ||
|
||
|
@@ -504,7 +494,7 @@ function _renderCreative(script, impId) { | |
|
||
function parseSizes(bid) { | ||
let params = bid.params; | ||
if (spec.hasVideoMediaType(bid)) { | ||
if (hasVideoMediaType(bid)) { | ||
let size = []; | ||
if (params.video && params.video.playerWidth && params.video.playerHeight) { | ||
size = [ | ||
|
@@ -518,7 +508,7 @@ function parseSizes(bid) { | |
} | ||
|
||
// deprecated: temp legacy support | ||
let sizes = Array.isArray(params.sizes) ? params.sizes : mapSizes(bid.sizes) | ||
let sizes = Array.isArray(params.sizes) ? params.sizes : mapSizes(bid.sizes); | ||
|
||
return masSizeOrdering(sizes); | ||
} | ||
|
@@ -535,11 +525,14 @@ function mapSizes(sizes) { | |
}, []); | ||
} | ||
|
||
function parsePosition(position) { | ||
if (position === 'atf' || position === 'btf') { | ||
return position; | ||
} | ||
return 'unknown'; | ||
/** | ||
* Test if bid has mediaType or mediaTypes set for video. | ||
* note: 'mediaType' has been deprecated, however support will remain for a transitional period | ||
* @param {BidRequest} bidRequest | ||
* @returns {boolean} | ||
*/ | ||
export function hasVideoMediaType(bidRequest) { | ||
return bidRequest.mediaType === VIDEO || typeof utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}`) !== 'undefined'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So But in the Validations we return false if mediaTypes.video.context is neither instream or outstream? (Line 115) Am I missing something or would a legacy video bid where mediaType == 'video' no longer ever work because of this? |
||
} | ||
|
||
export function masSizeOrdering(sizes) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@idettman can you review this? not sure if this is undoing the work you've done recently with the mediaTypes.