Show:

(require("WebABTest"))(props) → {WebABTest}

...
Initializes an AB test experiment. Example props: webABTest({ name: 'nameOfExperiment', buckets: { unsampled: { samplingRate: 0.25 }, control: { samplingRate: 0.25 }, treatment1: { samplingRate: 0.25 }, treatment2: { samplingRate: 0.25 } }, token: 'token' });
Parameters:
Name Type Description
props WebABTestProps
Source:
Returns:
Type
WebABTest

Members

(inner) cachedBucket :string

...
Type:
  • string
Source:

Methods

(inner) getBucket() → {string}

...
Get the name of the bucket the subject is assigned to for A/B testing.
Source:
Throws:
Will throw an error if token is undefined and body tag has not been assigned a bucket.
Type
Error
Returns:
the name of the bucket the subject is assigned.
Type
string

(inner) getBucketFromHTML() → (nullable) {string}

...
Get the name of the bucket from the class added to the body tag.
Source:
Returns:
Type
string

(inner) getBucketNames() → {Array.<string>}

...
Get the names of all the buckets from props.buckets.
Source:
Returns:
Type
Array.<string>

(inner) init()

...
Initialize and fire hook to register A/B test enrollment if necessary.
Source:

(inner) isInBucket(targetBucket) → {boolean}

...
Determine if subject is in a particular bucket.
Parameters:
Name Type Description
targetBucket string The target test bucket.
Source:
Returns:
Whether the subject is in the test bucket.
Type
boolean

(inner) isInSample() → {boolean}

...
Whether or not the subject is included in the experiment.
Source:
Returns:
Type
boolean

(inner) isInTreatmentBucket(treatmentBucketNameopt) → {boolean}

...
Whether or not the subject has been bucketed in a treatment bucket as defined by the bucket name containing the case-insensitive 'treatment', 'treatment1', or 'treatment2' substring (e.g. 'treatment', 'treatment1', 'sticky-header-treatment1' and 'stickyHeaderTreatment2' are all assumed to be treatment buckets).
Parameters:
Name Type Attributes Description
treatmentBucketName string | null <optional>
lowercase name of bucket.
Source:
Returns:
Type
boolean

Type Definitions

SamplingRate

...
Type:
  • Object
Properties:
Name Type Description
samplingRate number The desired sampling rate for the group in the range [0, 1].
Source:

TreatmentBucketFunction(aopt) → {boolean}

...
Parameters:
Name Type Attributes Description
a string <optional>
Source:
Returns:
Type
boolean

WebABTest

...
Type:
  • Object
Properties:
Name Type Description
name string
getBucket function
isInBucket function
isInSample function
isInTreatmentBucket TreatmentBucketFunction
Source:

WebABTest

...
Type:
  • Object
Properties:
Name Type Description
name string
getBucket getBucket
isInBucket isInBucket
isInSample isInSample
isInTreatmentBucket isInTreatmentBucket
Source:

WebABTestProps

...
Type:
  • Object
Properties:
Name Type Attributes Description
name string The name of the experiment.
buckets Object Dict with bucket name as key and SamplingRate object as value. There must be an `unsampled` bucket that represents a population excluded from the experiment. Additionally, the treatment bucket(s) must include a case-insensitive `treatment` substring in their name (e.g. `treatment`, `stickyHeaderTreatment`, `sticky-header-treatment`).
token string <optional>
Token that uniquely identifies the subject for the duration of the experiment. If bucketing/server occurs on the server and the bucket is a class on the body tag, this can be ignored. Otherwise, it is required.
Source: