Skip to content

Get splitTestAssignment from SDK bundle, if provided#304

Open
jplaroche wants to merge 1 commit into
masterfrom
jp/split-test-assignment
Open

Get splitTestAssignment from SDK bundle, if provided#304
jplaroche wants to merge 1 commit into
masterfrom
jp/split-test-assignment

Conversation

@jplaroche

Copy link
Copy Markdown
Contributor

and doesn't override if splitTestAssignment is already set (in case it is set server-side)

Why

Split-test assignment tagging (ortb2Imp.ext.optable.splitTestAssignment) is currently copy-pasted as a trackAuctionEnd monkey-patch across at least 4 SDK bundles (ezoic, britannica, publift, aditude — the latter merged just this week, #612). Each bundle wraps analytics(_v2).trackAuctionEnd identically to inject the same field before analytics processes the auction. Centralizing this in the SDK removes the duplication and the drift risk of bundles copy-pasting it slightly differently.

What Changed

  • addons/prebid/analytics.ts (v2) / addons/prototypes/analytics.js (v1): added optional getSplitTestAssignment?: () => string | undefined config callback.
  • trackAuctionEnd: when configured, tags every bid's ortb2Imp.ext.optable.splitTestAssignment with the callback's return value — skipped if the bid already has a splitTestAssignment set (e.g. set server-side upstream), so this never clobbers an existing value.
  • No-op (existing behavior unchanged) when getSplitTestAssignment is omitted.
  • Mapping/semantics of the assignment value (e.g. a bundle's 'none''test' relabeling) intentionally stay owned by the calling bundle, not baked into the SDK — the callback returns the final string to tag.

How to Test

  • npx jest lib/addons/prebid/analytics.test.ts — 5 new cases under trackAuctionEnd - split test assignment (no-op when unconfigured, tags all bids, does not override existing assignment, preserves other ext.optable fields). Full suite: 452/452 passing.
  • Tested
  • Docs / README updated (if public API changed)

Notes

  • Not breaking — new optional config field, fully backward compatible when omitted.
  • Follow-up (separate PRs, per bundle, after this ships): migrate ezoic, britannica, publift, aditude off their local trackAuctionEnd monkey-patch onto this config option.
  • Breaking change
  • Requires release - new SDK version needed before bundles can consume this

and doesn't override if splitTestAssignment is already set (in case it is set server-side)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant