-
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
Teads adapter: handle video playerSize #3423
Teads adapter: handle video playerSize #3423
Conversation
Fixes #3373 |
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.
Awesome! Thanks @valsouche ❤️
modules/teadsBidAdapter.js
Outdated
let sizes; | ||
if (isVideoBid(bid)) { | ||
sizes = utils.deepAccess(bid, 'mediaTypes.video.playerSize') || | ||
utils.deepAccess(bid, 'mediaTypes.video.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.
I'm still not convinced that mediaTypes.video.sizes
is a supported property 😂
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.
PlayerSize is optional, bid.sizes is the default and as you we are not sure about mediaTypes.video.sizes
(We didn't find any line code about this property in the sources) but there is an adUnit section in the Prebid documentation which makes us doubt (see my screen). That is the reason why we preferred to add this check anyway...
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.
FWIW Prebid will expose whatever the user puts in the adUnit.mediaTypes.video
object to the adapters.
So if a publisher is using Teads and has an ad unit like so:
{
code: 'test_div_1',
mediaTypes: {
video: {
playerSize: [400, 600],
sizes: [400, 600]
}
}
...... etc
Then both playerSize
and sizes
will be available to pick from.
The only caveat is that PBJS standardizes the playerSize to be the common array of size arrays if a single size array is passed in. (Like the example I just gave)
What this means is that the adapter would see an object with those two fields like so:
{
...
playerSize: [ [400, 600] ],
sizes: [400, 600]
...
}
We have noticed some publishers are pretty loose with declaring their sizes as a single array, or the recommended array of size arrays.
From what it looks like this scenario works just fine in this PR.
This adapter calls utils.parseSizesInput
(which is nice) after this so even if a publisher uses adUnit.mediaTypes.video.sizes
instead of playerSize
, it will handle accordingly and return the gpt standard array of ['40x60']
Just figured I would bring that up.
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 clarifying this. Even js is untyped, I pretend it is 😉 and try to avoid ambiguous variables. This fix was necessary as some internal behavior of adunit.sizes
changed and the playerSize
was not used anymore. That's why highlighted this in this PR.
When I searched the code for sizes
related functions, I got really confused as there are multiple representations (as you mentioned single-size array and array of size arrays, but also the <witdh>x<height>
arrays) and various parsing methods.
Hope this implementation will last ❤️ Thanks @valsouche for taking care 😘
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.
If logic is fine with multi-format comment below, then LGTM
modules/teadsBidAdapter.js
Outdated
let sizes; | ||
if (isVideoBid(bid)) { | ||
sizes = utils.deepAccess(bid, 'mediaTypes.video.playerSize') || | ||
utils.deepAccess(bid, 'mediaTypes.video.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.
FWIW Prebid will expose whatever the user puts in the adUnit.mediaTypes.video
object to the adapters.
So if a publisher is using Teads and has an ad unit like so:
{
code: 'test_div_1',
mediaTypes: {
video: {
playerSize: [400, 600],
sizes: [400, 600]
}
}
...... etc
Then both playerSize
and sizes
will be available to pick from.
The only caveat is that PBJS standardizes the playerSize to be the common array of size arrays if a single size array is passed in. (Like the example I just gave)
What this means is that the adapter would see an object with those two fields like so:
{
...
playerSize: [ [400, 600] ],
sizes: [400, 600]
...
}
We have noticed some publishers are pretty loose with declaring their sizes as a single array, or the recommended array of size arrays.
From what it looks like this scenario works just fine in this PR.
This adapter calls utils.parseSizesInput
(which is nice) after this so even if a publisher uses adUnit.mediaTypes.video.sizes
instead of playerSize
, it will handle accordingly and return the gpt standard array of ['40x60']
Just figured I would bring that up.
}); | ||
|
||
it('should use good mediaTypes video playerSizes', function() { | ||
const mediaTypesPlayerSize = { |
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.
Also just want to confirm:
If a publisher requests a multi-format adUnit with banner and video, teads will default to Video and try to get the sizes from the video object.
Just want to confirm this is intended and there is no logic necessary for teads' approach to multiformat requests.
From a glance it does not look like mediaType is passed into the Teads Ad request anyways, but want to be sure that in this scenario, the behavior is as expected!
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.
ex:
{
mediaTypes: {
video: {
playerSize: [400, 600]
}
banner: {
sizes: [[300, 250], [728, 90]]
}
}
Some adapters do a multi-format call with both, some default to just video, some to banner.
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.
Very good point! Teads does offer some special formats like parallax ads, which may come with another size. Should video
and banner
sizes simply be concatenated?
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.
That is hard to say without knowing the Teads Ad Exchange or what they tell customers about their implementation.
I think coming up with what the Teads approach to multi-format adUnits is would be a good start.
Maybe concatenating is the solution, maybe having one of the mediaTypes be higher priority (as video is in this current implementation)
Not sure!
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.
Good point,
we prefer receive all sizes, so we will concatenate. I'll push the update soon. Thanks
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.
Done. :) Don't hesitate to ask if you find something weird.
Thanks !
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.
As it stands this works, but take a look at the suggestions and let me know what you think
modules/teadsBidAdapter.js
Outdated
if (isVideoBid(bid)) { | ||
if (isHybridBid(bid)) { | ||
sizes = concatHybridBidSizes(bid); | ||
} else if (isVideoBid(bid)) { |
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.
Have a couple comments / suggestions:
With this current implementation a multi-format ad unit will add video.sizes
and video.playerSize
.
But if it is just a video mediaType, then it picks video.playerSize
OR video.sizes
. Not sure if it is better to remain consistent and just concatenate in this scenario as well?
Or maybe in concatHybridBidSizes
add the logic to choose video.playerSize
OR video.sizes
.
Also, instead of checking the isHybridBid
or isVideoBid
=> else
, does it make sense to just use the concatHybridBidSizes
and not do any mediaTypes checking?
Since you are using utils.deepAccess
to get the mediaTypes Sizes, then if the mediaType is not present, it will do what is needed anyways right?
so getSizes
could just be something like:
function getSizes(bid) {
return utils.parseSizesInput(concatHybridBidSizes(bid));
}
And if needed add the video.playerSize
|| video.sizes
logic, if that is the intended implementation.
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.
CC @muuki88 for some input as well
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.
Exact ! I did the change, simpler and cleaner :)
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.
Makes sense 😃
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.
Awesome!
LGTM!
* Teads adapter: handle playerSize * Handle multiple mediatypes sizes * Clean sizes logic
Type of change
Description of change
Change the way to get sizes. Now we check if playerSize is available before others.
Add tests about sizes.