Coder Social home page Coder Social logo

laboratory's Introduction

Build Status Dependencies devDependencies NPM version

Laboratory

Simple A/B Testing Framework for both client and server environments.

Laboratory chooses a variant for each experiment based on a configurable probability. Use the pluggable storage interface to serve users a consistent experience after they've been assigned a variant.

$ npm install laboratory

Example Usage

Run a single Experiment:

{Experiment} = require "laboratory"

experiment = new Experiment("color")
  .variant "red", 50, "#FF0000"
  .variant "blue", 50, "#0000FF"

variant = experiment.run()
variant.name # Either red or blue
variant.value # Either FF0000 or 0000FF

Run a suite of experiments in a Laboratory:

{Laboratory} = require "laboratory"
laboratory = new Laboratory()

laboratory.addExperiment("color")
  .variant "red", 50, "#FF0000"
  .variant "blue", 50, "#0000FF"

laboratory.addExperiment("FuzzyBunnies")
  .variant "variant0", 50,
    name: "Peter Rabbit"
    type: "Wooly"
  .variant "variant1", 50,
    subject: "Briar Rabbit"
    type: "Silky"

experiment = laboratory.run("FuzzyBunnies")
experiment.value # Either Peter or Briar Rabbit

Store the results per user in browser local storage:

store = new LocalStorageStore() # not included
laboratory = new Laboratory(store)

laboratory.addExperiment /* ... */
laboratory.run /* ... */

laboratory's People

Contributors

duereg avatar hurrymaplelad avatar sylspren avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laboratory's Issues

Ignore invalid variant names in store

We get into an awkward case when the the store contains a value which is not a variant name. I think the best thing to do in this case is to re-run the experiment. PR coming...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.