Add client-side bidder support for Prebid.js#472
Open
ChristianPavilonis wants to merge 4 commits intomainfrom
Open
Add client-side bidder support for Prebid.js#472ChristianPavilonis wants to merge 4 commits intomainfrom
ChristianPavilonis wants to merge 4 commits intomainfrom
Conversation
… for Prebid Add support for running specific Prebid.js bidders client-side in the browser instead of routing all bidders through the server-side auction. Rust changes: - Add client_side_bidders field to PrebidIntegrationConfig - Serialize clientSideBidders into injected head config - Warn when a bidder appears in both bidders and client_side_bidders JS changes: - requestBids shim skips client-side bidders from trustedServer bidderParams - Build-time adapter generation via TSJS_PREBID_ADAPTERS env var - Runtime validation that client-side bidders have adapters loaded - Vite resolve alias for prebid.js/src/adapterManager.js (not in package exports map) Closes #471
- Add Vite resolve.alias for prebid.js/src/adapterManager.js in both vitest.config.ts and build-all.mjs since the prebid.js package exports map does not expose internal src/ paths - Wrap getBidAdapter() validation in try-catch for defensive robustness - Fix doc comment ordering so client_side_bidders and bid_param_zone_overrides each have their own doc block - Run prettier to fix format-typescript CI check
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
client_side_biddersconfig field — bidders in this list stay as standalone native Prebid.js bids and are not absorbed into thetrustedServeradapter.TSJS_PREBID_ADAPTERSenv var) so operators can control which native Prebid.js adapters are bundled without code changes.Auction flow
flowchart TD A["Publisher Page<br/>pbjs.requestBids()"] --> B["requestBids Shim<br/>(tsjs-prebid)"] B --> C{"Is bidder in<br/>clientSideBidders?"} C -- "Yes (e.g. rubicon)" --> D["Leave as standalone bid<br/>Native Prebid.js adapter"] C -- "No (e.g. kargo, appnexus)" --> E["Absorb into trustedServer<br/>bidderParams"] E --> F["POST /auction<br/>Trusted Server Orchestrator"] F --> G["Prebid Server (PBS)<br/>OpenRTB 2.x auction"] G --> H["Server-side bids returned<br/>(kargo, appnexus, etc.)"] D --> I["Client-side bid<br/>(rubicon via rubiconBidAdapter.js)"] H --> J["Prebid.js auction<br/>All bids compete"] I --> J J --> K["Winning bid rendered"] style C fill:#f9f,stroke:#333 style D fill:#bfb,stroke:#333 style E fill:#bbf,stroke:#333Configuration example
Changes
crates/common/src/integrations/prebid.rsclient_side_bidders: Vec<String>toPrebidIntegrationConfigwith#[serde(default, deserialize_with)]; added field toInjectedPrebidClientConfigwithskip_serializing_if; added duplicate-bidder warning when a bidder appears in both lists; updatedbase_config()test helper; added 2 tests for head injector serializationcrates/js/lib/src/integrations/prebid/index.ts_adapters.generated.ts) andadapterManager; addedclientSideBidderstoInjectedPrebidConfiginterface; reads config into aSet; skips client-side bidders when buildingbidderParamsfortrustedServer; validates that each client-side bidder has a registered adapter at initcrates/js/lib/src/integrations/prebid/_adapters.generated.tsimportstatements for each adapter listed inTSJS_PREBID_ADAPTERS(defaults torubicon)crates/js/lib/build-all.mjsgeneratePrebidAdapters()that readsTSJS_PREBID_ADAPTERSenv var, validates adapter modules exist inprebid.js/modules/, and writes_adapters.generated.ts; added Viteresolve.aliasforprebid.js/src/adapterManager.jscrates/js/lib/vitest.config.tsresolve.aliasforprebid.js/src/adapterManager.jsso tests can resolve the modulecrates/js/lib/test/integrations/prebid/index.test.ts_adapters.generated.tsandadapterManager; added 8 new tests covering client-side bidder edge casescrates/js/lib/package-lock.jsontrusted-server.tomlrubiconfrombiddersto newclient_side_bidders; added documentation commentCloses
Closes #471
Closes #463
Known limitations
TSJS_PREBID_ADAPTERSat build time (e.g.TSJS_PREBID_ADAPTERS=rubicon,appnexus) and rebuilding the JS bundle — no code changes needed.biddersandclient_side_bidderslists are independent — the operator manages both explicitly. A warning is logged at startup if a bidder appears in both.Test plan
cargo test --workspacecargo clippy --all-targets --all-features -- -D warningscargo fmt --all -- --checkcd crates/js/lib && npx vitest runcd crates/js/lib && npm run formatcd docs && npm run format— pre-existing:prettiernot installed indocs/cargo build --bin trusted-server-fastly --release --target wasm32-wasip1fastly compute serveChecklist
unwrap()in production code — useexpect("should ...")tracingmacros (notprintln!)