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 Adapter Update: #1438

Merged
merged 1 commit into from
Aug 22, 2017
Merged

OpenX Adapter Update: #1438

merged 1 commit into from
Aug 22, 2017

Conversation

lntho
Copy link
Contributor

@lntho lntho commented Jul 28, 2017

  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

  • Bugfix
  • Feature

Description of change

  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

@@ -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()) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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


adloader.loadScript(`//${delDomain}/w/1.0/arj?${queryString}`);
if (useJsonp) {
Copy link
Collaborator

@snapwich snapwich Jul 31, 2017

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

let startTime;
let timeout = $$PREBID_GLOBAL$$.bidderTimeout;
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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. 👍

Copy link

@DubKF DubKF Aug 11, 2017

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

Copy link
Contributor Author

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.

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.

Left a few comments

@lntho lntho force-pushed the openx-release branch 2 times, most recently from b4ee232 to efb9515 Compare August 16, 2017 22:38
@lntho
Copy link
Contributor Author

lntho commented Aug 16, 2017

@snapwich after talking with the team, I removed the JSONP requests completely. Please let me know if there are more changes needed. Thanks.

snapwich
snapwich previously approved these changes Aug 17, 2017
@dbemiller dbemiller self-requested a review August 17, 2017 18:42
@dbemiller dbemiller assigned dbemiller and unassigned snapwich and ndhimehta Aug 17, 2017
try {
let queryString = buildQueryStringFromParams(params);
let url = `//${delDomain}/w/1.0/arj?${queryString}`;
ajax.ajax(url, $$PREBID_GLOBAL$$.oxARJResponse, void (0), {
Copy link
Contributor

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();
Copy link
Contributor

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
@lntho
Copy link
Contributor Author

lntho commented Aug 21, 2017

@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.

@dbemiller dbemiller merged commit afc36d1 into prebid:master Aug 22, 2017
outoftime pushed a commit to Genius/Prebid.js that referenced this pull request Aug 24, 2017
…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)
  ...
ptomasroos pushed a commit to happypancake/Prebid.js that referenced this pull request Aug 25, 2017
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
philipwatson pushed a commit to mbrtargeting/Prebid.js that referenced this pull request Sep 18, 2017
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
jbAdyoulike pushed a commit to jbAdyoulike/Prebid.js that referenced this pull request Sep 21, 2017
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
dluxemburg pushed a commit to Genius/Prebid.js that referenced this pull request Jul 17, 2018
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
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