-
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
Add support for backupOnly
option in mediaType video renderer
#5972
Conversation
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.
MR looks ok, can you just refactor condition I already mention in one of the comments?
Also, do we have some example page to test this, or some documentation? I tried testing it on my local by creating some custom html pages, but I couldn't do it.
src/Renderer.js
Outdated
return !!(adUnit && | ||
( | ||
(adUnit.renderer && adUnit.renderer.url && adUnit.renderer.render && !(utils.isBoolean(adUnit.renderer.backupOnly) && adUnit.renderer.backupOnly)) || | ||
(adUnit.mediaTypes && adUnit.mediaTypes.video && adUnit.mediaTypes.video.renderer.url && adUnit.mediaTypes.video.renderer.render && | ||
!(utils.isBoolean(adUnit.mediaTypes.video.renderer.backupOnly) && adUnit.mediaTypes.video.renderer.backupOnly)) | ||
) | ||
); |
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.
Can you break down this?
It is not readable, I think breaking it down in multiple if
s would help. It took me a lot of time to decode this entire condition.
Just a small hint, you can replace:
utils.isBoolean(adUnit.renderer.backupOnly) && adUnit.renderer.backupOnly
with:
adUnit.renderer.backupOnly === true
src/auction.js
Outdated
@@ -533,7 +533,7 @@ function getPreparedBidForAuction({adUnitCode, bid, bidderRequest, auctionId}) { | |||
var renderer = null; | |||
|
|||
// the renderer for the mediaType takes precendence | |||
if (mediaTypeRenderer && mediaTypeRenderer.url && mediaTypeRenderer.render) { | |||
if (mediaTypeRenderer && mediaTypeRenderer.url && !(mediaTypeRenderer.backupOnly && isBoolean(mediaTypeRenderer.backupOnly) && mediaTypeRenderer.render)) { |
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.
Same hint here, you can replace:
mediaTypeRenderer.backupOnly && isBoolean(mediaTypeRenderer.backupOnly)
with:
mediaTypeRenderer.backupOnly === true
You don't have to change it, I'm just making a suggestion how to make this if
condition a bit shorter.
2a20b4b
to
993ad37
Compare
@FilipStamenkovic, regarding your comment I tried to improve readability especially in the Please let me know. |
I didn't notice about your ask for documentation. In fact the documentation already exists : https://docs.prebid.org/dev-docs/show-outstream-video-ads.html#renderers
About testing, I didn't found a test page for an outstream video adUnit that I could extends. If you really need it I can try to build a full page for it, but I'm not sure it is really usefull as it depends of adapters specificities. |
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.
LGTM
993ad37
to
2ffe71c
Compare
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.
Thanks for this bugfix. This change looks good.
…id#5972) * Add support for `backupOnly` option in mediaType video renderer * Improve readability
Type of change
Description of change
When a publisher set a Renderer for an adUnit (outstream context), the official documentation explains the publisher can set
backupOnly: true
to prefer the buyer or adapter renderer.This options only works when the renderer is defined at the "adUnit" level.
This PR just add the support for the
backupOnly
option at the "mediaTypes.video" level.