Giter Site home page Giter Site logo

split-test's Introduction

split-test

A support library to simplify split testing. We have a repository of working examples you can reference in https://github.com/mobify/adaptivejs-split-test-examples

Quickstart

Install split-test using npm:

$ npm install split-test --save-dev

Defining a split condition

var splitTest = SplitTest.init(
    {
        'A': 0.4,
        'B': 0.5,
        'C': 0.1
    },
    {
        namespace: 'foo'
    }
);

Obtaining the split value

splitTest.getChoice();

Methods

init

Adds a script to a custom container.

Parameter name Type Description
value Object The split condition
options Object The setup parameters
var splitTest = SplitTest.init(
    {
        'A': 0.4,
        'B': 0.5,
        'C': 0.1
    },
    {
        namespace: 'foo',
        cookieDomain: 'http://www.foo.com',
        lifetime: 15
    }
);

Available options

Options Type Description
namespace String The namespace of the cookie to prevent conflict between cookie names
cookieDomain String The domain of this cookie. Default to the hostname
lifetime Integer (milliseconds) The lifetime of the cookie. Default to 30 days.

getChoice

Returns the split choice key.

// This returns either 'A', 'B', or 'C'
var choice = splitTest.getChoice();

setChoice

Manually sets the split choice.

Parameter name Type Description
value String split choice key
splitTest.setChoice('C');

// This return 'C'
splitTest.getChoice();

How to create and ship a change

  • Make your code changes and create a pull-request
  • Ensure the tests still work (grunt test)
  • Get your change reviewed and ๐Ÿ‘'ed

Changelog

  • 1.0.0: Remove bower dependencies and dist folder, distribute on npm
  • 0.0.1: Initial commit

Where to get help

Talk to @jansepar or @dbader.

split-test's People

Contributors

jansepar avatar scalvert avatar

Stargazers

Kevin He avatar Spiro avatar John Boxall avatar  avatar

Watchers

Igor Faletski avatar Jeremy Wiebe avatar  avatar Loki Meyburg avatar  avatar Ira Mitchell avatar Gabriel Hernandez avatar Mike Klemarewski avatar Jose Barrios avatar James Cloos avatar Drewz avatar Zoe Hardisty avatar Seb Vetter avatar Mobify Deploy Bot avatar Jennifer Bandelin avatar  avatar Benjamin Terrill avatar  avatar Anton Bielousov avatar  avatar Artem Shananin avatar Vivian Chen avatar Anoop Aulakh avatar Derrick S avatar Kyle Young avatar David Fay avatar Jason Zhang avatar Oliver avatar Mahdi Soleimani avatar Michael Lee avatar Olivya Striloff avatar Jaybe Allanson avatar Cole Sanderson avatar Tina Wang avatar Chris Bildfell avatar  avatar Rob Schwartz avatar  avatar Karey Shumansky avatar Hussain Dhanani avatar Alicia Woodside avatar  avatar  avatar Aaron Metta avatar Kimberly Dextras-Romagnino avatar Stephen Cheung avatar  avatar  avatar Spiro avatar Mobot Robot avatar Richard Sexton avatar  avatar  avatar Yoony Jiyoon Ok avatar  avatar  avatar  avatar Yana Bobrysheva avatar  avatar Andre Ponnouradjane avatar Lansi Chu avatar Alex avatar  avatar Farnush Farhadi avatar Judah Okwuobi avatar James Semple avatar BenCRO avatar Obie Egwim avatar  avatar  avatar Bill Chung avatar Alex Myers avatar  avatar  avatar  avatar  avatar  avatar

split-test's Issues

Unguarded incorrect init usage and overly relaxed regex for getCookie

You can initialize a split test variable like this:

SplitTest.init('my-cookie')

This creates an invalid SplitTest instance where cookieName is split.

When you getChoice on this instance, getCookie grabs the first cookie that matches split=cookieVaue <-- this ignores that fact that any cookie ending with split is also being matched (ie. optimizely-split=something will match if it was earlier in the cookie string)

Defining lifetime option in SplitTest.init does nothing

When initializing split test with the lifetime option, the cookie will always set to 30 days regardless what the lifetime options is set to.

This is due to lifetime not being passed in from setChoice to setCookie.

    SplitTest.prototype.setChoice = SplitTest.prototype.setValue = function(value) {
        // Splits are stored for 30 days.
        SplitTest.setCookie(this.cookieName, value, this.cookieDomain);
    };

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.