0.0.20 • Published 5 years ago

node-ab-decider v0.0.20

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

CircleCI

Setup

npm install node-ab-decider

Use

const decider = require('node-ab-decider')
const choosen = "oldVariant"
const experiments = {
  variantA: {
    weight: 10,
    url: "https://exp-a.example.com/"
  },
  variantB: {
    weight: 20,
    url: "https://exp-b.example.com/"
  }
}
const x = decider(experiments, choosen)
// possible "x" value: {weight: 10, name:"variantA", url: "https://exp-a.example.com/"}

NOTE: If choosen is present the experiments object it doesn't run the choosing algorithm. If it's not present it re-run the process.

With Express

var app = require('express')();
const {middleware} = require('node-ab-decider')

const experiments = {
  variantA: {
    weight: 10,
    url: "https://exp-a.example.com/"
  },
  variantB: {
    weight: 20,
    url: "https://exp-b.example.com/"
  }
}

app.use(middleware(experiments, {
  // ...opts
}), (req,res)=>res.send('original'))

app.listen(2323,()=>console.log('running on 2323'))

Same logic but, it uses cookies to get the choosen or set the cookie.

Middleware options

maxAge

Expiration (in milliseconds) of the cookie

cookieName

Name of the cookie used to save the choosen exp

skip

Skip this middleware. Useful in dev mode.

hash

Hash added to the cookie. It is something like a version.

sendHeaderToChild

If false it avoids to send "ab-decider-child" header to the proxied endpoint

https

Force https to children

headers

Headers to include in every response

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago