All Projects β†’ nkoehring β†’ vue-a2b

nkoehring / vue-a2b

Licence: MIT license
Split Testing for Vue.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-a2b

growthbook
Open Source Feature Flagging and A/B Testing Platform
Stars: ✭ 2,342 (+2756.1%)
Mutual labels:  ab-testing, split-testing
mojito
πŸ§ͺ Source-controlled split testing stack for building, launching and analysing A/B tests.
Stars: ✭ 49 (-40.24%)
Mutual labels:  ab-testing, split-testing
Motorhead
A Rails Engine framework that helps safe and rapid feature prototyping
Stars: ✭ 182 (+121.95%)
Mutual labels:  ab-testing
proctor-webapp
Proctor-webapp is a web application for managing Proctor A/B test definitions.
Stars: ✭ 16 (-80.49%)
Mutual labels:  ab-testing
abba
A/B Testing framework
Stars: ✭ 16 (-80.49%)
Mutual labels:  ab-testing
Node Ab
A command tool to test the performance of HTTP services.
Stars: ✭ 200 (+143.9%)
Mutual labels:  ab-testing
causeinfer
Machine learning based causal inference/uplift in Python
Stars: ✭ 45 (-45.12%)
Mutual labels:  ab-testing
Izanami
Izanami is a shared configuration, feature flipping and A/B testing server well-suited for micro-service architecture implementation.
Stars: ✭ 133 (+62.2%)
Mutual labels:  ab-testing
react-client
React JS SDK client for Split Software
Stars: ✭ 23 (-71.95%)
Mutual labels:  ab-testing
iter8
Kubernetes release optimizer
Stars: ✭ 217 (+164.63%)
Mutual labels:  ab-testing
experiment
A/B cookie testing tool for @laravel
Stars: ✭ 55 (-32.93%)
Mutual labels:  ab-testing
php-client
PHP SDK client for Split Software
Stars: ✭ 14 (-82.93%)
Mutual labels:  ab-testing
Split
πŸ“ˆ The Rack Based A/B testing framework
Stars: ✭ 2,539 (+2996.34%)
Mutual labels:  ab-testing
laravel-ab
Laravel A/B experiment testing tool
Stars: ✭ 108 (+31.71%)
Mutual labels:  ab-testing
K8s Deployment Strategies
Kubernetes deployment strategies explained
Stars: ✭ 2,649 (+3130.49%)
Mutual labels:  ab-testing
ruby-client
Ruby SDK client for Split Software
Stars: ✭ 22 (-73.17%)
Mutual labels:  ab-testing
Google Optimize Module
SSR friendly Google Optimize module for Nuxt.js
Stars: ✭ 180 (+119.51%)
Mutual labels:  ab-testing
android-projects
Android benchmark projects for Bazel and Gradle
Stars: ✭ 29 (-64.63%)
Mutual labels:  ab-testing
evolutio
ab testing framework with automated code removing
Stars: ✭ 15 (-81.71%)
Mutual labels:  ab-testing
intergo
A package for interleaving / multileaving ranking generation in go
Stars: ✭ 30 (-63.41%)
Mutual labels:  ab-testing

vue-a2b

split testing for Vuejs

Usage

Add the package to your project:

yarn add vue-a2b
# or
npm install vue-a2b

…and register it to Vue:

import VueAB from 'vue-a2b'
Vue.use(VueAB)

vue-a2b uses named slots for defining test variations. Any amount of variations is supported (A/B/n). The the variation identifier should be used as slot name and can be any valid string. Selection chances are given as ratio. In the first example, test A has twice the chance to be selected over test B:

Note: Selection chances are parsed as whole numbers, so instead of 2.5 and 1 use 5 and 2.

minimal example

<template>
  <split-test>
    <component slot="A" chance="2" />
    <component slot="B" chance="1" />
  </split-test>
</template>

more examples

Chances are optional. If left out, every test gets the same chance to be picked. The selection can also be forced with the always parameter, which is useful for testing:

<template>
  <split-test always="B"> <!-- will always choose B, no matter the chances -->
    <component slot="A" chance="2" />
    <component slot="B" chance="1" />
  </split-test>
</template>

If more than one element is part of the test, use template tags:

<template>
  <split-test>
    <template slot="A" chance="2">
      <button>hello</button>
      <button>World</button>
    </template>
    <template slot="B" chance="1">
      <button>hey ho</button>
      <button>lets go</button>
    </template>
  </split-test>
</template>

functional usage

Since version 0.2 functional usage is supported. The component scope now has the $abtest method. It can be used to initialize an A/B test without the <split-test> component or to get the test value:

To initialize a new test, created() is a good spot:

export default {
  created () {
    // creates a test 'fancy-bubbles' with 75% chance for even more bubbles
    this.$abtest('fancy-bubbles', { bubbles: 25, lotsOfBubbles: 75 })
  }
}

To get a value, for example in data, just call $abtest again:

export default {
  data () {
    return {
      more_bubbles: this.$abtest('fancy-bubbles') === 'lotsOfBubbles'
    }
  }
}

The function is reachable for the template as well:

<template>
  <div :class='$abtest("fancy-bubbles")'>bubbles!</div>
</template>

<style>
.lotsOfBubbles {
  font-size: var(--extra-big);
}
</style>

outside of components

vue-a2b exports the abtest method among others, so it is possible to access it via:

import { abtest } from 'vue-a2b'

Additionally randomCandidate is exported, which allows to get a randomly picked sample out of a list of VNodes or an object:

import { randomCandidate } from 'vue-a2b'

// pics a random candidate foo, bar, baz with 75%, 20%, 5% chance respectively
const candidate = randomCandidate({
  foo: 75,
  bar: 20,
  baz: 5
})

Settings

Test name

The test name needs to be set with the name attribute. If no name is given, it might be deferred from the parent components name attribute.

<template>
  <split-test name="the-one-test">
    <component slot="A" chance="2" />
    <component slot="B" chance="1" />
  </split-test>
</template>
Attention: Test name is mandatory!

Storage options

You can set storage method, name and expiry on initialization. Supported methods are cookie (the default) and localStorage.

Vue.use(VueAB, {
  storage: {
    method: 'localStorage',
    name: 'project42'
  }
})

The stored value expires after 30 days by default. This can be changed:

Vue.use(VueAB, {
  storage: {
    method: 'cookie',
    expiry: 7 // one week until the cookie expires
  }
})
Note: LocalStorage doesn't support expiration by default but the entries get
a timestamp and old entries will be ignored to make expiration possible.

Note: The expiry date is refreshed with every page visit. The entry only
expires, if the user doesn't come back in the specified time.

Component Name

By default <split-test> is the component that wraps a new test. This name can be overwritten on initialization:

Vue.use(VueAB, {component: 'a-b'})
<template>
  <a-b>
    <!-- variants -->
  </a-b>
</template>

Build setup

We recommend to use yarn but npm works too:

# Install dependencies
yarn install
# or
npm install

# Build for production with minification
yarn build
# or
npm run build

License

MIT Β© fromAtoB GmbH

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].