feat: Create split testing for multivariate#3235
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
matthewelwell
left a comment
There was a problem hiding this comment.
@zachaysan on the whole, this is really impressive. I have gone through with quite a fine-toothed comb so there are a fair amount of comments but most of them are my lack of knowledge in the world of statistics, or a little bit nit-picky :)
api/tests/unit/app_analytics/split_testing/test_unit_split_testing_tasks.py
Outdated
Show resolved
Hide resolved
api/tests/unit/app_analytics/split_testing/test_unit_split_testing_tasks.py
Outdated
Show resolved
Hide resolved
api/tests/unit/app_analytics/split_testing/test_unit_split_testing_tasks.py
Outdated
Show resolved
Hide resolved
api/tests/unit/app_analytics/split_testing/test_unit_split_testing_views.py
Outdated
Show resolved
Hide resolved
api/tests/unit/app_analytics/split_testing/test_unit_split_testing_views.py
Outdated
Show resolved
Hide resolved
api/app_analytics/views.py
Outdated
| track_feature_evaluation_influxdb_v2( | ||
| request.environment.id, self.evaluations | ||
| ) |
There was a problem hiding this comment.
This should be a task as well.
There was a problem hiding this comment.
I mirrored the existing function but since this one should be a task then both of them should be, right? So I've updated both versions to operate as tasks. Let me know if this is a problem.
There was a problem hiding this comment.
I also wrote an integration test that was missing for the v1 version of this just to make sure the task is configured correctly there as well.
Thanks for submitting a PR! Please check the boxes below:
pre-committo check linting[ ] I have added information todocs/if required so people know about the feature!Changes
Edit: These changes are out of date after multiple rounds of review and now with ongoing work to pull the split testing code into it's own repository.
Overall, the changes introduced here support adding split testing to Flagsmith for the customers of ours that use the
settings.USE_POSTGRES_FOR_ANALYTICSoption, so this does not support our current SaaS method. The basic idea is that each of our multivariate options are linked into aSplitTestmodel and serve as the source of identification as to which split test is represented. In detail changes include:FeatureEvaluationRawto accept a new identifier so we can tell when a user has encountered a feature. This has been implemented as a query param since the body of the request just has feature names. Also,FeatureEvaluationRawneeded faster lookups so an index onfeature_namewas added concurrently as well.chi2_contingencysummary statistic that follows the G-Test version of split testing which was verified as current on Wikipedia as well as elsewhere. This comes with all ofscipywhich may be a drawback on some systems, but if there is significant issues with it we can always extract the one function we need out into its own helper.ConversionEventwhich can be called for events like new user signup, just as a normal analytics app would. This is used to track the actual split test results.SplitTestresults they are available via aSplitTestViewSetwhich serializes the related attributes offeatureandmultivariate_feature_optionwhich reused serializers from existing areas of the codebase.How did you test this code?
Around seven or eight new tests, mostly on the new functionality. I wasn't quite happy with the split test task test since it is not deterministic and there didn't seem to be a clean way to force some identities to some multivariate options and other ones to others. Also, it would have been nice to test it with more objects, but with the size of the objects that would have been necessary, the statistics part was tested with raw numbers instead.