feat: use the variant as the exposure event value#222
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates get_experiment_flag to use the flag's variant as the exposure value for multivariate experiments, falling back to the standard flag value if no variant is present. It also changes the type check to ensure the flag is an instance of Flag before tracking exposure. Unit tests have been added to verify this behavior. The reviewer recommends wrapping the test logic in try...finally blocks to stop the background event processor thread and prevent resource leaks.
cbc3cb4 to
5d1b91e
Compare
e50ada6 to
f15af26
Compare
ddb2ac4 to
237dfa2
Compare
4e2ea59 to
72de3f7
Compare
When `get_experiment_flag` records a `$flag_exposure` event, send the selected variant as the event value when present (the variant's key, or "control" for the control bucket), falling back to the flag value for standard flags. This identifies the experiment cohort without changing the event shape.
Flagsmith(...) can start polling, streaming and event-processor background threads. Track every instance created during a test and stop its threads on teardown so they don't leak across the suite — previously a leaked polling thread could call a class-level-patched update_environment in a later test. Replaces the scattered per-test try/finally cleanup.
72de3f7 to
bb278dc
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
get_experiment_flagrecords a$flag_exposureevent, the event value is now the selected variant when present (the variant's key, or"control"), falling back to the flag value for standard flags — making the exposure value the experiment cohort identifier. Reuses the existingvaluefield; no change to the event shape.