# abatar

> A/B testing minion

Latest version **0.4.1** (published 2015-08-24) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install abatar
pnpm add abatar
yarn add abatar
bun add abatar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2015-08-24 |
| First published | 2015-01-05 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Danny Coates |
| Maintainers | dannycoates |

## Links

- npm: https://www.npmjs.com/package/abatar
- Repository: https://github.com/dannycoates/abatar
- Homepage: https://github.com/dannycoates/abatar#readme
- Issues: https://github.com/dannycoates/abatar/issues
- npm.io page: https://npm.io/package/abatar

## Dependencies (1)

- [js-sha1](https://npm.io/package/js-sha1.md) 0.2.0

## Recent versions

- 0.4.1 (latest) — 2015-08-24
- 0.4.0 — 2015-04-29
- 0.3.1 — 2015-04-26
- 0.3.0 — 2015-04-15
- 0.2.7 — 2015-03-15
- 0.2.6 — 2015-03-11
- 0.1.0 — 2015-01-05

## README

abatar A/B testing framework
============================

A workflow for testing and releasing application features.

[![Build Status: Travis](https://travis-ci.org/dannycoates/abatar.svg?branch=master)](https://travis-ci.org/dannycoates/abatar)

# Example

I've got a web app that I'd like to do some A/B testing on.

**App**

In the app js that runs in the browser I do something like this:

```js
// Initialize an AB instance with some session data
var ab = AB.create({
  niceCaptchaEnabled: false //default value
})
ab.subject.sessionId = session.id

//...

if (ab.choose('niceCaptchaEnabled')) {
  ui.showCaptcha()
}

//...
// At some point send a report of ab activity to an be analyzed.
// The details of which are beyond the scope of this library.
analyser.send(otherMetrics, ab.report())
```

**Experiment**

On the server I deploy a new experiment that looks like this:

```js
{
  name: 'captcha',
  hypothesis: 'a niceCaptcha does not negatively affect signups',
  startDate: '2014-12-15',
  subjectAttributes: ['sessionId'],
  independentVariables: ['niceCaptchaEnabled'],
  eligibilityFunction: function (subject) {
    // a random sampling of 10% of sessions will be in the experiment
    return this.bernoulliTrial(0.1, subject.sessionId)
  },
  groupingFunction: function (subject) {
    // 50% of participants will see a niceCaptcha the rest are the control group
    return {
      niceCaptchaEnabled: this.bernoulliTrial(0.5, subject.sessionId)
    }
  }
}
```

`niceCaptchaEnabled` is the variable that the app uses to determine whether
to display the captcha. Before the experiment goes live it will use the
default value, false. Once the experiment is live, it will use the `sessionId`
set by the app to determine whether it is eligible with the `eligibilityFunction`;
if not it will get the default, otherwise it gets enrolled in the experiment and
the  `groupingFunction` determines the value. In this example 5% of sessions
will have `niceCaptchaEnabled` set to true.

The analysis to test the hypothesis is beyond the scope of this library at
this time but a simple report of experiments can be created with `ab.report()`
and sent to an existing logging system.

See the "Lifecycle" section for details on how experiments are concluded.

For more examples see `doc/cookbook.md`

# Format

Experiments are defined with javascript objects. Since experimentation is a
process, not just a static declaration, the experiment will change properties
over time through its lifecycle. Not all experiments include all of these
properties and an individual experiment will add properties over time.

## Properties

***name***

    A short unique string for identifing the experiment.

***hypothesis***

    A text description of the experiment.

***startDate***

    The date when the experiment starts. (ISO 8601 format)

***endDate***

    The date when the experiment ends. (ISO 8601 format)

***subjectAttributes***

    The variables provided by the application to the experiment.
    These are typically used by experiments to determine eligibility
    and which experimental group the subject should be in.

***independentVariables***

    The variables provided by the experiment to the application.
    These are the variables the application needs for its configuration.

***eligibilityFunction***

    A javascript function that may use `subjectAttributes` to determine
    if the subject is eligible for the experiment.

***groupingFunction***

    A javascript function that returns values for the `independentVariables`
    based on the `subjectAttributes`.

***conclusion***

    The final values for `independentVariables` after the experiment
    is complete.

***release***

    The dates and strategy for releasing the `conclusion` to all clients.


# Lifecycle

## Phases

1. *New*
2. *Live*
3. *Concluded*
4. *Releasing*
5. *Complete*

## New

An experiment whose `startDate` is in the future is new. Unsurprisingly, it will
not do anything or affect other experiments, but is useful for iterating on the
details before unleashing it on the world. It is the starting state of all
experiments.

## Live

An experiment can transition to live when time catches up to the `startDate`.

## Concluded

An experiment is concluded when analysis has determined a `conclusion`. An
experiment with no conclusion but with an `endDate` skips directly to complete
and is considered aborted.

The conclusion is not automatically released. If an `endDate` is set, the
conclusion will be released all at once on that date and become complete. If a
`release` is set the experiment will transition to releasing.

If neither `endDate` nor `release` are set the experiment will continue running
as if no conclusion has been reached. This may be useful when analysis has
determined a conclusion but the descision about how to release it has not yet
been made.

## Releasing

An experiment that has reached a conclusion and is in the process of
releasing it to all subjects whether they were part of the experiment during
the live phase or not.

## Complete

The experiment is complete and the `conclusion` can be made the default value
in the application.

---
_Source: https://npm.io/package/abatar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
