All Projects → dollarshaveclub → Study

dollarshaveclub / Study

A simple, progressive, client/server AB testing library 📚

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Study

Simple Web Server
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
Stars: ✭ 2,261 (+671.67%)
Mutual labels:  server, client
Zserver4d
ZServer4D 是一套从商业项目剥离而出的云服务器中间件,可以承载百万级的分布式负载服务,并且支持IoT及内网穿透
Stars: ✭ 199 (-32.08%)
Mutual labels:  server, client
Qtswissarmyknife
QSAK (Qt Swiss Army Knife) is a multi-functional, cross-platform debugging tool based on Qt.
Stars: ✭ 196 (-33.11%)
Mutual labels:  server, client
Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (-44.03%)
Mutual labels:  server, client
Simplenetwork
simple TCP server / client C++ linux socket
Stars: ✭ 225 (-23.21%)
Mutual labels:  server, client
Unity Fastpacedmultiplayer
Features a Networking Framework to be used on top of Unity Networking, in order to implement an Authoritative Server with Lag Compensation, Client-Side Prediction/Server Reconciliation and Entity Interpolation
Stars: ✭ 162 (-44.71%)
Mutual labels:  server, client
Httpkit
⚡️ High-level, High-performance HTTP(S) Clients/Servers in Reason/OCaml
Stars: ✭ 198 (-32.42%)
Mutual labels:  server, client
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (-54.95%)
Mutual labels:  server, client
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (-28.67%)
Mutual labels:  server, client
Csharpgameframework
基于unity3d引擎与c#语言的游戏框架/架构(包括客户端与服务器)。使用ServerPlatform作为服务端通信基础设施。
Stars: ✭ 208 (-29.01%)
Mutual labels:  server, client
Gophertunnel
Toolbox for Minecraft software written in Go
Stars: ✭ 156 (-46.76%)
Mutual labels:  server, client
abba
A/B Testing framework
Stars: ✭ 16 (-94.54%)
Mutual labels:  experiment, ab-testing
Rolisteam
Rolisteam is a virtual tabletop. It helps you to manage tabletop role playing games with remote friends/players. It provides many features to share maps, pictures, dice roller, manage background music and much more. The main git repository is available here: [https://invent.kde.org/kde/rolisteam].
Stars: ✭ 151 (-48.46%)
Mutual labels:  server, client
Quarry
Python library that implements the Minecraft network protocol and data types
Stars: ✭ 182 (-37.88%)
Mutual labels:  server, client
Ether.network
https://github.com/Eastrall/Sylver
Stars: ✭ 147 (-49.83%)
Mutual labels:  server, client
Atlasr
Atlasr is a truly open-source and free map browser.
Stars: ✭ 196 (-33.11%)
Mutual labels:  server, client
Ocpp
Python implementation of the Open Charge Point Protocol (OCPP).
Stars: ✭ 127 (-56.66%)
Mutual labels:  server, client
Spreadsheet server
A python server harnessing the calculational ability of LibreOffice Calc (thanks to 'pyoo'). It provides 'instant' access to the cell ranges of a set of spreadsheets.
Stars: ✭ 132 (-54.95%)
Mutual labels:  server, client
Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+705.12%)
Mutual labels:  server, client
iter8
Kubernetes release optimizer
Stars: ✭ 217 (-25.94%)
Mutual labels:  experiment, ab-testing

A progressive, client/server AB testing library.

CircleCI codecov Greenkeeper badge npm bower

Study is an AB testing library designed to be clear, minimal, and flexible. It works in both the server and browser with the use of driver-based persistence layers.

You can download the compiled javascript directly here


Features

  • Powerful, clear API
  • Many variations. ABCD testing
  • Intelligent weighted bucketing
  • Browser & Server support
  • Storage Drivers: localStorage, cookies, memory, or build your own
  • Well documented, tested, and proven in high production environments
  • Lightweight, weighing in at ~ 3.8kb.
  • Not tested on animals

Installing

# Via NPM
npm i studyjs --save

# Via Bower
bower i studyjs --save

# Via Yarn
yarn add studyjs

Developing

npm install # Install dependencies
npm build # Build the babel'd version
npm lint # Run linting
npm test # Run tests

Usage

<script src="study.js"></script>
<script>

  // Set up our test API
  const test = new Study({
    store: Study.stores.local
  });

  // Define a test
  test.define({
    name: 'new-homepage',
    buckets: {
      control: { weight: 0.6 },
      versionA: { weight: 0.2 },
      versionB: { weight: 0.2 },
    }
  });

  // Bucket the user
  test.assign();

  // Fetch assignments at a later point
  const info = test.assignments();
</script>

API

Study(config)

const study = new Study({
  debug: true,
  store: Study.stores.local
});

This creates a new test API used to defined tests, assign buckets, and retrieve information.

Returns: Object

Name Type Description Default
debug Boolean Set to true to enable logging of additional information false
store Object An object with get/set properties that will accept information to help persist and retrieve tests Study.stores.local

study.define(testData)

// Create your test API
const study = new Study();

// Define a test
study.define({
  name: 'MyTestName',
  buckets: {
    variantA: { weight: 0.5 },
    variantB: { weight: 0.5 },
  },
});

This function defines the tests to be assigned to used during bucket assignment. This function accepts an object with two keys, name and buckets. Alternatively, you may pass an array of similar objects to define multiple tests at once.

The name value is the name of your test. The keys within bucket are your bucket names. Each bucket value is an object containing an object with an optional key weight that defaults to 1.

The percent chance a bucket is chosen for any given user is determined by the buckets weight divided by the total amount of all weights provided for an individual test. If you have three buckets with a weight of 2, 2/6 == 0.33 which means each bucket has a weight of 33%. There is no max for the total weights allowed.

Returns: null

Name Type Description Default
data Object/Array An object/array of objects containing test and bucket information null

study.assign(testName, bucketName)

const study = new Study();
study.define({
  name: 'new-homepage',
  buckets: {
    variantA: { weight: 0.5 },
    variantB: { weight: 0.5 },
  }
});

// Assign buckets from all tests to the user...
study.assign();

// or assign bucket from the specified test...
study.assign('new-homepage');

// or specify the bucket from the specified test...
study.assign('new-homepage', 'variantB');

// or remove the bucketing assignment from the specified test.
study.assign('new-homepage', null);

Calling the assign method will assign a bucket for the provided tests to a user and persist them to the store. If a user has already been bucketed, they will not be rebucketed unless a bucketName is explicitly provided.

If no arguments are provided, all tests will have a bucket assigned to the user. If the first argument provided is a test name, it will attempt to assign a bucket for that test to a user. If a bucketValue is provided, it will set that user to the specified bucket. If the bucketValue is null, it will remove that users assignment to the bucket.

Returns: null

Name Type Description Default
testName (optional) String The name of the test to assign a bucket to null
bucketName (optional) String The name of the bucket to assign to a user null

study.definitions()

const study = new Study();
study.define({
  name: 'new-homepage',
  buckets: {
    variantA: { weight: 0.5 },
    variantB: { weight: 0.5 },
  }
});

// Retrieve all of the provided tests
const tests = study.definitions();

This provides the user with all of the tests available.

The returned information will be an array if multiple tests were defined, otherwise, it will be an object of the single test defined. The object will mirror exactly what was provided in the define method.

Returns: Object|Array


study.assignments()

const study = new Study();
study.define({
  name: 'new-homepage',
  buckets: {
    variantA: { weight: 1 },
  }
});

// Capture assignments
study.assign();

// Retrieve all of the bucket assignments for the user
const buckets = study.assignments();
assert.strictEqual(buckets['new-homepage'], 'variantA');

This provides the user with all of the bucket assignments for the current user.

The returned information will be an object whose keys will be test names and values will be the current bucket assigned to the user.

// Example return
{
  'new-homepage': 'variantA',
  'some-test': 'some-bucket',
}

Returns: Object|Array


study.extendAssignments

Extending assignments can be a useful way to augment your Study implementation with third party software.

const study = new Study();

// Create a function that will modify assignments before you call `assignments`
study.extendAssignments =
  (assignments) => Object.assign(assignments, { foo: 'bar' })

// Retrieve all of the bucket assignments for the user
const buckets = study.assignments();
assert.strictEqual(buckets['foo'], 'bar');

A more practical example could be to implement with a third party AB testing platform like Optimizely (This uses pseudo code for brevity)

study.extendAssignments = (assignments) => {
  if (window.optimizely)
    for (const experiment in optimizely.experiments())
      assignments[experiment.name] = experiment.bucket

  return assignments
}

Returns: Object


Guide/FAQ

CSS Driven Tests

Tests logic may be potentially powered on solely CSS. Upon calling assign, if the script is running in the browser, a class per test will be added to the body tag with the test name and bucket in BEM syntax.

<body class="new-homepage--variantA"> <!-- Could be new-homepage--variantB -->
.new-homepage--variantA {
  /* Write custom styles for the new homepage test */
}

Storing metadata associated with tests

Each bucket provided may have additional metadata associated with it, and may have its value retrieved by retrieving the assignments and definitions.

const study = new Study();
study.define({
  name: 'new-homepage',
  buckets: {
    variantA: { weight: 1, foo: 'bar' },
  }
});

study.assign();

const defs = study.definitions();
const buckets = study.assignments();
const bucket = buckets['new-homepage'];
const bar = defs.buckets[bucket].foo; // "bar"

License

MIT Licensing

Copyright (c) 2015 - 2018 Dollar Shave Club

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].