Skip to content

vgno/ably

Repository files navigation

ably

Build StatusTest CoverageCode Climate

Provides a sane model for dealing with A/B tests.

Install

Using npm:

npm install vgno-ably --save

Using bower:

bower install vgno-ably --save

Usage

Defining tests

var Ably = require('vgno-ably');

var ably = new Ably();

ably.addTest({
    name: 'button-color',
    sampler: ably.samplers.default({
        red: 80,
        green: 20
    }),
    scope: 'device'
});

The code above will create a test named button-color, sample 80% of people to the red variant and 20% to the green one and persist information about the experiment on the device - so that the user will get always the same variant on this device.

Subscribing to variants

ably
    .on('button-color', 'red', function () {
        $('#buy-button').css('background-color', 'red');
    })
    .on('button-color', 'green', function () {
        $('#buy-button').css('background-color', 'green');
    });

Subscribe to all variants of a test:

ably
    .on('button-color', function (test) {
        $('#buy-button').css('background-color', test.getAssignment());
    });

Model

Ably contains a collection of experiments.

An experiment has:

  • a name
  • a sampler which assigns users to variants
  • a scope which persists information about the experiment

API Reference

Read more about all supported options in the Documentation.

Browser tests

BrowserStack has gracefully agreed to provide us with a sponsored plan. We will soon start relying on their infrastructure to run automated browser tests.

BrowserStack logo

About

Provides a sane model for dealing with A/B tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published