Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Latest commit

 

History

History
73 lines (58 loc) · 1.84 KB

README.md

File metadata and controls

73 lines (58 loc) · 1.84 KB

abtest

NPM version build status Test coverage David deps node version Gittip

an A/B test client for node web

Installation

$ npm install abtest

Feature

  • Random split user into different buckets.
  • Record user's bucket in cookie.
  • Force choose bucket by query.
  • Expire cookie when buckets changed.

Usage

use with koa:

var ABTest = ABTest();
var app = koa();

app.use(function* (next) {
  this.abtest = ABTest({
    getCookie: function () {},  // custom your getCookie method
    setCookie: function () {},  // custom your setCookie method
    query: this.query
  });
});

app.use(function* (next) {
  this.abtest.configure({
    bucket: {
      a: 9,
      b: 1
    },
    enableQuery: true,
    enableCookie: true
  });
});

app.use(function* (next) {
  this.body = this.abtest.bucket; // 10% a, 90% b
});

License

MIT