1.0.2 • Published 7 years ago

experiment-api v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

experiment-api-javascript

Greenkeeper badge

Install

npm install experiment-api

Use

const experimentApi = require('experiment-api');
const Bucketer = experimentApi.bucketer.Bucketer;

const bucketConfiguration = {
  trafficAllocation:       75,
  trafficAllocationOffset: 0,
  bucketPercentages:       [
    25,
    30,
    30,
    15
  ]
};

const bucketer = new Bucketer(bucketConfiguration);
const bucketId = bucketer.getBucketId('some string like visitorId');

switch (bucketId) {
  case -1:
    console.log('No bucket');
    break;
  case 0:
    console.log('First bucket. 25% bucket');
    break;
  case 1:
    console.log('Second bucket. 30% bucket');
    break;
  case 2:
    console.log('Third bucket. 30% bucket');
    break;
  case 3:
    console.log('Forth bucket. 15% bucket');
    break;
  default:
    console.log('Should not happen');
    break
}
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago