0.0.2 • Published 6 years ago

microab v0.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

microab

MicroAB is an A/B Testing API for express applications. Typically A/B testing frameworks provide an SDK bundle which affects page load time. Microab is a thin middleware for express application enabling A/B testing via a node server with persistence in redis.

Dependencies

  1. redis
  2. Cookie parser
  3. uniqid

Installation

npm install --save microab

Usage

const microab = require('microab');
const cookieParser = require('cookie-parser');


app.use(cookieParser());

const microabClient = microab.createClient({
  redis: {
    host: 'localhost',
    port: 6379
  }
});

microabClient.createTests([{
  name: 'Red Button',
  duration: 1, // duration in days
  percentage: 80 // percentage traffic
}, {
  name: 'Green Dropdown',
  duration: 1,
  percentage: 5
}
]);

This will create 2 tests with their appt configs and store them in redis

Check Test Results

app.get('/', microabClient.checkFeatureResults('Red Button'), function (req, res) {
  console.log(res.locals);
  // use res.locals however you please
  res.send(res.locals);
});

This middleware will create an object in res.locals asper the test name for the home route. The middleware can used to check the ab test result for various routes.

{
  "Red Button" : true / false
}

This can now be used in your route handler, in which ever way the developer wishes to.

Local development

Start Redis

redis-server

To start

node examples/demo.js

http://localhost:3000/green
http://localhost:3000

should give you a response like this

{
  "Red Button" : true
}

Roadmap

  1. Complete basic test cases
  2. Create some for of tracking via a CLI interface
  3. Implement a web interface where tests can be addded and edited

Found a bug

File it here