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

Add support for OpenRTB protocol and endpoint #2102

Merged
merged 13 commits into from
Feb 20, 2018
Merged

Conversation

matthewlane
Copy link
Collaborator

@matthewlane matthewlane commented Feb 3, 2018

Type of change

  • Feature

Description of change

Adds support to prebidServer adapter for working with the OpenRTB prebid-server endpoint. Enable support by configuring s2s to use an endpoint with the pattern openrtb2/auction:

pbjs.setConfig({
  debug: true,
  s2sConfig: {
    accountId: '123',
    enabled: true,
    bidders: ['appnexus'],
    endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction',
  },
});

When s2sConfig.endpoint is not configured to this type of endpoint, prebidServer communicates with the configured endpoint using the existing s2s protocol.

Other information

Fixes #2126

@bretg
Copy link
Collaborator

bretg commented Feb 12, 2018

What's the status on this -- is it ready for review @matthewlane ?

@matthewlane
Copy link
Collaborator Author

@bretg Yes, status is ready for review

@bretg
Copy link
Collaborator

bretg commented Feb 12, 2018

Cool. Added the Needs Docs label as well. Ought to have page on prebid.org somewhere describing the different endpoints.

Will the legacy endpoint be phased out at some point?

@matthewlane
Copy link
Collaborator Author

I'll work on a docs draft. Not sure on legacy endpoint being phased out or timing, ccing @mkendall07 @dbemiller for comment

@dbemiller
Copy link
Contributor

dbemiller commented Feb 13, 2018

Legacy endpoint will definitely be phased out... but no specific timeline yet. I'd planned to get rid of it once the metrics said that the traffic was low enough (and Rubicon agreed, and we left the PR deleting them open for a week or so in case anyone else wanted to complain).

I haven't been using prebid.org at all, because I find jekyll to be annoying and I think there's a lot of value in keeping the docs in the same repo as the code... but there's documentation for some of the endpoints here. The folder structure & filenames of .md files mirror the endpoints on PBS. /cookie_sync is not documented yet, but should be. We should probably include that during work on prebid/prebid-server#341.

We should definitely update these two pages, though:

Once prebid.js uses /openrtb2/auction, there will be no value in a buyer implementing a legacy adapter anymore.

Copy link
Collaborator

@snapwich snapwich left a comment

Choose a reason for hiding this comment

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

Overall looking pretty good. I have some questions and nitpicks that I left.

*/
const protocolAdapter = () => {
const OPEN_RTB_PATH = 'openrtb2/auction';
const isOpenRtb = _s2sConfig.endpoint.includes(OPEN_RTB_PATH);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is polyfilled. Either way, it's probably safer using a regex or something to validate that this is at the end of the endpoint.

Copy link
Collaborator Author

@matthewlane matthewlane Feb 15, 2018

Choose a reason for hiding this comment

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

One of the legacy test pages I found originally had an endpoint configured like https://prebid.adnxs.com/pbs/v1/auction?url_override=..., so checking for the end of the string might not work. Good point about the polyfill, updated to use old school indexOf rather than the string version of includes

if (digiTrust) {
requestJson.digiTrust = digiTrust;
request.digiTrust = digiTrust;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens to this app, device, digiTrust, etc stuff if we use the OpenRTB endpoint? Can we pass it as ext data?

Copy link
Collaborator Author

@matthewlane matthewlane Feb 15, 2018

Choose a reason for hiding this comment

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

Good question, will find out

Edit: yes, these are supported by the OpenRTB endpoint, pushed an update to send them

if (bannerParams && bannerParams.sizes) {
// get banner sizes in form [{ w: <int>, h: <int> }, ...]
const format = bannerParams.sizes.reduce((acc, size) =>
[...acc, { w: size[0], h: size[1] }], []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a perfect candidate for Array#map, is there a reason for using reduce? Also, I think creating a new array on each iteration of the reduce is less than ideal for performance.


// get bidder params in form { <bidder code>: {...params} }
const ext = adUnit.bids.reduce((acc, bid) =>
Object.assign({}, acc, { [bid.bidder]: bid.params }), {});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same performance complaint as a above.

const ext = adUnit.bids.reduce((acc, bid) => {
	acc[bid.bidder] = bid.params;
	return acc;
}, {})

In my opinion this is more readable, but opinion aside it's definitely going to perform much better as it's not doing additional iteration per each loop (each arg passed to Object.assign is extra iteration) and not instantiating a bunch of throwaway object literals.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, totally blanked on the way of doing this, thanks, updated

Copy link
Member

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

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

@matthewlane
When I test this using our hello world page and the new ORTB endpoint, I receive the following error from PBS:
Invalid request format: request.imp[%d] must contain at least one of "banner", "video", "audio", or "native"

Request payload that generated the error:

{
	"id": "44cb5fb9-33d8-4767-978e-d2be5819225c",
	"site": {
		"publisher": {
			"id": "c9d412ee-3cc6-4b66-9326-9f49d528f13e"
		}
	},
	"source": {
		"tid": "44cb5fb9-33d8-4767-978e-d2be5819225c"
	},
	"tmax": 1000,
	"imp": [{
		"id": "div-gpt-ad-1460505748561-0",
		"ext": {
			"appnexus": {
				"placementId": 10433394
			}
		},
		"secure": 0
	}],
	"test": 0
}

@matthewlane
Copy link
Collaborator Author

@mkendall07 Thanks, updated to default to banner when mediaTypes is not defined, please test again

const OPEN_RTB_PATH = 'openrtb2/auction';

const endpoint = (_s2sConfig && _s2sConfig.endpoint) || '';
const isOpenRtb = ~endpoint.indexOf(OPEN_RTB_PATH);
Copy link
Member

Choose a reason for hiding this comment

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

nice operator usage :)

Copy link
Member

@mkendall07 mkendall07 left a comment

Choose a reason for hiding this comment

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

Looks great, nice work

@mkendall07 mkendall07 merged commit a455757 into master Feb 20, 2018
@mkendall07 mkendall07 deleted the openrtb-protocol branch February 20, 2018 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants