-
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
Sharethrough: Change to using a closure for the callback from ajax to preserve bidObj #1108
Conversation
src/adapters/sharethrough.js
Outdated
bidResponse = JSON.parse(bidResponse); | ||
const bidId = bidResponse.bidId; | ||
const bidObj = utils.getBidRequest(bidId); | ||
try { |
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 wasn't a change in this PR, but I'd suggest moving the try {
above the JSON.parse()
so any errors parsing the JSON are caught so the bids are added to the bidManager as errors.
@@ -117,8 +108,8 @@ describe('sharethrough adapter', () => { | |||
"stxUserId": "" | |||
}; | |||
|
|||
pbjs.strcallback(JSON.stringify(bidderReponse1)); | |||
pbjs.strcallback(JSON.stringify(bidderReponse2)); | |||
adapter.callback(bidderRequest.bids[0], JSON.stringify(bidderReponse1)); |
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.
rather than exposing the callback just for testing, it's preferred that you test using the sinon.fakeServer
with a mock response and calling adapter.callBids()
. You can see an example in here.
src/adapters/sharethrough.js
Outdated
@@ -39,10 +45,9 @@ var SharethroughAdapter = function SharethroughAdapter() { | |||
return url; | |||
} | |||
|
|||
$$PREBID_GLOBAL$$.strcallback = function(bidResponse) { | |||
function _strcallback(bidObj, bidResponse) { | |||
bidResponse = JSON.parse(bidResponse); |
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 see there was another change (causing a conflict) where you wrapped this in a separate try/catch. I'd still recommend wrapping it in the try block below so that the bid is added to the bidManager (in your _handleInvalidBid()
function) so it can still be tracked.
Made the changes! |
src/adapters/sharethrough.js
Outdated
@@ -102,6 +101,7 @@ var SharethroughAdapter = function SharethroughAdapter() { | |||
return { | |||
callBids: _callBids, | |||
str : str, | |||
callback: _strcallback |
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.
no need to expose callback
any longer
thanks @rizhang! made one more minor comment. |
Made the change! |
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.
looks like the travis-ci
tests failed, but the errors are unrelated to these changes, and the tests pass locally for me
…built * 'master' of https://github.com/prebid/Prebid.js: inclusion of popular Nordic ad sizes to default size list (prebid#1168) pre release version bump Prebid 0.23.1 Release Add trafficSourceCode + test (prebid#1184) Clear cookie sync to prevent multiple calls (prebid#1181) change s2s adapter to filter out units with empty sizes array (prebid#1179) Sharethrough: Change to using a closure for the callback from ajax to preserve bidObj (prebid#1108) check array length when mapping sizes (prebid#1180) Bugfix/encoding url (prebid#1178)
…21.0 to aolgithub-master * commit '4d573b42c5fbbabf23fed48fa042b75a72dd16b2': (31 commits) Added prebidServer in aolPartnersIds.json. Added adapters in aolPartnersIds.json. Added changelog entry. Prebid 0.23.1 Release Add trafficSourceCode + test (prebid#1184) Clear cookie sync to prevent multiple calls (prebid#1181) change s2s adapter to filter out units with empty sizes array (prebid#1179) Sharethrough: Change to using a closure for the callback from ajax to preserve bidObj (prebid#1108) check array length when mapping sizes (prebid#1180) Bugfix/encoding url (prebid#1178) add lodash as dependency (prebid#1174) fix size mapping for s2s (prebid#1175) Improve footer styling (prebid#1171) Bugfix: internal bids requested overwritten (prebid#1173) pre-release version bump Prebid 0.23.0 Release Yieldbot adapter - multiple requestBids per pageview (prebid#1146) Widespace adapter validate size fix (prebid#1140) Audience Network: bid when at least one valid slot size (prebid#1148) Quantcast adaptor (prebid#1063) ...
Type of change
Description of change
Passing the bid request object inside the callback function, instead of relying on fetching it with a bid Id. When multiple auctions are ran, old bid requests will be deleted, which causes the adapter to error out.
rzhang@sharethrough.com
Other information