All Projects → 7anshuai → abba

7anshuai / abba

Licence: MIT license
A/B Testing framework

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to abba

VariantRetriever
VariantRetriever is a minimalist package for feature flagging
Stars: ✭ 23 (+43.75%)
Mutual labels:  experiment, ab-testing
Study
A simple, progressive, client/server AB testing library 📚
Stars: ✭ 293 (+1731.25%)
Mutual labels:  experiment, ab-testing
iter8
Kubernetes release optimizer
Stars: ✭ 217 (+1256.25%)
Mutual labels:  experiment, ab-testing
React Lessons
Tool for creating and taking interactive React tutorials
Stars: ✭ 103 (+543.75%)
Mutual labels:  experiment
Modelchimp
Experiment tracking for machine and deep learning projects
Stars: ✭ 121 (+656.25%)
Mutual labels:  experiment
Aimandshoot
A neuroevolution game experiment.
Stars: ✭ 201 (+1156.25%)
Mutual labels:  experiment
php-client
PHP SDK client for Split Software
Stars: ✭ 14 (-12.5%)
Mutual labels:  ab-testing
Fb Android Crash
How to crash the integrated browser in FB for Android? Let's open that URL!
Stars: ✭ 89 (+456.25%)
Mutual labels:  experiment
android-projects
Android benchmark projects for Bazel and Gradle
Stars: ✭ 29 (+81.25%)
Mutual labels:  ab-testing
Clearml Server
ClearML - Auto-Magical Suite of tools to streamline your ML workflow. Experiment Manager, ML-Ops and Data-Management
Stars: ✭ 186 (+1062.5%)
Mutual labels:  experiment
Isomorphic Lab
Isomorphic React experimentation
Stars: ✭ 144 (+800%)
Mutual labels:  experiment
Thegoodman
An experiment with basic CSS3 animations.
Stars: ✭ 128 (+700%)
Mutual labels:  experiment
Chat
A simple chat app created to experiment with Redis, Gevent, Flask & Server-Sent Events.
Stars: ✭ 202 (+1162.5%)
Mutual labels:  experiment
Pseudo Python
a restricted python to javascript / c# / go / ruby compiler
Stars: ✭ 106 (+562.5%)
Mutual labels:  experiment
nodegame-server
nodeGame server for the browser and node.js
Stars: ✭ 17 (+6.25%)
Mutual labels:  experiment
Offline Gallery
🎈 A 16kb Preact & Redux based Progressive Web App that offers an offline gallery experience of external images.
Stars: ✭ 90 (+462.5%)
Mutual labels:  experiment
java-client
Java SDK client for Split Software
Stars: ✭ 20 (+25%)
Mutual labels:  ab-testing
Design Of Experiment Python
Design-of-experiment (DOE) generator for science, engineering, and statistics
Stars: ✭ 143 (+793.75%)
Mutual labels:  experiment
Clearml
ClearML - Auto-Magical CI/CD to streamline your ML workflow. Experiment Manager, MLOps and Data-Management
Stars: ✭ 2,868 (+17825%)
Mutual labels:  experiment
Morse Learn
A fun little web app to help you learn Morse code on Gboard.
Stars: ✭ 140 (+775%)
Mutual labels:  experiment

abba Build Status Greenkeeper badge

abba is a simple a/b testing framework for JavaScript and Node.js.

It's a node.js clone with small improvement over @maccman's Abba.

Features

  • Simple JavaScript API
  • Multi variant support
  • Filter results by date and browser

Requirements

  • Node.js 6+
  • MongoDB

Getting started

# Clone the project
git clone https://github.com/7anshuai/abba
cd abba

# Install dependencies
npm install

# or if you're using Yarn
yarn

Then you can begin development:

# yarn
yarn run dev

# npm
npm run dev

This will launch a nodemon process for automatic server restarts when your code changes.

Testing

Testing is powered by Mocha. This project also uses supertest for demonstrating a simple routing smoke test suite.

Start the test runner with:

# yarn
yarn test

# npm
npm test

You can also generate coverage with:

# yarn
yarn run cover

# npm
npm run cover

Linting

Linting is set up using ESLint. It uses ESLint's default eslint:recommended rules.

Begin linting in watch mode with:

# yarn
yarn run lint

# npm
npm run lint

Environmental variables in development

The project uses dotenv for setting environmental variables during development. Simply copy .env.example, rename it to .env and add your env vars as you see fit.

It is strongly recommended never to check in your .env file to version control. It should only include environment-specific values such as database passwords or API keys used in development. Your production env variables should be different and be set differently depending on your hosting solution. dotenv is only for development.

Using docker in development

You will need docker and docker-compose installed to build the application.

After installing docker, start the application with the following commands:

# To build the project for the first time or when you add dependencies
$ docker-compose build web

# To start the application (or to restart after making changes to the source code)
$ docker-compose up web

To view the app, find your docker ip address + port 8080 ( this will typically be http://192.168.99.100:8080/ ).

Deployment

Deployment is specific to hosting platform/provider but generally:

# yarn
yarn run build

# npm
npm run build

will compile your src into /dist, and

# yarn
yarn start

# npm
npm start

will run build (via the prestart hook) and start the compiled application from the /dist folder.

The last command is generally what most hosting providers use to start your application when deployed, so it should take care of everything.

A/B Testing API

First include abba.js using a script tag. The host of this url will need to point to wherever you deployed the app.

<script src="//localhost:8080/scripts/abba.js"></script>

Then call Abba(), passing in a test name and set up the control test and variants.

<script>
  Abba('test name')
    .control('test a', function(){ /* ... */ })
    .variant('test b', function(){ /* ... */ })
    .start();
</script>

The control is whatever you're testing against, and is usually the original page. You should only have one control (and the callback can be omitted).

The variants are the variations on the control that you hope will improve conversion. You can specify multiple variants. They require a variant name, and a callback function.

When you call start() Abba will randomly execute the control or variants' callbacks, and record the results server side.

Once the user has successfully completed the experiment, say paid and navigated to a receipt page, you need to complete the test. You can do this by invoking complete().

<script>
  // On successful conversion
  Abba('test name').complete();
</script>

You can find an example under ./public/test.

options

Persisting results

If set the persist option to true, then the experiment won't be reset once it has completed. In other words, that visitor will always see that particular variant, and no more results will be recorded for that visitor.

<script>
  Abba('Pricing', {persist: true}).complete();
</script>

Weighting

You can set a variant weight, so some variants are used more than others:

Abba('My Checkout')
  .control('Control', {weight: 20})
  .variant('Variant 1', {weight: 3}, function(){
    $('#test').text('Variant 1 was chosen!');
  })
  .variant('Variant 2', {weight: 3}, function(){
    $('#test').text('Variant 2 was chosen!');
  })
  .start();

In the case above, the Control will be invoked 20 times more often than the other variants.

Flow control

You can continue a previously started test using continue().

Abba('My Checkout')
  .control()
  .variant('Variant 1', function(){
    $('#test').text('Variant 1 was chosen!');
  })
  .variant('Variant 2', function(){
    $('#test').text('Variant 2 was chosen!');
  })
  .continue();

Nothing will be recorded if you call continue() instead of start(). If a variant hasn't been chosen previously, nothing will be executed.

You can reset tests using reset().

Abba('My Checkout').reset();

Lastly, you can calculate the test that you want to run server side, and just tell the JavaScript library which flow was chosen.

Abba('My Checkout').start('Variant A');

Links

If you're triggering the completion of a test on a link click or a form submit, then things get a bit more complicated.

You need to ensure that tracking request doesn't get lost (which can happen in some browsers if you request an image at the same time as navigating). If the link is navigating to an external page which you don't control, then you have no choice but to cancel the link's default event, wait a few milliseconds, then navigate manually:

<script>
  $('body').on('click', 'a.external', function(e){
    // Prevent navigation
    e.preventDefault();
    var href = $(this).attr('href');

    Abba('My Links').complete();

    setTimeout(function(){
      window.location = href;
    }, 400);
  });
</script>

That's far from ideal though, and it's much better to place the tracking code on the page you're going to navigate to. If you have control over the page, then add the following code that checks the URL's hash.

<script>
  if (window.location.hash.indexOf('_abbaTestComplete') != -1) {
    Abba('My Links').complete();
  }
</script>

Then add the hash to the link's URL:

<a href="/blog#_abbaTestComplete">

License

MIT License. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].