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

Add context to evaluated flags to describe reason for value (e.g. segment, identity, environment) #5181

Open
deepforest opened this issue Mar 4, 2025 · 4 comments

Comments

@deepforest
Copy link

deepforest commented Mar 4, 2025

Is your feature request related to a problem? Please describe.

Conducting A/B testing and some other custom logic on top of Features provided by Flagsmith SDK, it is required to have Feature Metadata along side the feature list and evaluation results.

Scenario 1: Conducting A/B testing, we would like to be able to realize what is the reason where Identity is assigned to group A or B or None (not participated in the test). For example, setting an A/B test for all the users with custom segmentation, where PropA=X and PropB=Y, how can we tell what is the reason for a given Identity, being assigned to group A, B or neither? (for example, PropA is not X or PropB is not Y).

Scenario 2: Conducting A/B testing, we would like to be able to run some custom logic which sends the results to Big Query for example. As we don't want to run this logic per-each feature, only for those who were marked with "A/B" feature Tag, from the Dashboard, the SDK don't provide back these essential Tag information.
There are many other cases where one would like to filter-in/out features based on this info.

Providing back the segmentation information, tags and other Metadata is possible using the REST APIs. But since the SDK already Poll for this info, why not exposing it as public APIs?
While using the REST API is possible, the Feature state provided by the SDK won't be in Sync with the direct calls to the REST API and there will always be redundant calls to the API service.

Describe the solution you'd like.

Expose Feature metadata, such as Segmentation rules and Tags from the SDK.

Describe alternatives you've considered

None

Additional context

No response

@matthewelwell
Copy link
Contributor

Hi @deepforest , I'm sorry, can you please provide more context here on what data you're looking for?

From what I understand, you're looking to do something like the following, is that correct?

flags = flagsmith.get_identity_flags("my-identity", traits={"foo": "bar"})
my_ab_test_flag = flags.get_flag("my-ab-test")

# existing functionality
print(f"enabled = {my_ab_test_flag.enabled}")
print(f"value = {my_ab_test_flag.value}")

# desired functionality
if my_ab_test_flag.is_segment_override:
    print(f"segment = {my_ab_test_flag.segment}")
elif my_ab_test_flag.is_identity_override:
    print("identity override = true")

@deepforest
Copy link
Author

deepforest commented Mar 4, 2025

Yes. Either this or another, any reasonable way to get back the Feature Segments. Not necessarily given an Identity.
It's very important to have to we can "debug" the results and get better understanding of why feature is evaluated as X and not Y, given an Identity.
Also, an option to get back feature Tags, also all features with tags: T1, T2, .. etc.

@matthewelwell
Copy link
Contributor

Understood, thanks @deepforest .

Just for context here, this information is not currently exposed by the API that returns flags so this is not a trivial requirement, but I do agree that it would be useful. At this point, however, I can't at this point say if / when we will get around to adding it.

@matthewelwell matthewelwell changed the title Provide feature metadata Add context to evaluated flags to describe reason for value (e.g. segment, identity, environment) Mar 4, 2025
@deepforest
Copy link
Author

Appreciate that. Thanks.

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

2 participants