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

Teads adapter: handle video playerSize #3423

Merged

Conversation

valsouche
Copy link

Type of change

  • Bugfix

Description of change

Change the way to get sizes. Now we check if playerSize is available before others.
Add tests about sizes.

  • test parameters for validating bids
{
  bidder: 'teads',
  params: {
    pageId: 89489,
    placementId: 96888
  }
}

@muuki88
Copy link
Collaborator

muuki88 commented Jan 8, 2019

Fixes #3373

Copy link
Collaborator

@muuki88 muuki88 left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks @valsouche ❤️

let sizes;
if (isVideoBid(bid)) {
sizes = utils.deepAccess(bid, 'mediaTypes.video.playerSize') ||
utils.deepAccess(bid, 'mediaTypes.video.sizes') ||
Copy link
Collaborator

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 😂

Copy link
Author

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...
capture d ecran 2019-01-08 a 14 45 49

Copy link
Collaborator

@robertrmartinez robertrmartinez Jan 10, 2019

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.

Copy link
Collaborator

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 😘

Copy link
Collaborator

@robertrmartinez robertrmartinez left a 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

let sizes;
if (isVideoBid(bid)) {
sizes = utils.deepAccess(bid, 'mediaTypes.video.playerSize') ||
utils.deepAccess(bid, 'mediaTypes.video.sizes') ||
Copy link
Collaborator

@robertrmartinez robertrmartinez Jan 10, 2019

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 = {
Copy link
Collaborator

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!

Copy link
Collaborator

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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!

Copy link
Author

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

Copy link
Author

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 !

Copy link
Collaborator

@robertrmartinez robertrmartinez left a comment

Choose a reason for hiding this comment

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

@valsouche

As it stands this works, but take a look at the suggestions and let me know what you think

if (isVideoBid(bid)) {
if (isHybridBid(bid)) {
sizes = concatHybridBidSizes(bid);
} else if (isVideoBid(bid)) {
Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Author

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 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense 😃

Copy link
Collaborator

@robertrmartinez robertrmartinez left a comment

Choose a reason for hiding this comment

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

Awesome!

LGTM!

@robertrmartinez robertrmartinez merged commit 3a44263 into prebid:master Jan 15, 2019
pedrolopezmrf pushed a commit to Marfeel/Prebid.js that referenced this pull request Mar 18, 2019
* Teads adapter: handle playerSize

* Handle multiple mediatypes sizes

* Clean sizes logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants