abtest
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