feat(ab-test): add selectABTest addon for split test selection and persistence#279
Open
MO-Thibault wants to merge 2 commits intoOptable:masterfrom
Open
feat(ab-test): add selectABTest addon for split test selection and persistence#279MO-Thibault wants to merge 2 commits intoOptable:masterfrom
MO-Thibault wants to merge 2 commits intoOptable:masterfrom
Conversation
…rsistence Extracts A/B test selection logic from wrapper bundles into a reusable addon: - calculateTrafficPercentages: fills missing trafficPercentage values evenly - determineABTest: weighted random bucket selection (mirrors lib/edge/targeting.ts) - selectABTest: full selection flow — forced overrides via sessionStorage (optableInclude<ID>, optableResolve<ID>, optableExclude<ID>), excludes marked tests, falls back to random, persists result to OPTABLE_SPLIT_TEST OptablePrebidAnalytics accepts config.selectedTest (result of selectABTest) and includes selectedABTest in every auction_processed witness payload. Wrappers can replace calculateTrafficPercentages + determineABTest + splitTestSelection with a single selectABTest() call.
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
Extracts A/B test selection logic that lives duplicated across wrapper bundles into a reusable addon at
lib/addons/prototypes/ab-test.js.Exports:
calculateTrafficPercentages(abTests)— fills missingtrafficPercentagevalues by distributing the remaining % evenlydetermineABTest(abTests)— weighted random bucket selection (mirrorslib/edge/targeting.ts)selectABTest(abTests)— full selection flow: forced overrides → exclude filter → random selection → persist tosessionStorage.OPTABLE_SPLIT_TESTsessionStorage override keys (value
"1"or"true"to activate):optableInclude<ID>/optableResolve<ID>— force a specific testoptableExclude<ID>/optableInclude<ID>=false— exclude a test from random selectionOptablePrebidAnalyticsacceptsconfig.selectedTest(the result ofselectABTest) and includesselectedABTestin everyauction_processedwitness payload.Migration for wrappers
Wrappers can drop:
calculateTrafficPercentages,determineABTest,splitTestSelection, and thecustomAnalytics.selectedABTestblock.Test plan
selectABTestreturns null for empty/null inputtrafficPercentageoptableIncludeNONE=1selects thenonetest regardless of randomoptableExcludeNONE=1removesnonefrom random poolsessionStorage.OPTABLE_SPLIT_TESTselectedABTestappears in witness payload whenconfig.selectedTestis set