marvelapp / react-ab-test

A/B testing React components and debug tools. Isomorphic with a simple, universal interface. Well documented and lightweight. Tested in popular browsers and Node.js. Includes helpers for Mixpanel and Segment.com.
MIT License
243 stars 46 forks source link

add method to calculate active variant before rendering #6

Closed jalopez closed 5 years ago

jalopez commented 5 years ago

Table of Contents

Description

This PR adds a new method in the emitter calculateActiveVariant that will force the calculation of the active variant of an experiment, even if it has not been rendered yet. It has implied some refactoring (take the activeVariant calculation outside the Experiment component, so it can be called from both the component and the emitter)

Motivation and Context

There are some scenarios where developer needs to know beforehand which will the variant of an experiment will be selected (before rendering it). There are some event trackers that need to receive the experiments and the selected variant just when the page loads, and before the experiment itself is rendered. To do so, there is a new method calculateActiveVariant inside the emitter that can be called at anytime and will set an active variant of the given experiment even if the associated component is not yet rendered.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist:

chestozo commented 5 years ago

hey guys! any chances to get this PR merged in the close future? would be happy to give you a hand if needed )

moretti commented 5 years ago

Hey @jalopez, thank you for your PR! I'm sorry that I took so long to get back to you, I think it was lost in the noise generated by Github notifications.

moretti commented 5 years ago

Released in v2.3.0 🎉

chestozo commented 5 years ago

great!!!