-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Is your feature request related to a problem?
Currently, get_feature_flag_result is only available through the direct Client interface but not at the module level. This means users who want to access extended feature flag information (payload, reason, etc.) are forced to use multiple SDK methods get_feature_flag and get_feature_flag_payload or use the Client interface, even though the module-level API is the recommended approach for most use cases.
This creates a suboptimal experience where users need to:
- Make multiple API calls to get all flag information
- Or switch to the Client interface just to access this consolidated method
Describe the solution you'd like
Expose get_feature_flag_result at the module level to provide a single method that returns all flag information in one call. This would maintain the benefits of the module-level API while providing a more efficient way to access complete flag information.
Example desired usage:
import posthog
posthog.api_key = 'api-key'
result = posthog.get_feature_flag_result('flag-key', 'user-123')
if result:
print(f"Enabled: {result.enabled}")
print(f"Variant: {result.variant}")
print(f"Payload: {result.payload}")
print(f"Reason: {result.reason}")This would reduce the number of API calls needed when both flag state and payload information are required.
Describe alternatives you've considered
- Continue using separate
get_feature_flagandget_feature_flag_payloadcalls - Use
get_all_flags_and_payloadsand filter, expensive! - Use the Client interface when consolidated information is needed
- Create a new module-level method with a different name that combines the functionality