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

Update adapter to prebid v1.0 #1908

Merged
merged 9 commits into from
Jan 23, 2018

Conversation

Spacedragoon
Copy link
Contributor

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other

Description of change

Version 1.0 of the Smart Bidder Adapter, every mandatory params and optional params are the same as previous version

  • test parameters for validating bids
{
  sizes: [[320, 250]],
  bids: [{
    bidder: "smartadserver",
    params: {
      siteId: 32216,
      pageId: 881291,
      formatId: 13695,
      domain: 'http://prg.smartadserver.com'
    }
  }]
}

Be sure to test the integration with your adserver using the Hello World sample page.

Other information

adloader.loadScript(url.format(adCall));
}
// pull requested transaction ID from bidderRequest.bids[].transactionId
if (!Array.isArray(validBidRequests)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will always be an array, so this is unnecessary

siteid: bid.params.siteId,
pageid: bid.params.pageId,
formatid: bid.params.formatId,
currencyCode: config.getConfig('currency'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

'currency' is an object, do you mean 'currency.adServerCurrency'?

*/
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
if (serverResponse) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

serverResponse is now split into two properties. serverResponse.body and serverResponse.headers. I think you're wanting to get all the stuff off serverResponse.body here.

},
getUserSyncs: function (syncOptions) {
// iframe || image
return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're not using userSyncs, just don't include this function definition rather than returning undefined.

var bid = validBidRequests[0];
const payload = {
siteid: bid.params.siteId,
pageid: bid.params.pageId,
formatid: bid.params.formatId,
currencyCode: config.getConfig('currency'),
currencyCode: config.getConfig('currency').adServerCurrency,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should use config.getConfig('currency.adServerCurency') since the config module does safe deep access. The way you have it here if currency hasn't been set then it will throw "can't read adServerCurrency of undefined" error.

@Spacedragoon
Copy link
Contributor Author

Hello,
Any news about my last changes ?

@snapwich
Copy link
Collaborator

@Spacedragoon you have conflicts that need to be resolved

@Spacedragoon
Copy link
Contributor Author

Hello,
conflicts resolved.

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.

LGTM

Copy link
Collaborator

@matthewlane matthewlane left a comment

Choose a reason for hiding this comment

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

Are the test parameters in smartadserverBidAdapter.md still valid? Currently getting a 200 OK but empty response when using those for testing. Also one change requested below

if (response) {
const bidResponse = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
Copy link
Collaborator

Choose a reason for hiding this comment

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

bidderCode will be set automatically by bidderFactory now, this line can be dropped

@matthewlane
Copy link
Collaborator

@Spacedragoon Updates look, but still getting an empty response with the updated test parameters.

The way I'm testing is taking those params and putting them in the hello_world test page bids array, running gulp serve from the Prebid directory, and opening the test page in a browser. In the dev console, running pbjs.getBidResponses() returns an empty object, and in the network tab, the request to http://prg.smartadserver.com is 200 OK but the response is empty. Are you getting different results in this setup?

Once bid responses are verified this should be good for merge.

@Spacedragoon
Copy link
Contributor Author

Alright, it didn't work because i assumed the code here would work just by filling the blanks.

But the line requestId: bidRequest.bidId, in interpretResponse function puts undefined as a value in requestId if you follow the lines of the buildRequests function just above :
return { method: 'POST', url: ENDPOINT_URL, data: payloadString, };

It may be a good idea to review this part of the documentation

@snapwich
Copy link
Collaborator

snapwich commented Jan 8, 2018

Unfortunately the location the requestId comes from can't just be fill in the blank, because in reality in depends on your request architecture. For most, attaching the request containing the bidId to the server request and getting back in the response handler like shown is fine, but for people who have implemented some kind of single request architecture, they'll need to map their response back to the appropriate IDs.

The documentation doesn't describe that process very well, I'll see if I can update it to clarify what that id is and how to get it.

@matthewlane
Copy link
Collaborator

@Spacedragoon still getting no response data with the test parameters and updated code, with the setup described here, checking on this again so we can validate bid responses and get this merged

@Spacedragoon
Copy link
Contributor Author

Hello @matthewlane I tested it again here and it seems to work : you can see the response from our side, plus the bidResponses in pbjs.
image

Copy link
Collaborator

@matthewlane matthewlane left a comment

Choose a reason for hiding this comment

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

@Spacedragoon Ok, thanks. One more required change then will merge

var response = serverResponse.body;
if (response) {
const bidResponse = {
requestId: JSON.parse(bidRequest.data).bidId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any JSON.parse calls should be wrapped in a try/catch block

@Spacedragoon
Copy link
Contributor Author

@matthewlane Alright, done.

@matthewlane matthewlane merged commit 9b56b11 into prebid:master Jan 23, 2018
@matthewlane
Copy link
Collaborator

matthewlane commented Jan 23, 2018

Thanks, this is merged. Please also submit a PR to update your bidder file in the docs repo, to add the line prebid_1_0_supported: true to the header, and make any updates to the bidder params if necessary

@Spacedragoon
Copy link
Contributor Author

@matthewlane Thank you, the PR for the docs repo is now done here

Millerrok pushed a commit to Vertamedia/Prebid.js that referenced this pull request Jan 24, 2018
* 'master' of https://github.com/prebid/Prebid.js:
  Prebid 1.2.0 Release
  Use polyfilled includes method (prebid#2061)
  RockYou Adapter: Added RockYou Adapter supporting Prebid 1.0 (prebid#1977)
  Optimera Adapter for 1.0. (prebid#1961)
  Use cross-browser integer check (prebid#2058)
  Fix skipped test (prebid#2059)
  Support multiple media formats within a single ad unit (prebid#1991)
  pre1api module that allows use of deprecated pre1.0 API in Prebid 1.0 (prebid#1976)
  Colossus SSP header bidding adapter 1.0.0 (prebid#2029)
  InSkin Bidder Adapter (prebid#2016)
  Update adapter to prebid v1.0 (prebid#1908)
  PubMatic 1.0 adapter (prebid#2011)
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
* Update adapter to prebid v1.0

* corrected some things following pullrequest review

* slight change to avoid potential error

* added the maintainer email

* Updated the tests to fit changes

* Updated the doc, removed the bidderCode, added adUrl

* fix adapter

* Added try catch around JSON.parse
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.

4 participants