Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions posthog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
28 changes: 24 additions & 4 deletions references/posthog-python-8.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
28 changes: 24 additions & 4 deletions references/posthog-python-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
Loading