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

Prebid Core: switch native assets to ortb2 format #7847

Closed

Conversation

FilipStamenkovic
Copy link
Contributor

Type of change

  • Feature

Description of change

Change from prebid 'standard' of defining native assets to openRTB 1.2 standard.
Instead of sponsoredBy, image, icon, we would have openRTB equivalents:

  • { data: { type: 1 }}
  • { img: { type: 3 }}
  • { img: { type: 1 }}

This will help standardize prebid native. Also, a lot of bidders are sending ortb2 requests on their back end, so at the moment, they are converting bid request from prebid to openRTB standard and later they are converting bid responses from openRTB to prebid standard. With this approach a lot of duplicated code between the bidders can be removed.

Backwards compatibility

When this PR is merged, we will still have backwards compatibility. Which mean, nothing will break for the existing native bidders. That will give us some time until all bidders adjust their code

Other information

This PR resolves #7830 issue.

@FilipStamenkovic FilipStamenkovic added feature needs review native needs 2nd review Core module updates require two approvals from the core team labels Dec 10, 2021
@FilipStamenkovic
Copy link
Contributor Author

I also created an example how this will look like on the test page. I used pubwise bidder, because that's the only bidder I found that is always returning to me test native bid.

Code how that would look like can be found on my local repo

src/native.js Outdated

const match = requiredAssetIds.every(assetId => includes(returnedAssetIds, assetId));
if (!match) {
logError(`didn't receive a bit with all required assets. Required ids: ${requiredAssetIds}, but received ids in response: ${returnedAssetIds}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: bit should be bid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this

Copy link
Contributor

@Fawke Fawke left a comment

Choose a reason for hiding this comment

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

Hi,

The changes look fine at a first glance, but I do not see any docs PR associated with it. If Native now supports OpenRTB params, then I think we should document it with proper examples.

Also, I do see an associated PR for Prebid Universal Creative. Does that take of the rendering if new ortb fields are used?

@FilipStamenkovic
Copy link
Contributor Author

@Fawke

Thanks for the review.
I didn't open any docs PR, my plan was to open first changes to the code, so that reviewers can take a look at proposed approach how to switch to openRTB for native ads. If everything is ok I will also open docs PR.

@bretg
Copy link
Collaborator

bretg commented Jan 5, 2022

@FilipStamenkovic - we're going to need an update to the prebidServerBidAdapter. Currently it's mapping the prebid-specific attributes to ortb2. It should check for the existence of this new format first and merge them in. Thanks.

@FilipStamenkovic
Copy link
Contributor Author

@bretg I was thinking to do pbs adapter changes in separate PR not in this one. But, if you think it's ok to add pbs changes in this PR I'll do it then?

@bretg
Copy link
Collaborator

bretg commented Jan 6, 2022

I'd say go for it @FilipStamenkovic

@FilipStamenkovic
Copy link
Contributor Author

@bretg I included pbs changes in the PR. I didn't implement 'merge strategy' between old way and ortb format.
I decided to go with approach: if mediaTypes.native.ortb is present use it, if not fallback to the current approach.

body: {required: false},
icon: {required: false},
});
expect(nativeRequest.ortb.assets).to.deep.equal([
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't we want to have a test case of old native request as well? It should be able to accept either, if ortb is set go with that if not use old, right? Maybe it's too much to ask or it is already covered in another test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already covered in another test.
Basically all existing native tests rely on 'old native way'.
But, if you feel like this PR needs more tests, I'll add them?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's covered in another test, then that works!

@Rothalack
Copy link
Collaborator

I think this just needs your approval for the Docs PR change request @Fawke

@@ -63,6 +63,11 @@ export function receiveMessage(ev) {
} else if (data.action === 'allAssetRequest') {
const message = getAllAssetsMessage(data, adObject);
ev.source.postMessage(JSON.stringify(message), ev.origin);
// if there is an ortb object inside native, puc won't send postMessage to trigger impression tracker, in that case marking bid as winning
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be better to move this to the top, if any message with an adId comes in, it means that adId has won the auction, no? you'll need some logic to avoid duplicating the event but IMO that's better than two different ways to mark the bid won (or three if you count the non-native case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't move it to the top because of backwards compatibility.
This code needs to work with 'old native' and with ORTB native.
If I move it to the top, in case of 'old native' we would have duplicated events, because in 'old native' handleNativeRequest() function is executed on many different occasions:

  • native ad was rendered
  • native ad needs to be resized
  • native ad was clicked on
  • etc.

Once native ORTB is fully adopted in the prebid we can then remove a lot of duplicated code that is simply there because of backwards compatibility.

P.S.
When I say 'old native' I mean what is currently there on master branch for native ads.

Copy link
Collaborator

@dgirardi dgirardi Jan 25, 2022

Choose a reason for hiding this comment

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

I mean something like -

const BID_WONS = new WeakMap();

function receiveMessage(ev) {
 // ...
 if !BID_WONS.has(adObject) {
    BID_WONS.set(adObject, true);
    // ... trigger event
 }
 // message handling
}

the issue I have with a "temporary" solution like the one here is that 1) it will be a long long time before we can remove the "legacy" protocol and 2) it's easy to break by accident during that time... if for example the safeframe decides to request single assets instead of all, or some new tracker message is added for the native ortb2 case, the committer is probably not thinking about the bid won event. And to me it seems easy to decide "if a frame has the adId, that always means it has won the auction, we can just mark the bid won right at the beginning".

Copy link
Contributor Author

@FilipStamenkovic FilipStamenkovic Jan 25, 2022

Choose a reason for hiding this comment

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

code updated

@ChrisHuie
Copy link
Collaborator

Docs PR -> prebid/prebid.github.io#3497

Copy link
Collaborator

@osazos osazos left a comment

Choose a reason for hiding this comment

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

It is ok for me for the code review.
I added a comment in the doc PR.

@bretg
Copy link
Collaborator

bretg commented Feb 1, 2022

I hope I'm wrong here, but I think this PR is just the first step in a long journey. I believe that all 74 bid adapters that support native need to be updated to support this new format, right? i.e. in addition to looking in mediatypes.native.title, they need to look in mediatypes.native.ortb2.assets.title, right?

If that's the case, publishers can't change their pages until all the adapters they use support the new syntax.

@FilipStamenkovic
Copy link
Contributor Author

Yeah, this is just a first step, adapters would need to update their code.

It would not be mediaTypes.native.ortb2.assets.title.
It's ortb not ortb2 (because this PR is based on openRTB 1.2 Native specs, there is a link in the description). Also, assets contains array of objects, so to get titles (in theory one native ad can have multiple titles) you would need to do something like:

let titles = mediaTypes.native.ortb.assets.filter(asset => asset.hasOwnProperty('title'));

@bretg
Copy link
Collaborator

bretg commented Feb 2, 2022

Ok, discussed in today's PBJS meeting. We propose handling this native change in a way similar to how we handled the first party data change last year:

  1. Add some transition code (e.g. toOrtbNative) that maps old-style AdUnit native definitions to new-style.
  2. Create a transition function (e.g. fromOrtbNative) that bid adapters can use to translate the new-style native definition back to the old-style. This is a lossy transition and would only support whatever fields are currently covered by the proprietary format.
  3. Update all 74 native-capable bid adapters to call fromOrtbNative() at the top of buildRequests. Then we communicate with them to start the process of converting their adapters to not need fromOrtbNative().

FWIW, I poked around a couple of adapters: one had a complicated bunch of code for mapping native params and the other seemed to wrap it all up and parse server-side. So this transition may take a while.

Documentation-wise, the proposal is:

  • produce a new document that is the recommended way that new native implementations should be done.
  • leave the current doc in place but warn that new implementations should be done in the ortb-way
  • hide the old-old doc away, making it more clear that no one should be using that (sendId) approach anymore.

@ChrisHuie ChrisHuie removed the request for review from Fawke February 3, 2022 14:03
@musikele
Copy link
Contributor

Closing this one and continuing the work in #8086 .

@musikele musikele closed this Feb 18, 2022
@FilipStamenkovic FilipStamenkovic deleted the native_assets_ortb2 branch August 4, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature native needs review needs 2nd review Core module updates require two approvals from the core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prebid Native: switch to openRTB for native
8 participants