Skip to content

feat: propagate personProperties and groups in feature flag events#383

Draft
igormq wants to merge 2 commits intoPostHog:mainfrom
igormq:feat/propagate-props-in-feature-flag-events
Draft

feat: propagate personProperties and groups in feature flag events#383
igormq wants to merge 2 commits intoPostHog:mainfrom
igormq:feat/propagate-props-in-feature-flag-events

Conversation

@igormq
Copy link
Copy Markdown
Contributor

@igormq igormq commented Jan 22, 2026

Summary

  • Propagate personProperties (as userProperties) and groups to captureStateless when $feature_flag_called events are sent during feature flag evaluation
  • Previously these properties were available during flag evaluation but not passed through to the captured event, meaning the feature flag evaluation context was lost

Split from original PR addressing contributor feedback to keep changes focused.

When `getFeatureFlagStateless` calls `captureStateless` for the
`$feature_flag_called` event, it now propagates the `personProperties`
(as userProperties) and `groups` to the event. Previously these
properties were available but not passed through, meaning the feature
flag evaluation context was lost in the captured event.

This ensures that when analyzing feature flag events in PostHog,
the user properties and group context are properly attached for
accurate targeting and analysis.

Fixes part of the issue by ensuring proper event context propagation.
@marandaneto
Copy link
Copy Markdown
Member

@dustinbyrne i think you'd know better what exactly the problem here is

@marandaneto marandaneto requested a review from a team January 22, 2026 17:40
PostHogEventName.FEATURE_FLAG_CALLED.event,
distinctId,
properties = props,
userProperties = userProps,
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.

Providing userProperties here will mutate persisted person properties. That seems unexpected for a feature flag called event.

What's the behavior we're looking for by doing this?

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.

shouldn't it? for me if we change a property of the user with a feature flag, we should reflect it , shouldnt we?
please let me know if this is not the intention

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dustinbyrne mind to follow up here? PR is stale for a while

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 open to hearing more about the case of changing a property with a feature flag. Currently, however, I don't believe this is the behavior in any of our other SDKs. The $feature_flag_called event is fired off as a side-effect of reading a feature flag. The reason I say it feels unexpected is because we'd now be implicitly mutating a person record in a read-only operation.

The additional propagation of groups that you've added does look like a gap. We should be passing that.

@marandaneto marandaneto marked this pull request as draft March 6, 2026 07:03
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

Successfully merging this pull request may close these issues.

3 participants