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

OpenX official adapter release: Fixing the existing openx adapter and… #896

Merged
merged 1 commit into from
Jan 10, 2017

Conversation

lntho
Copy link
Contributor

@lntho lntho commented Dec 27, 2016

… adding test coverage on it

Type of change

  • [ x ] official adapter submission
  • test parameters for validating bids
{
  bidder: 'openx’,
  params: {
    // …
    params: {
              unit: ‘538562284’, // OpenX ad unit ID
              delDomain: 'clientname-d.openx.net',  // OpenX delivery domain
              customParams: {"gender": "female"}   // Publisher specified custom parameters, optional
            }
  }
}

bidder code: openx
Send All Bids Ad Server Keys: hb_pb_openx, hb_adid_openx, hb_size_openx
Default Deal ID Ad Server Key: hb_deal_openx

Other information

Note:
The OpenX adapter requires setup and approval from your OpenX team. Please reach out to your OpenX representative or Support@openx.com for more information and to enable using this adapter.

@lntho lntho closed this Dec 27, 2016
@lntho lntho reopened this Dec 28, 2016
@protonate protonate self-assigned this Jan 3, 2017
@mkendall07 mkendall07 assigned mkendall07 and unassigned protonate Jan 4, 2017
@@ -1,130 +1,228 @@
// jshint ignore:start
var bidfactory = require('../bidfactory.js');
Copy link
Member

Choose a reason for hiding this comment

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

prefer const here

if (bid.params.pageURL) {
opts.pageURL = bid.params.pageURL;
}
var OpenxAdapter = function OpenxAdapter() {
Copy link
Member

Choose a reason for hiding this comment

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

const

var OpenxAdapter = function OpenxAdapter() {
const BIDDER_CODE = 'openx';
const BIDDER_CONFIG = 'hb_pb';
var startTime;
Copy link
Member

Choose a reason for hiding this comment

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

let

@mkendall07 mkendall07 added this to the Prebid 0.18.0 milestone Jan 5, 2017
@lntho
Copy link
Contributor Author

lntho commented Jan 6, 2017

@mkendall07 Thanks for the review! I've fixed the ones you have mentioned, please take a look again and let me know if there are additional things to fix :)

@mkendall07
Copy link
Member

@lntho
Hey sorry I got interrupted during code review so I just commented inline on those. I should be able to finish up the review today. Thanks for responding.

opts.pageURL = bid.params.pageURL;
}
var OpenxAdapter = function OpenxAdapter() {
const BIDDER_CODE = 'openx';
Copy link
Member

Choose a reason for hiding this comment

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

Consider using the "alias" pattern with baseAdapter to allow whitelabeling of your adapter.

See https://github.com/prebid/Prebid.js/blob/master/src/adapters/appnexusAst.js#L22 for example

}

function callBids(params) {
let isIfr = window.self !== window.top,
Copy link
Member

Choose a reason for hiding this comment

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

window.top can throw. Please add try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, will add a try catch here


if (bid.params.jstag_url) {
scriptUrl = bid.params.jstag_url;
var bids = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'openx').bids;
Copy link
Member

Choose a reason for hiding this comment

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

let

POX.addPage(opts.pgid);
if (boBase) {
img.src = `${boBase[1]}bo?${buildQueryStringFromParams(params)}`;
return img;
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like this img is used anywhere. Did you want to trigger a pixel/beacon here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the return is not needed. This might be a relic from testing phases, I will remove the return.

body;

if (isIfr) {
tWin = window.top;
Copy link
Member

Choose a reason for hiding this comment

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

These lines need try/catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The window.top here is already checked below at line 195, I think it should be fine here without a try/catch?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that should be good.

ee: 'api_sync_write',
ef: 'bt%2Cdb',
be: 1,
bc: BIDDER_CONFIG
Copy link
Member

Choose a reason for hiding this comment

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

What is this used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the bc parameter is for us to track what kind of service is making the ad request in our events

}

function callBids(params) {
let isIfr = window.self !== window.top,
Copy link
Member

Choose a reason for hiding this comment

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

try/catch

function callBids(params) {
let isIfr = window.self !== window.top,
bids = params.bids || [],
currentURL = window.location.href && encodeURIComponent(window.location.href);
Copy link
Member

Choose a reason for hiding this comment

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

encodeURIComponent is safe to use directly. You don't need && here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we're trying to check if window.location.href exists to begin with, and if it is undefined we want to leave it as such instead of encoding it to be a string 'undefined'

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha

});

it('should add empty bid responses if no bids returned', function () {
var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse');
Copy link
Member

Choose a reason for hiding this comment

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

nit: replace all vars with const or let in this file.

}

function addBidResponse(adUnit, bid) {
var bidResponse = bidfactory.createBid(adUnit ? CONSTANTS.STATUS.GOOD : CONSTANTS.STATUS.NO_BID);
Copy link
Member

Choose a reason for hiding this comment

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

Please pass the bidRequest bid object through the bidfactory.createBid(CONSTANTS.STATUS.GOOD, bid) so that we can match the bidId param. Example https://github.com/prebid/Prebid.js/blob/master/src/adapters/appnexusAst.js#L116

@mkendall07
Copy link
Member

@lntho
For validating purposes, we will need a real parameters. clientname-d.openx.net is not a valid endpoint. Please update with proper test params. Thanks

@lntho
Copy link
Contributor Author

lntho commented Jan 10, 2017

The PR has been updated, please let me know if there are additional issues that you see :)

@mkendall07
Copy link
Member

@lntho thanks, will review again.

beaconParams.bp = adUnit.pub_rev;
beaconParams.ts = adUnit.ts;
addBidResponse(adUnit, bid);
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: there is an extra space after this brace.

};
};

module.exports = OpenxAdapter;
module.exports = OpenxAdapter;
Copy link
Member

Choose a reason for hiding this comment

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

we have a newline at the end of the file by convention.

@mkendall07
Copy link
Member

Verified bids received and ads renderered. LGTM. Please address those 2 style items and we'll be good to merge. Thanks for contributing!

@lntho
Copy link
Contributor Author

lntho commented Jan 10, 2017

The style changes have been made, thank you for the review!

@mkendall07
Copy link
Member

Thanks. BTW you don't have to squash your commits (it's actually easier to review if you don't). Github has automatic squashing during merge to master.

@mkendall07 mkendall07 merged commit 0853677 into prebid:master Jan 10, 2017
@mkendall07
Copy link
Member

@lntho
Also please open PR to update the bidder docs for OpenX: https://github.com/prebid/prebid.github.io/blob/master/dev-docs/bidders/openx.md

Walexander pushed a commit to MbidIO/Prebid.js that referenced this pull request Mar 6, 2017
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.

3 participants