ScaleBun
Skip to article

Experiments

react-nativeDeveloperv0.1.0-alpha.4

The ScaleBun.experiments namespace — 1 members.

Updated Reviewed
TypeScript
import ScaleBun from '@scalebun/react-native';
ScaleBun.experiments.<method>(…);

Members#

MemberSignature
variantvariant(key: string): string | null

Reference#

variant#

TypeScript
ScaleBun.experiments.variant(key: string): string | null

Notes#

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#

  1. init(), then identify(), then variant()

    Assignment stability depends on a stable identifier, the same as rollouts. An unidentified user is bucketed per device.

  2. 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.

  3. 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.

Experiments · API reference · React Native SDK · ScaleBun