BunchboxSdk

Creates a new instance of the Bunchbox SDK.

During development it is recommended to reduce the log level to debug.

new BunchboxSdk(token: string, opts: Object?): undefined
Parameters
token (string) the Bunchbox API token
opts (Object?)
Name Description
opts.strict Boolean (default true) flag that controls how strict errors are handled
opts.timeout Number (default 5000) timeout value (in milliseconds)
opts.logger Object? all logging- related options
opts.logger.colors Boolean (default true) controls the color output
opts.logger.level string (default 'info') the supported levels are:
- :trace - for very detailed debug-related messages
- :debug - for debug-related messages
- :info - for information of any kind
- :warn - for warnings
- :error - for errors
Returns
undefined:
Example
const bb = new BunchboxSdk('$yourToken')

activate

Buckets visitor into a variant and sends participation event.

If the referenced experiment has multiple steps an optional step index can be given to skip the evaluation of the step targeting.

Note: A given clientId will always be assigned to same variant of an experiment.

activate(args: Object, params: Object?): Promise<(string | false)>
Parameters
args (Object)
Name Description
args.clientId string the user id
args.experimentId string the experiment id
args.stepIndex number (default null) the step index
params (Object? = {}) the (targeting) parameters
Returns
Promise<(string | false)>: variation id
Example
const bb = new BunchboxSdk('$yourToken')

const variantId = await bb.activate({
  clientId: '43026325619819',
  experimentId: '5b475fb051ceab0190f68719'
})

track

Sends a conversion event.

For convenience neither the experimentId nor the goalIdentifier must be present. If both arguments are omitted effectively all experiments with all their goals are tracked. Passing in one or even both parameter(s) limits the events being tracked accordingly.

For example, passing in only an experimentId leads to all goals of the respective experiment being tracked. On the other hand, passing in just a goalIdentifier limits the result set to all experiments that have a goal matching that identifier.

track(args: Object, params: Object?): Promise<Boolean>
Parameters
args (Object)
Name Description
args.clientId string the user id
args.goalIdentifier string (default null) the goal identifier
params (Object? = {}) the (targeting) parameters
Returns
Promise<Boolean>: the result
Example
const bb = new BunchboxSdk('$yourToken')

await bb.track({ experimentId: '5b475fb051ceab0190f68719' })

reloadTestingFile

Triggers a reload of the testing file.

reloadTestingFile(): undefined
Returns
undefined:
Example
const bb = new BunchboxSdk('$yourToken')
bb.reloadTestingFile()

hash

JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)

hash(key: string, seed: number): number
Author: <a href='mailto:aappleby@gmail.com'>Austin Appleby</a>
Parameters
key (string) ASCII only
seed (number = 1) Positive integer only
Returns
number: 32-bit positive integer hash