-
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
New Module: MinBidToWin Notifications: Created a new module to support sending minbidtowin notifications to bidders #11086
base: master
Are you sure you want to change the base?
Conversation
will write tests for this PR once the questions within the comment above are addressed |
src/lossNotifications.js
Outdated
|
||
if (bidder.beaconUrl) { | ||
// use js beacon api to fire payload immediately to ssp provided endpoint | ||
navigator.sendBeacon(bidder.beaconUrl, JSON.stringify(lossNotificationPayload)); |
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 use our methods; fetch keepalive has replaced sendBeacon and is now supported by importing the ajax library
Would suggest naming this "auction info" instead of trying to promise true "loss notification". prebid/prebid-server#3333 |
One thought in committee is keeping direct calls for the unload event; we would attempt to send all notifications on the next payload. |
Some notes in committee discussion https://docs.google.com/document/d/1AojPDLnJzXaxwmFE5U7Qsm2GAV1fVwjcx4YyI6kX9ew/edit Looking forward to this feature! |
Hey, chiming in to check what is required for this PR to be approved? As a Prebid Server bidder, we are very interested with this feature as it was proven very efficient with other partners in terms of optimizing our bidding behavior and winrate. |
I think it is important to try and censure bidder B listening to scenarios they have submitted valid bids. We dont want to incentivize invalid bid submissions to get these events |
Turns out the Prebid Server committee has been discussing this general topic as well. See prebid/prebid-server#3333 . The scenarios are different, but it might make sense to standardize on the ORTB extension here. Haven't done a full analysis, but did note some key points of difference:
PBJS proposed payload:
PBJS proposed ORTB extension at ext.prebid.previousauctioninfo
Perhaps these approaches should be discussed in next week's committee meetings? |
@jlquaccia, @patmmccann, @mlapeyre3 - any response to my concerns? Most importantly, I believe currency is a must-have. But also I think a "piggybacking-on-the-next auction" approach is superior to the current "fire payload immediately to ssp provided endpoint" implementation. Am ready to debate this. :-) |
@bretg I'm good with the ext.prebid.previousauctioninfo approach mentioned above with the additional keys you proposed, makes sense to me. Aligning with PBS would definitely be ideal. I can also see why immediately firing a response would have drawbacks (as also mentioned above). What if during subsequent auctions, for ssp's that have opted in to receive previousauctioninfo, in order for them to actually receive this info, their subsequent bid request has to pass their own bid adapter isBidRequestValid check? (to help try filter out invalid submissions) @patmmccann @mlapeyre3 thoughts on your end? |
Works for me |
@jlquaccia we'd love to make progress on this. Do you think we're in a position to start writing tests? Can we pitch in? |
noting the file is in /src/ not /modules |
src/lossNotifications.js
Outdated
} else { | ||
pbln[bidder.bidderCode] = [lossNotificationPayload]; | ||
} | ||
storage.setDataInLocalStorage('pbln', JSON.stringify(pbln)); |
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.
why use storage instead of just an object in window?
@patmmccann thanks for the recent updates above. yes, i can pick this up again (will aim for next week). currently wrapping up with some internal project work over here. |
Tread carefully! This PR adds 3 linter errors (possibly disabled through directives):
|
@patmmccann addressed the items above and wrote some new tests. let me know if you have any other feedback |
hey @patmmccann, just wanted to follow up with this one for a code review? |
|
||
export const onAuctionEndHandler = (auctionDetails) => { | ||
// eslint-disable-next-line no-console | ||
console.log('onAuctionEndHandler', auctionDetails); |
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.
should this be here?
}, auctionDetails.bidsReceived[0]); | ||
|
||
auctionDetails.bidsReceived.forEach(bidReceived => { | ||
receivedBidsMap[bidReceived.requestId] = bidReceived; |
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 could be done in the reduce
above to spare a loop
|
||
if (enabledBidder) { | ||
bidderRequest.bids.forEach(bid => { | ||
const isValidBid = enabledBidder.isBidRequestValid(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.
(After writing what's below, I realized isBidRequestValid
is not necessarily coming from the adapter, so I'm not sure if my point is valid - what's the idea for this validation?)
I'm worried that some adapters may not be expecting this. They could for example generate duplicate error messages, or if they keep state, break them.
Is it necessary? Would it be acceptable to have an "empty" prevAuctionInfo object for invalid requests, as if no-one bid?
If not, I think it'd be preferable to mark invalid bids where we already call isBidRequestValid
, so that you can recognize them here without calling it again.
if (enabledBidder && window.pbpai[bidRequest.bidderCode]) { | ||
window.pbpai[bidRequest.bidderCode].forEach(prevAuctPayload => { | ||
if (winningBidsMap[prevAuctPayload.transactionId]) { | ||
prevAuctPayload.minBidToWin = winningBidsMap[prevAuctPayload.transactionId].cpm; | ||
prevAuctPayload.rendered = 1; | ||
} | ||
}); |
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 purpose of this is to update the prevAuctionInfo object with the winning bid's cpm, right? If so, I think it'd be more intuitive to put it in the BID_WON handler. But see also below on transactionId
bidderRequestId: bidderRequest.bidderRequestId, | ||
minBidToWin: highestCpmBid?.cpm || 0, | ||
rendered: 0, | ||
transactionId: bid.ortb2Imp.ext.tid || bid.transactionId, |
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 leaks transactionId
to the bidder, which is hidden by default. You could still use this to keep track of winners without exposing it, for example by using a map from transactionId -> prevAuctionInfo, which would make it easier to update the winning cpm on BID_WON, and pass only the values to the bidder on the next request.
transactionId: bid.ortb2Imp.ext.tid || bid.transactionId, | ||
source: 'pbjs', | ||
auctionId: auctionDetails.auctionId, | ||
impId: bid.adUnitCode, |
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.
IMO adUnitCode
is a better name. impId
makes me think of ORTB imp.id
, which most of the time is different from the ad unit code.
timestamp: auctionDetails.timestamp, | ||
} | ||
|
||
window.pbpai = window.pbpai || {}; |
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.
why put this in window
? it looks like internal state to me.
winningBidsMap = {}; | ||
}; | ||
|
||
export const enablePreviousAuctionInfo = (config, cb = initHandlers) => { |
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 unclear to me how this is intended to be used.
If it's an optional module chosen by the publisher, this should be in the modules
folder and listen for changes to setConfig
.
Alternatively we could let individual bidders opt in, in which case the only parameter needed should be the bidder code, and this should allow for being called multiple times with different bidders.
rendered: 0, | ||
transactionId: bid.ortb2Imp.ext.tid || bid.transactionId, | ||
source: 'pbjs', | ||
auctionId: auctionDetails.auctionId, |
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.
Same issue as transactionId
- this is hidden by default. This should either be omitted, or included only when the transmitTid
activity is allowed
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 think it should be debated whether any of this data is useful to bidders if there's no IDs. If I understand the purpose correctly, the receiver will join these logs with their bid logs so they can do stuff like "oh, when the browser is X and the country is Y, my bid has to be higher". In order to do that, I suspect that there's a minimal set of IDs or the join will be impossible.
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 can leave in requestId
and bidderRequestId
. They have the same domain (allow the same join) as transactionId
/ auctionId
, the difference is they're not shared across bidders.
Or we can do what I think the first join would have to be - each request's prevAuctionInfo only pertains bids on the same ad unit.
if (!isValidBid) return; | ||
|
||
const previousAuctionInfoPayload = { | ||
bidderRequestId: bidderRequest.bidderRequestId, |
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 bidderRequest.bidderRequestId?
|
||
const previousAuctionInfoPayload = { | ||
bidderRequestId: bidderRequest.bidderRequestId, | ||
minBidToWin: highestCpmBid?.cpm || 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.
How does 'minBidToWin' differ from the 'highestcpm' field? I can live with this term because it's sort of an industry standard, but it's actually not correct. Not guaranteed at all that they would have won with this bid. It just happens to be the highest bid that Prebid knows about. Which is why I prefer the term 'highestcpm' -- there's less of a promise involved. But anyhow, I get that 'minBidToWin' is a cow that's left the barn, so I would suggest removing 'highestcpm' then. Please make sure that it's positioned right next to the cur
field though. Another pet peeve of mine is when it's not clear what currency a price is stated in.
Which I suppose opens a can of worms. The obvious minBidToWin currency is the ortb.cur, but there are going to bidders that will only accept minBidToWin in USD, EUR, or whatever. Do we need this module to convert to different currencies, so an array of minBidToWin entries?
auctionId: auctionDetails.auctionId, | ||
impId: bid.adUnitCode, | ||
// bidResponseId: FLOAT, // don't think this is available client side? | ||
// targetedbidcpm: FLOAT, // don't think this is available client side? |
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.
Yes, targetedbidcpm is available in PBJS. If deals are prioritized over open market, the highestcpm
might not be the one that Prebid chose to send in hb_pb
.
Type of change
Description of change
Other information
#10788