-
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 Adapter Update: #1438
OpenX Adapter Update: #1438
Conversation
modules/openxBidAdapter.js
Outdated
@@ -187,10 +203,25 @@ const OpenxAdapter = function OpenxAdapter() { | |||
} | |||
}); | |||
|
|||
params.callback = 'window.$$PREBID_GLOBAL$$.oxARJResponse'; | |||
let queryString = buildQueryStringFromParams(params); | |||
if (window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) { |
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.
withCredentials
should be available in any browser version that Prebid.js supports. Are you seeing otherwise?
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.
Unfortunately we require the credentials for our ajax support to function correctly, so we must do this check here
modules/openxBidAdapter.js
Outdated
|
||
adloader.loadScript(`//${delDomain}/w/1.0/arj?${queryString}`); | ||
if (useJsonp) { |
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 would be ideal to just remove Jsonp altogether if the ajax is working correctly. Also, to switch to a scoped callback rather than using a pbjs global function.
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.
As mentioned in the previous comment, there are times where we cannot support ajax so we can't really remove jsonp completely. What did you mean by the switching to a scoped callback?
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.
When can you not support AJAX? What I'm trying to say, is in any browser that doesn't support AJAX won't support Prebid.js, so if you can run Prebid.js then you should be able to use AJAX, including withCredentials
always.
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.
Hello! We have some special cases to support IE9 which doesn't fully support Ajax yet, so it is best to check withCredentials and have a fallback to jsonp.
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.
@snapwich Hello there! I just noticed that prebid supports only IE10+ now, just wanted to confirm with you on that. If that is the case then we're okay with removing jsonp completely and I'll get to working on that.
modules/openxBidAdapter.js
Outdated
let startTime; | ||
let timeout = $$PREBID_GLOBAL$$.bidderTimeout; |
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.
This is going to always be the default value since any custom timeouts will be set in a pbjs.queue block which will execute after adapter initialization. It might be best for you to always just look at $$PREBID_GLOBAL$$.bidderTimeout
so that you know you're getting the latest.
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 are trying capture the timeout at the time of request and store it until time of response. Do you know if this global stays constant throughout? We have observed that sometimes it seems the value changes so that's why I'm doing this to make sure.
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 didn't notice that you're overwriting the timeout below from the bidderRequest params. That should be accurate. 👍
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.
Regarding the timeout, there is at least one case which is not captured. If the old style PREBID_TIMEOUT variable is used in the style
var PREBID_TIMEOUT = 700;
// Load GPT when timeout is reached.
setTimeout(initAdserver, PREBID_TIMEOUT);
like it's done in the example the bidmanager will have no clue about it and default to 3000 instead.
Therefore, I'd recommend
bt: Math.min($$PREBID_GLOBAL$$.cbTimeout || $$PREBID_GLOBAL$$.bidderTimeout, window.PREBID_TIMEOUT || $$PREBID_GLOBAL$$.bidderTimeout)
instead
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 agree with this to try to capture the PREBID_TIMEOUT on the window but we've observed the inside cbTimeout being changed at the time of response, hence the change to save the one coming from the paramter for later use. I'll make the changes accordingly to try to capture the one on the window.
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.
Left a few comments
b4ee232
to
efb9515
Compare
@snapwich after talking with the team, I removed the JSONP requests completely. Please let me know if there are more changes needed. Thanks. |
modules/openxBidAdapter.js
Outdated
try { | ||
let queryString = buildQueryStringFromParams(params); | ||
let url = `//${delDomain}/w/1.0/arj?${queryString}`; | ||
ajax.ajax(url, $$PREBID_GLOBAL$$.oxARJResponse, void (0), { |
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.
Now that JSONP is gone, is there any reason for this function to be on the global?
If not, let's remove it.
assert(!spyLoadScript.called); | ||
spyLoadScript.restore(); | ||
assert(!spyAjax.called); | ||
spyAjax.restore(); |
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.
spies, stubs, etc need to be done in beforeEach
or afterEach
blocks.
Otherwise spyAjax.restore()
won't execute when your test fails, and it causes tons of unrelated cascading failures (sinon won't let you wrap an already-wrapped function)
1) Implementing AJAX calls for ad requests 2) Adding prebid trasaction id to ad request 3) Updated timeout to use the timeout passed as params 4) Implemented cache busting on ad request 5) Add tbd feature field to bidResponse
@dbemiller I have removed the callback from the global, as well as changed the unit test structure to incorporate beforeEach and afterEach. Please let me know if there are any other things you see. |
…built * 'master' of https://github.com/prebid/Prebid.js: (83 commits) feat(strAdapt): check if tagJS is already present (prebid#1500) Updated karma-mocha, and simplified the test framework for runs which dont include --watch. (prebid#1520) Revert "drop specific code for index adapter (prebid#1487)" (prebid#1529) Override default asset params when set on ad unit (prebid#1524) Adding new kv to xhb Adapter (prebid#1513) removing for...of loops because IE cannot handle them properly (prebid#1523) Increment pre version Prebid 0.27.0 Release Move unit test file to appropriate location (prebid#1516) Support 'cta' native asset (prebid#1505) Add adapter parameter types (prebid#1504) Register bid adapter (prebid#1514) Match port when testing legacy browser (prebid#1511) modify 'featureforward' adapter to be an indepandant adapter (prebid#1288) Feature/s2s client side fallback (prebid#1485) Make bid.vastUrl use the cache URL if the bid didnt already have one. (prebid#1506) OpenX Adapter Update: (prebid#1438) Add session id feature for roxot analytics adapter (prebid#1498) Update platformioBidAdapter (prebid#1493) Adding VAST Payload support for video bids (prebid#1407) ...
1) Implementing AJAX calls for ad requests 2) Adding prebid trasaction id to ad request 3) Updated timeout to use the timeout passed as params 4) Implemented cache busting on ad request 5) Add tbd feature field to bidResponse
1) Implementing AJAX calls for ad requests 2) Adding prebid trasaction id to ad request 3) Updated timeout to use the timeout passed as params 4) Implemented cache busting on ad request 5) Add tbd feature field to bidResponse
1) Implementing AJAX calls for ad requests 2) Adding prebid trasaction id to ad request 3) Updated timeout to use the timeout passed as params 4) Implemented cache busting on ad request 5) Add tbd feature field to bidResponse
1) Implementing AJAX calls for ad requests 2) Adding prebid trasaction id to ad request 3) Updated timeout to use the timeout passed as params 4) Implemented cache busting on ad request 5) Add tbd feature field to bidResponse
Type of change
Description of change