-
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
Filter bid arrays using adUnitsFilter function #750
Conversation
@dugwood you will notice here that I've reversed myself on an |
@protonate yes, that's great I think :-) I've reviewed a bit your code, and there's a lot of changes! Wouldn't it be useful to set a big global object that would group all current global variables?
I'll try this code today, as I have issues with Rubicon and multiple sizes. Maybe that will fix it too. Rubicon team is working on the issue anyway. |
@protonate Looks like there is conflicts now. Please resolve thanks |
f73f234
to
4e03174
Compare
@mkendall07 conflicts fixed |
@@ -38,6 +38,7 @@ var eventValidators = { | |||
|
|||
$$PREBID_GLOBAL$$._bidsRequested = []; | |||
$$PREBID_GLOBAL$$._bidsReceived = []; | |||
$$PREBID_GLOBAL$$._adUnitCodes = []; |
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 name isn't super intuitive. Maybe just add comment here on what this is.
utils.logInfo('Invoking $$PREBID_GLOBAL$$.requestBids', arguments); | ||
|
||
if (!adUnits || adUnits.length === 0) { | ||
utils.logMessage('No adUnits configured. No bids requested.'); | ||
if (typeof bidsBackHandler === objectType_function) { | ||
bidmanager.addOneTimeCallback(bidsBackHandler, false); | ||
} | ||
|
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.
extra line breaks.
} | ||
|
||
// we will use adUnitCodes for filtering the current auction | ||
$$PREBID_GLOBAL$$._adUnitCodes = adUnitCodes; |
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.
doesn't this clubber a current auction running codes since it's before if (auctionRunning)
check?
4e03174
to
fa0feb4
Compare
@mkendall07 note addressed |
417d87a
to
0a37f14
Compare
@mkendall07 ready for review |
0a37f14
to
1edc943
Compare
This PR has been updated and is ready to test. The following changes have been made. Applies the current adUnitCodes filter when calling reporting APIs Note that if a placement is included in one request and a second request as well, and the second request is made before the first request has rendered an ad, the bids for the first request will be cleared and the |
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.
Just a few comments.
@@ -43,6 +43,7 @@ function getBidders(bid) { | |||
function bidsBackAdUnit(adUnitCode) { | |||
const requested = $$PREBID_GLOBAL$$._bidsRequested | |||
.map(request => request.bids | |||
.filter(adUnitsFilter.bind(this, $$PREBID_GLOBAL$$._adUnitCodes)) |
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's the reason for using bind
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.
It's isn't needed here, only in places where the filter may be passed in rather than the current pbjs._adUnitCodes
array. I'll remove from here and elsewhere where we can and have utils.adUnitsFilter
check for an array passed in and if not found use ad unit codes defined on global.
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.
Actually if we use .bind
for processCallbacks
to support a single ad unit code or all ad unit codes (for bidsBackAdUnit
and bidsBackAll
respectively) then we should use the same partial application pattern in all of these cases. This is probably preferable as the ad unit codes to use as a filter can be set as instance data on the requestBids
function and we can remove the _adUnitCodes
global property.
@@ -273,19 +278,26 @@ exports.executeCallback = function (timedOut) { | |||
} | |||
}; | |||
|
|||
exports.externalCallbackReset = function () { | |||
externalCallbacks.all.called = false; |
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.
externalCallbacks
has evolved into complex object. Should we formalize this into int's own file / class constructor?
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 like that idea.
@mkendall07 any changes needed to merge? |
Sorry @protonate I didn't get a chance to test this PR yet. I'll do that today and sans any issues we can merge it. |
Tested functionality, LGTM. Can merge after resolving conflicts. |
The requested and received bid arrays must retain bid objects from multiple calls to `pbjs .requestBids`. However this causes unexpected behavior in the reporting APIs as bids from previous auctions were returned. This PR addresses this by creating a `pbjs._adUnitCodes` primary data structure to be used as a filter when Prebid needs only the current "auction". While not ideal this allows us to retain bid data for in-flight calls to an ad server while also allowing additional bid requests to be made without the introduction of Prebid Auction instances. Closes #590 * reset externalCallbacks.all.called * use adUnitsFilter to filter bid arrays to current auction
Applies the filter when calling reporting APIs `getBidResponses`, `getAdserverTargeting`. Queues a bid request if a previous request is still running, closing over instance data. Clears previous bids from placements included in current bid request (remove stale bids). Note that if a placement is included in one request and a second request as well, and the second request is made before the first request has rendered an ad, the bids for the first request will be cleared and the `renderAd` function will throw an error as the bids cannot be found. However, the placement should be immediately filled with the results of the second request. The error is not caught so as to warn that a placement was overwritten, and care should be taken not to request bids for a placement with a request already in flight. fixes #772 fixes #590
e53f07a
to
6d97e91
Compare
@mkendall07 conflicts are resolved |
Type of change
Description of change
The requested and received bid arrays must retain bid objects from multiple calls to
pbjs .requestBids
. However this causes unexpected behavior in the reporting APIs as bids fromprevious auctions were returned. This PR addresses this by creating a
pbjs._adUnitCodes
primarydata structure to be used as a filter when Prebid needs only the current "auction". While not
ideal this allows us to retain bid data for in-flight calls to an ad server while also allowing
additional bid requests to be made without the introduction of Prebid Auction instances.
Closes #590