Identity Contexts #1839
Replies: 6 comments 6 replies
-
In addition to above, a lot of the use-cases for this would be an on demand switching of contexts. E.g. if we used this on a organisation / project switching level. To accomplish this, for client-side SDKs we'd want to be able to also get additional contexts at the time they are used. e.g. await flagsmith.getContext("orgId", {organisation:"orgId"}) |
Beta Was this translation helpful? Give feedback.
-
How we would go about persisting this Trait data without a big architectural change? If we added a |
Beta Was this translation helpful? Give feedback.
-
Not sure how we would 'seed' the % split/multivariate engine here. With regular Identities we get a unique key from the database which we use to seed the % split (basically). With identity contexts we don't have this, so we would need to generate something that is reproducable across SDKs. Suggest just grabbing all the trait keys and values, concatenating them together, SHA256 hashing that string and then using that as the seed? |
Beta Was this translation helpful? Give feedback.
-
I think this is in-line with what we're trying to achieve in my comment here: #430 (comment) |
Beta Was this translation helpful? Give feedback.
-
A user's "organisation" context may also change during the session if the user belongs to multiple organisations, for example when they "Switch Organisation" in the UI. Will that be supported, or will it be a 1:1 relationship? Where from Flagsmith's POV a user has/belongs to no organisation, or 1, but not multiple? |
Beta Was this translation helpful? Give feedback.
-
Ah I see now. Yes, so for identity contexts, you would most likely store multiple organisations as contexts with their own unique id. |
Beta Was this translation helpful? Give feedback.
-
It would be extremely useful to be able to provide multiple identities to Flagsmith as different
contexts
and then get the flags for different contexts in the SDK based on the use case in question.Use Cases
organisation
. Traits could besubscription_level
,number_of_seats
.device_type
. Traits could behas_notifications
,low_bandwidth_mode
.user_role
. Traits could beallow_fullscreen
,can_edit
.Example Code
Server Side Changes
Two options:
context
which is the name of the context. Identities that are not associated with a context remain the same, withNULL
as the context value.plan
scale-up
organisation
Getting flags now allows the SDK to receive N sets of flags, for each context provided. So effectively the Flag engine would need to run N times for each context provided. This would be done in a single request/response.
Remaining Questions
Are contexts stored within the Identity, or shared amongst Identities based on a common Key?
For example. Two Identities are part of the same Organisation. The SDK declares an
organisation
context which is the same data for each Identity. Do the two Identities 'share' this same piece of data or not? This could be dangerous if one Identity modifies the Trait data.Do Contexts need an ID to be provided?
How would the % split/mutlivariate flag engine work for contexts?
We could combine the Identity key with the context name/string and use that as the seed?
Beta Was this translation helpful? Give feedback.
All reactions