Multivariate - A/B - split testing with Flipper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Register test groups | |
# https://www.flippercloud.io/docs/features#enablement-group | |
Flipper.register(:group_a) do |actor, context| | |
# Algorithm or database lookup to determine if a user is in this group | |
# e.g. 10% percentage of actors | |
crc32('group_a' + context.feature_name + actor.flipper_id) % 100 < 10 | |
end | |
Flipper.register(:group_b) do |actor, context| | |
# Use data model to determine if user is in group | |
actor.respond_to?(:in_group?) && user.in_group?(:group_b) | |
end | |
# Enable different experiments for different groups | |
Flipper.enable(:my_experiment_a, :group_a) | |
Flipper.enable(:my_experiment_b, :group_b) | |
# Conditional in your app to check if an experiment is enabled for a specific actor | |
if Flipper.enabled?(:my_experiment_a, current_user) | |
# experiment A group | |
elsif Flipper.enabled?(:my_experiment_b, current_user) | |
# experiment B group | |
else | |
# control group | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment