feat: propagate personProperties and groups in feature flag events#383
feat: propagate personProperties and groups in feature flag events#383igormq wants to merge 2 commits intoPostHog:mainfrom
Conversation
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.
|
@dustinbyrne i think you'd know better what exactly the problem here is |
| PostHogEventName.FEATURE_FLAG_CALLED.event, | ||
| distinctId, | ||
| properties = props, | ||
| userProperties = userProps, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@dustinbyrne mind to follow up here? PR is stale for a while
There was a problem hiding this comment.
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.
Summary
personProperties(asuserProperties) andgroupstocaptureStatelesswhen$feature_flag_calledevents are sent during feature flag evaluationSplit from original PR addressing contributor feedback to keep changes focused.