mw.experiments

Provides an API for bucketing users in experiments.

Methods

getBucket(experiment, token) → {string|undefined}static #

Gets the bucket for the experiment given the token.

The name of the experiment and the token are hashed. The hash is converted to a number which is then used to get a bucket.

Example

// The experiment has three buckets: control, A, and B. The user has a 50% chance of
// being assigned to the control bucket, and a 25% chance of being assigned to either
// the A or B bucket. If the experiment were disabled, then the user would always be
// assigned to the control bucket.
{
  name: 'My first experiment',
  enabled: true,
  buckets: {
    control: 0.5
    A: 0.25,
    B: 0.25
  }
}

Parameters:

Name Type Description
experiment Object
Properties:
Name Type Description
name string

The name of the experiment

enabled boolean

Whether or not the experiment is enabled. If the experiment is disabled, then the user is always assigned to the control bucket

buckets Object

A map of bucket name to probability that the user will be assigned to that bucket

token string

A token that uniquely identifies the user for the duration of the experiment

Source:

Returns:

The bucket

Type
string | undefined
Gets the bucket for the experiment given the token.