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

Prebid core: cached bids should contain the ID of the auction they actually won #10541

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

msmeza
Copy link
Contributor

@msmeza msmeza commented Sep 27, 2023

Type of change

  • Feature

Description of change

Cached bids should contain the ID of the auctions that they actually won so that this information is available through BID_WON events.

Other information

More information about the motivation for this PR can be found here: #10540

src/targeting.js Outdated
@@ -464,6 +464,14 @@ export function newTargeting(auctionManager) {
if (typeof filterFunction === 'function') {
bidsReceived = bidsReceived.filter(bid => latestAuctionForAdUnit[bid.adUnitCode] === bid.auctionId || !!filterFunction(bid))
}

bidsReceived = bidsReceived
.map(bid => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks more suited to forEach. Also I think it should be done after all filtering is done, around line 480, or do you see a reason why it's better to tag them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, forEach is mor suited for this.

Yes, I agree that the property should be set after all filtering is done, provided it should be set on all the bids in the pool (as you mentioned in your comment below). The reason I added my change where I did was to avoid increasing the size of bid objects in the cases where auctionId would have the same value as the new property. But I think it's a good idea to set the property on all bids in the pool.

src/targeting.js Outdated
bidsReceived = bidsReceived
.map(bid => {
if (latestAuctionForAdUnit[bid.adUnitCode] !== bid.auctionId) {
bid.latestAuctionForAdUnit = latestAuctionForAdUnit[bid.adUnitCode];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • IMO this should be set on all bids in the pool, not just those from a previous auction.
  • I don't like the name, "forAdUnit" is redundant since the object is a bid and already tied to a particular ad unit. Maybe latestTargetedAuctionId? Asking also @patmmccann for opinions. I'd prefer to make targeting explicit since this only runs when the publisher uses prebid's targeting logic, which in theory they could do without.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On naming , I agree with a shorter name yes

@patmmccann patmmccann merged commit 6c7f17f into prebid:master Oct 10, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants