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
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
The `capture()` method has an optional argument `sendFeatureFlags`, which is set to `false` by default. By setting this to `true`, feature flag information will automatically be sent with the event.
The `capture()` method has an optional argument `sendFeatureFlags`, which is set to `false` by default. This parameter controls whether feature flag information is sent with the event.

Note that by doing this, PostHog will make an additional request to fetch feature flag information before capturing the event. So this method is only recommended if you don't mind the extra API call and delay.
#### Basic usage

Setting `sendFeatureFlags` to `true` will include feature flag information with the event:

```node
client.capture({
distinctId: 'distinct_id_of_your_user',
event: 'event_name',
sendFeatureFlags: true,
})
```
```

#### Advanced usage (v5.5.0+)

As of version 5.5.0, `sendFeatureFlags` can also accept an options object for more granular control:

```node
client.capture({
distinctId: 'distinct_id_of_your_user',
event: 'event_name',
sendFeatureFlags: {
onlyEvaluateLocally: true,
personProperties: { plan: 'premium' },
groupProperties: { org: { tier: 'enterprise' } }
}
})
```

#### Performance considerations

- **With local evaluation**: When [local evaluation](/docs/feature-flags/local-evaluation) is configured, setting `sendFeatureFlags: true` will **not** make additional server requests. Instead, it uses the locally cached feature flags, and it provides an interface for including person and/or group properties needed to evaluate the flags in the context of the event, if required.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here.

If you are using local evaluation, you also need to set onlyEvaluateLocally: true when calling capture with sendFeatureFlags? Person and group properties for sendFeatureFlags are only relevant if locally evaluating?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I guess if you want sendFeatureFlags to evaluate locally too you use it, otherwise it will make a server-call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Person and group properties for sendFeatureFlags are only relevant if locally evaluating?

Not true, we still support property overrides even when we use the server call (e.g. they want to pass a person property that hasn't been ingested yet)

If you are using local evaluation, you also need to set onlyEvaluateLocally: true when calling capture with sendFeatureFlags?

yeah, the idea is you have to specify that you're sending feature flags locally, otherwise we will hit the servers for the most up-to-date evaluation.


- **Without local evaluation**: PostHog will make an additional request to fetch feature flag information before capturing the event, which adds delay.

#### Breaking change in v5.5.0

Prior to version 5.5.0, feature flags were automatically sent with events when using local evaluation, even when `sendFeatureFlags` was not explicitly set. This behavior has been **removed** in v5.5.0 to be more predictable and explicit.

If you were relying on this automatic behavior, you must now explicitly set `sendFeatureFlags: true` to continue sending feature flags with your events.
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
The `capture()` method has an optional argument `send_feature_flags`, which is set to `false` by default. By setting this to `true`, feature flag information will automatically be sent with the event.
The `capture()` method has an optional argument `send_feature_flags`, which is set to `false` by default. This parameter controls whether feature flag information is sent with the event.

Note that by doing this, PostHog will make an additional request to fetch feature flag information before capturing the event. So this method is only recommended if you don't mind the extra API call and delay.
#### Basic usage

Setting `send_feature_flags` to `True` will include feature flag information with the event:

```python
posthog.capture(
distinct_id="distinct_id_of_the_user"
'event_name',
distinct_id="distinct_id_of_the_user",
event='event_name',
send_feature_flags=True
)
```

## Advanced usage (v6.3.0+)

As of version 6.3.0, `send_feature_flags` can also accept a dictionary for more granular control:

```python
posthog.capture(
distinct_id="distinct_id_of_the_user",
event='event_name',
send_feature_flags={
'only_evaluate_locally': True,
'person_properties': {'plan': 'premium'},
'group_properties': {'org': {'tier': 'enterprise'}}
}
)
```

#### Performance considerations

- **With local evaluation**: When [local evaluation](/docs/feature-flags/local-evaluation) is configured, setting `send_feature_flags: True` will **not** make additional server requests. Instead, it uses the locally cached feature flags, and it provides an interface for including person and/or group properties needed to evaluate the flags in the context of the event, if required.

- **Without local evaluation**: PostHog will make an additional request to fetch feature flag information before capturing the event, which adds delay.

#### Breaking change in v6.3.0

Prior to version 6.3.0, feature flags were automatically sent with events when using local evaluation, even when `send_feature_flags` was not explicitly set. This behavior has been **removed** in v6.3.0 to be more predictable and explicit.

If you were relying on this automatic behavior, you must now explicitly set `send_feature_flags=True` to continue sending feature flags with your events.