Experiments
The ScaleBun.experiments namespace — 1 members.
import ScaleBun from '@scalebun/react-native';
ScaleBun.experiments.<method>(…);Members#
| Member | Signature |
|---|---|
variant | variant(key: string): string | null |
Reference#
variant#
ScaleBun.experiments.variant(key: string): string | nullNotes#
experiments.variant(key) returns the variant this user is assigned to, or null when they are not
in the experiment. It is the client half of the A/B and multivariate tests configured in the
dashboard.
null is a real answer and needs handling: it means no assignment — the experiment is not running,
the key is unknown, or configuration has not arrived yet. Treat it as "show the control".
Assignment must be read, not computed#
Do not derive a variant yourself from a user id or a random number. Assignment comes from the delivered configuration so that the dashboard and your app agree about who saw what. A locally computed variant makes experiment analytics meaningless, because the reported arms will not match the rendered ones.
Ordering#
init(), then identify(), then variant()
Assignment stability depends on a stable identifier, the same as rollouts. An unidentified user is bucketed per device.
Read once per exposure, at the moment of exposure
Not at launch, and not repeatedly in a render loop — hold the value in state for that screen.
Handle null as control
Every call site needs that branch. It is the state before configuration arrives, which is exactly when your first screen renders.
Limits and edge cases#
A user must stay in one arm. If assignment changes mid-experiment the results are invalid. This is why identity comes first.
Propagation delay applies — starting an experiment reaches devices with their next configuration fetch.
The metric must be tracked separately. This namespace assigns; it does not measure. Track the outcome event yourself.
Client-side assignment is visible to anyone inspecting the app, including which variants exist.