All Projects → imjul1an → ab-react-hook

imjul1an / ab-react-hook

Licence: MIT license
🧪A/B-Testing React Hook

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to ab-react-hook

Clearml
ClearML - Auto-Magical CI/CD to streamline your ML workflow. Experiment Manager, MLOps and Data-Management
Stars: ✭ 2,868 (+14994.74%)
Mutual labels:  experiment
dango-tribute
👀
Stars: ✭ 20 (+5.26%)
Mutual labels:  experiment
yii2-wizflow
The wizard UI pattern implemented using yii2-workflow
Stars: ✭ 14 (-26.32%)
Mutual labels:  experiment
Chat
A simple chat app created to experiment with Redis, Gevent, Flask & Server-Sent Events.
Stars: ✭ 202 (+963.16%)
Mutual labels:  experiment
iter8
Kubernetes release optimizer
Stars: ✭ 217 (+1042.11%)
Mutual labels:  experiment
caracara
GEUT LABS. An experimental Dat based collaborative editor.
Stars: ✭ 33 (+73.68%)
Mutual labels:  experiment
Isomorphic Lab
Isomorphic React experimentation
Stars: ✭ 144 (+657.89%)
Mutual labels:  experiment
experiment
A/B cookie testing tool for @laravel
Stars: ✭ 55 (+189.47%)
Mutual labels:  abtest
abba
A/B Testing framework
Stars: ✭ 16 (-15.79%)
Mutual labels:  experiment
console-web-ui
Examples to show case how to build web based UI (that can be invoked using curl) for console applications using Javascript(NodeJS)
Stars: ✭ 28 (+47.37%)
Mutual labels:  experiment
Trixi
Manage your machine learning experiments with trixi - modular, reproducible, high fashion. An experiment infrastructure optimized for PyTorch, but flexible enough to work for your framework and your tastes.
Stars: ✭ 211 (+1010.53%)
Mutual labels:  experiment
hb-config
hb-config: easy to configure your python project especially Deep Learning experiments
Stars: ✭ 21 (+10.53%)
Mutual labels:  experiment
evolutio
ab testing framework with automated code removing
Stars: ✭ 15 (-21.05%)
Mutual labels:  abtest
Aimandshoot
A neuroevolution game experiment.
Stars: ✭ 201 (+957.89%)
Mutual labels:  experiment
knight
Nginx Http 集群api 统计监控、灰度发布、频率控制
Stars: ✭ 68 (+257.89%)
Mutual labels:  abtest
Clearml Server
ClearML - Auto-Magical Suite of tools to streamline your ML workflow. Experiment Manager, ML-Ops and Data-Management
Stars: ✭ 186 (+878.95%)
Mutual labels:  experiment
rainbow-explorer
🌈 A 20kb Preact & Redux based Progressive Web App that translates real life color to digital color.
Stars: ✭ 26 (+36.84%)
Mutual labels:  experiment
mcSIM
Code for running a multicolor structured illumination microscopy (SIM) experiment using a DLP6500 digital micromirror device (DMD) and performing SIM reconstruction.
Stars: ✭ 19 (+0%)
Mutual labels:  experiment
VariantRetriever
VariantRetriever is a minimalist package for feature flagging
Stars: ✭ 23 (+21.05%)
Mutual labels:  experiment
TypeEdge
TypeEdge is a strongly-typed development experience for Azure IoT Edge.
Stars: ✭ 15 (-21.05%)
Mutual labels:  experiment



A/B
Experiment Hooks



npm package CircleCI master




Install

Using npm:

npm i ab-react-hook

or using yarn:

yarn add ab-react-hook

When should I use A/B tests?

It's a very good question to ask before start doing A/B tests. The simple answer would be - when the sample size is statistically significant and you have a good traffic. To dig deeper into numbers use powercalculator made by booking to understand how long would it take you to run an A/B test and get a statistically significant result.

useExperiment()

  • Define experiment variants and weights:
variants: [{
  name: "control", weight: 50 
}, {
  name: "test", weight: 50
}]

You can define as many variants as you want but it is recommended to keep two or max three variants for your experiment.

  • Get the variant and send it to your analytics (google analytics, facebook analytics etc.), so you can aggregate results in a single place and analyze it later.
const AddToCartButtonExperiment = () => {
  const experimentConfig = {
    id: "3143106091",
    name: "add-to-cart-green",
    variants: [{ name: "control", weight: 50 }, { name: "test", weight: 50 }]
    enableForceExperiment: true
  };
 
  const variant = useExperiment(experimentConfig)

  if (variant.name === "control") {
     return <button class="black">Add to cart</button>;
  } else if (variant.name === "test") {
     return <button class="green">Add to cart</button>;
  }
}

useExperimentAsync()

const fetchVariant = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve("test");
    }, 2000);
  });
}

function AsyncAddToCartButtonExperiment() {
  const { variant, isLoading } = useExperimentAsync({
    name: "exp1",
    fetchVariant,
    enableForceExperiment: true
  });

  if (isLoading) {
    return <div>loading...</div>;
  }

  if (variant.name === "control") {
     return <button class="black">Add to cart</button>;
  } else if (variant.name === "test") {
     return <button class="green">Add to cart</button>;
  }
}

Force experiment variant

If enableForceExperiment flag set to true you can seamlessly test all possible variants of the particular experiment without changing the code.

To force experiment variant add query parameter with experiment id and the variant name.

  • Force single experiment variant:
/?et=exp_id:exp_variant
  • Force multiple experiments:
/?et=exp_1:exp_variant_id,exp_2:exp_variant_id
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].