Repository navigation
Takeover Module: page takeover deals (#15719) - #16321
WhimsicalCoder wants to merge 6 commits into
Conversation
Read ext.prebid.deal.takeover into bid.meta.deal.takeover, add the TakeoverMeta type and the takeoverResult event name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the takeover module (modes all, max and viewport), its tests and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aeb3430bda
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let won = outright; | ||
| if (sameTier.length > 0) { | ||
| const exclusivity = takeoverConfig.allowExclusivity ? group.terms.exclusivity : undefined; | ||
| const outside = eligibleCodes.filter(code => !matched.includes(code)); |
There was a problem hiding this comment.
Count exclusions from matched slots the takeover loses
When allowExclusivity is enabled and a max/viewport group has enough outright wins to satisfy minSlots, it can still lose a matched lower-priority slot; only all rejects lostTier. This list omits that slot, but the winner path later removes matching competitor bids from every slot not in codes. Because the lost-tier bid is also excluded from sameTier, it contributes to neither value term, so the module can accept a takeover and delete the only competing bid from a slot it does not win. Include those exclusions in the hurdle or restrict the drop to winning slots.
AGENTS.md reference: AGENTS.md:L129-L129
Useful? React with 👍 / 👎.
|
|
||
| // takeovers are ranked against each other first; only one can win an auction | ||
| groups.sort((a, b) => (bestPriority(a) - bestPriority(b)) || (totalDesirability(b) - totalDesirability(a))); | ||
| const takeoverAdIds = new Set(groups.flatMap(group => [...group.bidByAdUnit.values()].map(bid => bid.adId))); |
There was a problem hiding this comment.
Remove all bids from a rejected takeover group
When a bidder returns multiple responses with the same dealId for one ad unit, groupTakeovers retains only the best in bidByAdUnit, so this set leaves the alternates in otherBids. If that group is rejected (for example, it misses minSlots) and no other takeover wins that slot, decision.droppedAdIds contains only the representative; targetBidPoolHook therefore passes an alternate through, and the normal per-bidder targeting reduction can select it as a regular bid. A rejected page deal can then render on only part of the page; track and drop every response belonging to the group.
AGENTS.md reference: AGENTS.md:L129-L129
Useful? React with 👍 / 👎.
Docs for prebid/Prebid.js#16321. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop every bid of a rejected takeover, including repeat bids on an ad unit, and apply exclusivity only to ad units the takeover did not bid on, where its cost is counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both findings fixed in the latest commits, with a regression test for each:
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c357221588
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| const matched = scope.filter(code => group.bidByAdUnit.has(code)); | ||
| // exclusivity is only charged for, and only applied to, ad units the takeover did not bid on | ||
| const unmatched = eligibleCodes.filter(code => !matched.includes(code)); |
There was a problem hiding this comment.
Base exclusivity on actual takeover bids
A remaining case is viewport: matched contains only in-view slots, so an eligible off-screen slot with a bid in group.bidByAdUnit is classified as unmatched. If it has an excluded competitor bid, that bid is removed even though the takeover's off-screen bid is also dropped; when it is the only competitor, the slot is left empty although the takeover did not win it. If there is a same-tier in-view slot, the off-screen bid is also charged in the value hurdle. Build the exclusion set from actual bid presence or keep exclusivity within the winning scope.
Useful? React with 👍 / 👎.
| if (!decision) return true; | ||
| if (decision.droppedAdIds.has(bid.adId)) return false; | ||
| const winner = decision.winnerByAdUnit.get(bid.adUnitCode); | ||
| return winner == null || winner === bid.adId; |
There was a problem hiding this comment.
Filter cached bids from takeover-winning slots
When useBidCache: true and an unexpired bid from an earlier auction is present for a slot this takeover wins, that bid can have no winner in its own decision and pass through this branch. getBidsReceived() includes cached bids, so an older bid can then beat the takeover in the targeting pool even though the current decision reports that slot as won. Suppress other-auction bids on takeover-winning slots or include cached bids in the decision.
Useful? React with 👍 / 👎.
| if (!exclusivity) return false; | ||
| const domains = bid.meta?.advertiserDomains ?? []; | ||
| const categories = [bid.meta?.primaryCatId, ...(bid.meta?.secondaryCatIds ?? [])].filter(Boolean); | ||
| return domains.some(domain => exclusivity.adomain?.includes(domain)) || |
There was a problem hiding this comment.
Normalize advertiser domains before matching
When allowExclusivity is enabled and a bid reports an advertiser domain with different casing from the takeover's adomain list, this exact match misses it even though domain names are case-insensitive. The competitor is therefore neither charged nor dropped and can still be selected despite the exclusion; normalize both sides before comparing.
Useful? React with 👍 / 👎.
- Exclusivity only applies to ad units the takeover has no bid on, so off-screen ad units in viewport mode keep their competing bids. - The latest auction for an ad unit decides whether a takeover holds it, so cached bids from earlier auctions cannot displace a takeover. - Advertiser domains are matched case-insensitively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All three findings fixed in the latest commit, with a regression test for each:
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 252c653302
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| decisions.forEach(decision => decision.adUnitCodes.forEach(code => { | ||
| const winner = decision.winnerByAdUnit.get(code); | ||
| winnerByAdUnit.set(code, winner != null && inPool.has(winner) ? winner : undefined); |
There was a problem hiding this comment.
Order decisions by auction start time
When auctions for the same ad unit overlap and the older one finishes last, onAuctionEnd inserts its decision after the newer one, so this traversal lets the stale decision overwrite the newer slot result. Core marks latestAuctionForAdUnit when requestBids starts; with useBidCache: true, the older response remains in getBidsReceived(), and an older no-takeover decision can clear the current takeover winner here, letting that cached bid compete. Order decisions by auction start or otherwise ignore results older than the latest request for each ad unit.
Useful? React with 👍 / 👎.
Implements #15719 (whole page takeover on deal response) as an optional module, following the design discussed there: https://github.com/WhimsicalCoder/prebid-bundle-auction/blob/main/SPEC.md
Type of change
Description of change
Core (minimal):
libraries/ortbConverter/processors/deal.ts: normalizesext.prebid.deal.takeover(mode,min_slots,exclusivity) intobid.meta.deal.takeover; malformed fields are dropped.src/bidfactory.ts,src/types/ortb/ext/deal.d.ts:TakeoverMeta/TakeoverExttypes.src/constants.ts:EVENTS.TAKEOVER_RESULT.Module (
modules/takeover):dealid. Decided atauctionEnd; only one takeover wins an auction.premiumand the value of bids its exclusivity removes.all(every ad unit or none; rejected if a slot already rendered),max(min_slots/minSlotsFloor),viewport(ad units in view when bids are requested).acceptFrom=priority(default,allowPriorityBids),allowlist, ordeals.getHighestCpmBidsFromBidPool(same pattern as multibid); winners gethb_tko=1(andhb_exclfor exclusivity labels).meta.deal.takeover.groupIdon winning bids, plus atakeoverResultevent per takeover.blockRefresh,collapseUnfilled,excludeAdUnits.Testing
test/spec/modules/takeover_spec.js(43 tests, ~99% line coverage of the module), plus deal normalization tests intest/spec/ortbConverter/common_spec.js.npx gulp test-only: 968 files, 30,582 tests passed.npx gulp lint --nolintfixon changed files,npx gulp ts,npx gulp ts-strict: clean.Other information
Docs PR: prebid/prebid.github.io#7006
🤖 Design by WhimsicalCoder (see #15719); code and tests written with Claude Code.