-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve feature flags #71
Conversation
Does it make sense to call this if identify is called? It feels like that should work automatically |
We could call this directly, but we need to make sure identity is not only called, but the event is processed in the backend, giving the new feature flags. Alternatively, we could pass the new distinct_id somehow to /decide and use that to directly calculate the new flags. |
Great! That would work if I could be sure that the call to get_distinct_id was updated, but it appears that is what you mean by "but we need to make sure identity is not only called, but the event is processed in the backend". Would it be possible to have the onFeatureFlags handler act as an event handler? It looks like we could get around the server part by using adding a call in the persistence module, like an observer pattern. I am likely missing a lot of the big picture, and haven't tested it, but something like:
|
Passing in the distinct_id would also work for my use case I think, basically exposing 'decide' as 'featureFlagsForDistinctID(id): flags' |
3cc557e
to
309e9b8
Compare
Hi @Ralph7C2! My apologies for the long wait before a reply (vacations period 😅) I actually gave you some wrong information before. We are passing the If your feature flags are only dependent on the user's ID (e.g. to calculate if the user is part of the flag's rollout), what is implemented in this PR should be enough. Just call If the flag is also calculated from some The idea to refactor |
Yes, I believe as long as calling reloadFeatureFlags directly after identify gives the feature flags for the id passed in identify. Our flow is:
All feature flagging would be after logging in, and we would just need it to be consistent on the user id. My understanding of PostHog's feature flag code is it is some hashing function applied to the feature_flag_id+distinct_id, so as long as that distinct_id is the user_id we pass to identify, it'll work? |
522ef9b
to
7a4672f
Compare
New changes:
Problems:
@timgl ready to be reviewed |
Merged with master and one change added:
Ready for a look. |
on it |
Changes
.reloadFeatureFlags()
toposthog
. Calling that updates all feature flags for the current user. (Fixes Feature flag issue for SPA #70).reloadFeatureFlags(flags => console.log(flags))
No tests since there are no tests for feature flags... and I don't have time to add any now before the day is over :).
Checklist