-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature Flags aren't consistent when distinctIDs can change #9547
Comments
Doh, which would only work for us 🤦 |
I think right from when during all these steps and further the feature flags with variants should not change their value. right? |
between (d) and (e), if you go incognito / clear caches / disabled cookies/cache , then there's no way to know if you are the same person who logged in earlier, so its very much possible for feature flags to flip. |
There's an existing issue addressing this problem: #7115
Using |
Note that feature flags can (and I have in the past) be used as authorization-type gates - can user do X. This means that if you don't change the flag as user logs in you also create problems. |
I'm looking into fixing this issue this week. To have all context and make informed decisions, here's all the use cases we know of: ( @marcushyett-ph - could use some help filling out anything I've missed) Feature Flags use cases
And in all of these cases, Problems with above use cases
Before I jump into solutions, does this make sense? Am I missing any use cases? (cc: @macobo @mariusandra @Twixes @EDsCODE @rcmarron . No requirement to respond, just pinging to confirm I've covered all bases) |
Constraints to keep in mind:
|
I think there's 3 ways to about solving this, but one seems superior to all options. Firstly, since consistency is not a requirement for all sorts of feature flags, and only plays a role when the flag has to go through an identify / login / distinct_id change event, we should make this optional, and default to false. For the special case when consistency is switched on (we need a better name though), we need some extra work to make things work. All these options can't be evaluated completely on the client-side. Not great option 1: Use person_id as the key for hashingThis seems to work, except for the fact that personIDs may merge when identify is called for the first time, which leads to deleting old person IDs, which can just as easily cause the same problems, although in a smaller number of cases. Implementing this, however, is pretty straightforward. Not great option 2: Use a feature flag value overrideWhenever we have a Thus, no matter the change in distinctID, we can be sure that the person always sees the same variant. The problem here, though, is how this handles adjustments to rollout %s. If, say, at the end of the experiment, I come and rollout the winning variant to 100%, it simply won't work because the persons are all overridden to this old value. Option 3: Use a hash key overrideWhenever we have a This ensures that future changes correctly change the behaviour for the feature flag, while also ensuring it remains consistent when distinct IDs change. Open to hear about other options, but option 3 seems best to me so far. I considered going the opposite route, where the client keeps the anon distinctID as the 'main' one, but that has other problems, and doesn't fit in well with existing architecture, not worth reversing this at all. More detailed spec of how option 3 will work:
Effectively, option 3 is a more general form of option 1. Choosing between option 1 and 3 also depends on how the ingestion side works when identifying persons, which I'm looking into next. Maybe the cases where the person_id changes are actually much smaller (or that's my suspicion), which can help us get rid of the cruft. |
Option 1 was a no-go because of how person merges affect identify. Consider this very standard case:
In contrast to option 3, where the override is added at this point, ensuring that |
This is now fixed and rolling out slowly to everyone |
Bug description
When someone logs out / switches to a new browser and then tries logging in, they get a new distinct ID, which can mean that sometimes the feature flags can flip, because feature flags are based on distinctID, not personID.
Then once they're logged in and move to their existing distinctID, until the
/decide
call returns, we're using the 'wrong' feature flag value. Further, if they keep using the$anon_distinct_id
, our feature flag is permanently flipped, which is not great for experiments.Additional context
personID
as feature flag identifier, for cases when you'd want multiple distinctIDs belonging to the same person to go to the same bucket.Thank you for your bug report – we love squashing them!
The text was updated successfully, but these errors were encountered: