Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A/B test framework for app features #130

Open
jace opened this issue Nov 2, 2016 · 1 comment
Open

A/B test framework for app features #130

jace opened this issue Nov 2, 2016 · 1 comment

Comments

@jace
Copy link
Member

jace commented Nov 2, 2016

Baseframe should provide an A/B test framework for new app features. In its simplest form, the app initalizes Baseframe with a list of feature flags currently being tested:

baseframe.init_app(app, ab=['feature1', 'feature2'])

For a high impact experimental feature, the app may want to limit the test to, say, 1 in 10 users:

baseframe.init_app(app, ab=[('feature1', 10), 'feature2'])

Baseframe then adds a before_request handler that examines session['ab'], creating a dictionary if required and adding all missing flags with a value of None (not part of A/B test), False (A group) or True (B group):

for flag, chance in self.ab_flags:  # Default chance is 1
    if flag not in session['ab']:
        session['ab'][flag] = random.choice([True, False]) if randint(1, chance) == 1 else None

An after_request handler runs through session['ab'] again and removes all keys that are not in self.ab_choices, to remove flags that the app is no longer testing.

Within the app, any transaction that is based on the feature can read the A/B flag status from session['ab'][flag]. It is not possible to read A/B flags from the client-side unless flags are stored in a separate, unencrypted (but still signed) non-HTTPOnly cookie.

@jace
Copy link
Member Author

jace commented Nov 3, 2016

Ideally, Baseframe should take this further, also providing a mechanism to log events and linking A/B flags to event outcomes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant