Repository navigation
Bid selector for winner override - #964
Draft
mdanylov-sigma wants to merge 2 commits into
Draft
mdanylov-sigma wants to merge 2 commits into
mdanylov-sigma wants to merge 2 commits into
Conversation
Collaborator
Author
|
I put together a full proposal: problem statement, API shape (shown as pseudocode), design rationale for each non-obvious decision, alternatives considered, and open questions for maintainers. Posting it for review before this PR goes further. Full doc, Part I. |
mdanylov-sigma
marked this pull request as draft
July 16, 2026 13:39
2 of 3 tasks
Aligns the bid selector with Part I of the API proposal linked from prebid/prebid-mobile-ios#950, the same way as prebid/prebid-mobile-ios#1276: - The selector is a plugin: PrebidBidSelecting gains getPluginInfo(), selectBid(bids, context) and default onRegister/onUnregister, and is registered with PrebidMobile.registerPlugin(selector, PluginCapability.BID_SELECTOR). At most one is active. The per-ad-unit setBidSelector methods are gone. - The selection runs in BidLoader after the response is parsed, once, on the main thread, over the eligible bids: with filterOutUncachedBids the Original API offers only cached bids. Rendering gets no new cache requirement. - A null or foreign result is a load error with no winner; there is no fallback to the server's winner or to the cached-bid promotion. - Targeting comes from the selected bid alone. Generic keys are filled in from its bidder-specific keys, resolving aliases and truncated keys; no other bid's keys are merged. - If an ad server integration can't get the winner keys for the selected bid, the load fails with the new ResultCode/FetchDemandResult INVALID_TARGETING. Standalone Rendering ad units don't need the keys. - The hb_* key literals now come from one TargetingKey class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mdanylov-sigma
force-pushed
the
feature/950-bid-selector
branch
from
November 11, 2026 20:09
ecc3ca3 to
b814ae7
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the bid selector from Part I of the API proposal linked from prebid/prebid-mobile-ios#950 (part 2 of the issue: let the publisher override the SDK's winner). It's the Android twin of prebid/prebid-mobile-ios#1276 and has the same public shape.
The selector is a plugin. Register it once and it applies to every ad unit of the Original, Rendering and Mediation APIs:
Workflow (proposal 1.4.1)
With no selector registered, nothing changes. With one registered,
BidLoaderruns the selection right after parsing the response:setFilterOutUncachedBids(true), the Original API offers only bids with a Prebid Cache entry (they are already filtered while parsing). The Rendering API gets no new cache requirement.selectBid(bids, context)once, on the main thread (the network task delivers the response there).contextgives the ad unit's config ID and ad formats, since one selector now serves all ad units.null, or an object that isn't one of the given bids (logged), ends the auction with no winner:NO_BIDS, no keywords, no rendering, no winner tracking. There is no fallback to the server's winner or to the cached-bid promotion.hb_pb,hb_bidder,hb_size,hb_format,hb_deal,hb_cache_id,hb_uuid,hb_cache_host,hb_cache_path,hb_env) from its bidder-specific keys. The bidder code comes from the bid's ownhb_bidder_<code>, so aliases work, and keys that Prebid Server truncated are matched by prefix. If a key could match more than one entry, the targeting is invalid rather than guessed. Missing optional keys stay missing, and no other bid's keys are merged. The SDK writes the result to the selected bid's targeting too, so the code that reads the winning bid directly (GAM event handlers, win notifier) sees the same set.hb_pbandhb_bidder(plushb_cache_idwhen the cache is used, as for the default winner), the auction ends with the newResultCode.INVALID_TARGETING/FetchDemandResult.INVALID_TARGETINGand nothing is attached. Standalone Rendering ad units render the bid's markup, so they don't need the keys.Changes since the first version of this PR
BaseInterstitialAdUnitandBidResponse). The selector now uses the plugin registry from Add the plugin registry and PrebidMobile.registerPlugin (plugin system, step 1) #1054.setBidSelectoronAdUnitConfiguration,PrebidRequest,BannerView, the interstitial/rewarded ad units and the Mediation ad units is removed in favour ofPrebidMobile.registerPlugin(selector, PluginCapability.BID_SELECTOR)(proposal 1.4.2).BidResponseconstructor intoBidLoader, after the response is parsed and filtered.hasBidSelectorRejectedAllBids()and the per-ad-unitNO_BIDSchecks are gone: a rejection is a load error.hb_pb/hb_bidder/hb_cache_idwere stripped from them, so a runner-up pick still left the server winner's other generic keys in the targeting.hb_*key literals (BidResponse,WinNotifier,AdUnit) now come from one restrictedTargetingKeyclass.Public API
PrebidBidSelecting:getPluginInfo(),selectBid(List<Bid>, BidSelectionContext), defaultonRegister()/onUnregister().BidSelectionContext:getConfigId(),getAdFormats().PluginCapability.BID_SELECTOR: at most one selector is registered. A second registration is ignored with a warning.ResultCode.INVALID_TARGETING,FetchDemandResult.INVALID_TARGETING.Open points for review
BidSelectionContextis where per-impression data, such as an impression ID, would go later.Test plan
BidSelectorTest(23): registration and the one-selector limit, default path unchanged, selection, main thread, null and foreign results, eligibility with and withoutsetFilterOutUncachedBids, targeting validation (includinghb_cache_idwhen the cache is used), standalone rendering ad units, and the key mapping (aliases, truncation, other key families, ambiguity).AdUnitConfigurationTest: the copy constructor keeps the newrendersWithoutAdServerflag.🤖 Generated with Claude Code