-
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
Prebid Core: switch native assets to ortb2 format #7847
Prebid Core: switch native assets to ortb2 format #7847
Conversation
I also created an example how this will look like on the test page. I used 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}`); |
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.
Typo: bit
should be 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.
I fixed this
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.
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?
Thanks for the review. |
@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. |
@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? |
I'd say go for it @FilipStamenkovic |
@bretg I included pbs changes in the PR. I didn't implement 'merge strategy' between old way and ortb format. |
186ba06
to
f4ed600
Compare
body: {required: false}, | ||
icon: {required: false}, | ||
}); | ||
expect(nativeRequest.ortb.assets).to.deep.equal([ |
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.
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.
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.
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?
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 it's covered in another test, then that works!
I think this just needs your approval for the Docs PR change request @Fawke |
src/secureCreatives.js
Outdated
@@ -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 |
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 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).
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 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.
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 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".
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.
code updated
d9ebecc
to
4ceed0f
Compare
Docs PR -> prebid/prebid.github.io#3497 |
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.
It is ok for me for the code review.
I added a comment in the doc PR.
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. |
Yeah, this is just a first step, adapters would need to update their code. It would not be let titles = mediaTypes.native.ortb.assets.filter(asset => asset.hasOwnProperty('title')); |
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:
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:
|
e9e7049
to
a649f89
Compare
Closing this one and continuing the work in #8086 . |
Type of change
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.