-
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
OpenX official adapter release: Fixing the existing openx adapter and… #896
Conversation
@@ -1,130 +1,228 @@ | |||
// jshint ignore:start | |||
var bidfactory = require('../bidfactory.js'); |
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.
prefer const
here
if (bid.params.pageURL) { | ||
opts.pageURL = bid.params.pageURL; | ||
} | ||
var OpenxAdapter = function OpenxAdapter() { |
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.
const
var OpenxAdapter = function OpenxAdapter() { | ||
const BIDDER_CODE = 'openx'; | ||
const BIDDER_CONFIG = 'hb_pb'; | ||
var startTime; |
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.
let
@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 :) |
@lntho |
opts.pageURL = bid.params.pageURL; | ||
} | ||
var OpenxAdapter = function OpenxAdapter() { | ||
const BIDDER_CODE = 'openx'; |
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.
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, |
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.
window.top
can throw. Please add try/catch.
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.
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; |
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.
let
POX.addPage(opts.pgid); | ||
if (boBase) { | ||
img.src = `${boBase[1]}bo?${buildQueryStringFromParams(params)}`; | ||
return img; |
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 doesn't look like this img
is used anywhere. Did you want to trigger a pixel/beacon here?
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.
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; |
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.
These lines need try/catch
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.
The window.top here is already checked below at line 195, I think it should be fine here without a try/catch?
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.
Yeah that should be good.
ee: 'api_sync_write', | ||
ef: 'bt%2Cdb', | ||
be: 1, | ||
bc: BIDDER_CONFIG |
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.
What is this used for?
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.
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, |
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.
try/catch
function callBids(params) { | ||
let isIfr = window.self !== window.top, | ||
bids = params.bids || [], | ||
currentURL = window.location.href && encodeURIComponent(window.location.href); |
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.
encodeURIComponent
is safe to use directly. You don't need &&
here.
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.
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'
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.
Gotcha
}); | ||
|
||
it('should add empty bid responses if no bids returned', function () { | ||
var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); |
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.
nit: replace all var
s with const
or let
in this file.
} | ||
|
||
function addBidResponse(adUnit, bid) { | ||
var bidResponse = bidfactory.createBid(adUnit ? CONSTANTS.STATUS.GOOD : CONSTANTS.STATUS.NO_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.
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
@lntho |
The PR has been updated, please let me know if there are additional issues that you see :) |
@lntho thanks, will review again. |
beaconParams.bp = adUnit.pub_rev; | ||
beaconParams.ts = adUnit.ts; | ||
addBidResponse(adUnit, 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.
nit: there is an extra space after this brace.
}; | ||
}; | ||
|
||
module.exports = OpenxAdapter; | ||
module.exports = OpenxAdapter; |
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.
we have a newline at the end of the file by convention.
Verified bids received and ads renderered. LGTM. Please address those 2 style items and we'll be good to merge. Thanks for contributing! |
… adding test coverage on it
The style changes have been made, thank you for the review! |
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. |
@lntho |
… adding test coverage on it (prebid#896)
… adding test coverage on it
Type of change
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.