@visionect/frontend-experiments
Experiment utility
Last updated 7 months ago by some1else .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @visionect/frontend-experiments 
SYNC missed versions from official npm registry.

Frontend Experiments

Install

yarn add @visionect/frontend-experiments

or

npm install --save @visionect/frontend-experiments

Usage

import Experiments from "@visionect/frontend-experiments"

const expConfig = [
  {
    name: 'EXP-01',
    variants: [
      {
        name: 'simple_cta',
        payload: 'Sign up',
      },
      {
        name: 'alter_cta',
        payload: 'Start free trial',
      }
    ]
  }
]

const ExpProvider = new Experiments(expConfig)

// Broadcast values to analytics
const variant = ExpProvider.getVariant('EXP-01')
// Set custom dimension 1 to 'simple_cta' or 'alter_cta'
window.ga && window.ga('set', 'cd1', variant.name)
// Button text is Sign up / Button text is Start free trial
console.log('Button text is', variant.payload)


// Fetch payload from a child component
const exp01CTA = ExpProvider.getPayload('EXP-01')
const Button = ({ onClick }) => (
  <button onClick={onClick}>
    {exp01CTA}
  </button>
)

(c) 2019 Visionect

Current Tags

  • 0.3.0                                ...           latest (6 months ago)

4 Versions

  • 0.3.0                                ...           6 months ago
  • 0.2.1                                ...           7 months ago
  • 0.2.0                                ...           7 months ago
  • 0.1.0                                ...           8 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |