From defb56bca638ddee097113c142b7bcc19e9f52e7 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Wed, 18 Nov 2026 12:29:31 -0500 Subject: [PATCH] docs: mark feature_enabled, get_feature_flag and get_feature_flag_payload deprecated in their docstrings These methods already warn at runtime, but the generated 8.x reference shows no deprecation and uses feature_enabled as the get_feature_flag_payload example. Add the runtime warning's wording to the docstrings, switch that example to evaluate_flags, and regenerate references/. Co-Authored-By: Claude Opus 5.5 --- posthog/__init__.py | 8 ++++++++ posthog/client.py | 18 ++++++++++++++--- references/posthog-python-8.md | 28 ++++++++++++++++++++++---- references/posthog-python-reference.md | 28 ++++++++++++++++++++++---- 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/posthog/__init__.py b/posthog/__init__.py index cf5a54e94..eafc2a3ac 100644 --- a/posthog/__init__.py +++ b/posthog/__init__.py @@ -851,6 +851,10 @@ def feature_enabled( """ Use feature flags to enable or disable features for users. + `feature_enabled` is deprecated and will be removed in a future major version. Use + `posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This + consolidates flag evaluation into a single `/flags` request per incoming request. + Args: key: The feature flag key distinct_id: The user's distinct ID @@ -904,6 +908,10 @@ def get_feature_flag( """ Get feature flag variant for users. Used with experiments. + `get_feature_flag` is deprecated and will be removed in a future major version. Use + `posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This + consolidates flag evaluation into a single `/flags` request per incoming request. + Args: key: The feature flag key distinct_id: The user's distinct ID diff --git a/posthog/client.py b/posthog/client.py index d71aa13d7..e552150ff 100644 --- a/posthog/client.py +++ b/posthog/client.py @@ -4702,6 +4702,10 @@ def feature_enabled( """ Check if a feature flag is enabled for a user. + `feature_enabled` is deprecated and will be removed in a future major version. Use + `posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This + consolidates flag evaluation into a single `/flags` request per incoming request. + Args: key: The feature flag key. distinct_id: The distinct ID of the user. @@ -5059,6 +5063,10 @@ def get_feature_flag( """ Get multivariate feature flag value for a user. + `get_feature_flag` is deprecated and will be removed in a future major version. Use + `posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This + consolidates flag evaluation into a single `/flags` request per incoming request. + Args: key: The feature flag key. distinct_id: The distinct ID of the user. @@ -5161,6 +5169,10 @@ def get_feature_flag_payload( """ Get the payload for a feature flag. + `get_feature_flag_payload` is deprecated and will be removed in a future major version. Use + `posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag_payload(key)` instead. This + consolidates flag evaluation into a single `/flags` request per incoming request. + Args: key: The feature flag key. distinct_id: The distinct ID of the user. @@ -5180,12 +5192,12 @@ def get_feature_flag_payload( Examples: ```python - is_my_flag_enabled = posthog.feature_enabled('flag-key', 'distinct_id_of_your_user') + flags = posthog.evaluate_flags('distinct_id_of_your_user') - if is_my_flag_enabled: + if flags.is_enabled('flag-key'): # Do something differently for this user # Optional: fetch the payload - matched_flag_payload = posthog.get_feature_flag_payload('flag-key', 'distinct_id_of_your_user') + matched_flag_payload = flags.get_flag_payload('flag-key') ``` Category: diff --git a/references/posthog-python-8.md b/references/posthog-python-8.md index a7d441aa7..8eacccc20 100644 --- a/references/posthog-python-8.md +++ b/references/posthog-python-8.md @@ -553,6 +553,10 @@ get_feature_flag(key: str, distinct_id: ID_TYPES, *, groups: Optional[Mapping[st Get multivariate feature flag value for a user. +`get_feature_flag` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -587,6 +591,10 @@ get_feature_flag_payload(key: str, distinct_id: ID_TYPES, *, match_value: Option Get the payload for a feature flag. +`get_feature_flag_payload` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag_payload(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -611,12 +619,12 @@ Type | Description **Examples:** ```python -is_my_flag_enabled = posthog.feature_enabled('flag-key', 'distinct_id_of_your_user') +flags = posthog.evaluate_flags('distinct_id_of_your_user') -if is_my_flag_enabled: +if flags.is_enabled('flag-key'): # Do something differently for this user # Optional: fetch the payload - matched_flag_payload = posthog.get_feature_flag_payload('flag-key', 'distinct_id_of_your_user') + matched_flag_payload = flags.get_flag_payload('flag-key') ``` ## Get feature flag result @@ -864,6 +872,10 @@ feature_enabled(key: str, distinct_id: ID_TYPES, *, groups: Optional[Mapping[str Check if a feature flag is enabled for a user. +`feature_enabled` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -2538,6 +2550,10 @@ feature_enabled(key: str, distinct_id: ID_TYPES, groups: Optional[Mapping[str, U Use feature flags to enable or disable features for users. +`feature_enabled` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -2577,6 +2593,10 @@ get_feature_flag(key: str, distinct_id: ID_TYPES, groups: Optional[Mapping[str, Get feature flag variant for users. Used with experiments. +`get_feature_flag` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -3678,7 +3698,7 @@ attempts = attempts #### `posthog.capture_send.CaptureError.drops` ```python -drops = [(CaptureDroppedEvent(*drop)) for drop in (drops or [])] +drops = [CaptureDroppedEvent(*drop) for drop in drops or []] ``` #### `posthog.capture_send.CaptureError.endpoint` diff --git a/references/posthog-python-reference.md b/references/posthog-python-reference.md index acd91e295..fcb9d8f1f 100644 --- a/references/posthog-python-reference.md +++ b/references/posthog-python-reference.md @@ -553,6 +553,10 @@ get_feature_flag(key: str, distinct_id: ID_TYPES, *, groups: Optional[Mapping[st Get multivariate feature flag value for a user. +`get_feature_flag` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -587,6 +591,10 @@ get_feature_flag_payload(key: str, distinct_id: ID_TYPES, *, match_value: Option Get the payload for a feature flag. +`get_feature_flag_payload` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag_payload(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -611,12 +619,12 @@ Type | Description **Examples:** ```python -is_my_flag_enabled = posthog.feature_enabled('flag-key', 'distinct_id_of_your_user') +flags = posthog.evaluate_flags('distinct_id_of_your_user') -if is_my_flag_enabled: +if flags.is_enabled('flag-key'): # Do something differently for this user # Optional: fetch the payload - matched_flag_payload = posthog.get_feature_flag_payload('flag-key', 'distinct_id_of_your_user') + matched_flag_payload = flags.get_flag_payload('flag-key') ``` ## Get feature flag result @@ -864,6 +872,10 @@ feature_enabled(key: str, distinct_id: ID_TYPES, *, groups: Optional[Mapping[str Check if a feature flag is enabled for a user. +`feature_enabled` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -2538,6 +2550,10 @@ feature_enabled(key: str, distinct_id: ID_TYPES, groups: Optional[Mapping[str, U Use feature flags to enable or disable features for users. +`feature_enabled` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.is_enabled(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -2577,6 +2593,10 @@ get_feature_flag(key: str, distinct_id: ID_TYPES, groups: Optional[Mapping[str, Get feature flag variant for users. Used with experiments. +`get_feature_flag` is deprecated and will be removed in a future major version. Use +`posthog.evaluate_flags(distinct_id, ...)` and call `flags.get_flag(key)` instead. This +consolidates flag evaluation into a single `/flags` request per incoming request. + **Parameters:** Name | Type | Description | Default @@ -3678,7 +3698,7 @@ attempts = attempts #### `posthog.capture_send.CaptureError.drops` ```python -drops = [(CaptureDroppedEvent(*drop)) for drop in (drops or [])] +drops = [CaptureDroppedEvent(*drop) for drop in drops or []] ``` #### `posthog.capture_send.CaptureError.endpoint`