docs: Context values for Segments - #5654
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
matthewelwell
left a comment
There was a problem hiding this comment.
I've added one minor comment to a specific line I wasn't sure about.
On the whole though, it looks good to me. I think that one thing that I'd love to see (whether they make it into the docs for release or not) is some example use cases listed out and how to achieve them.
For example,
"A multi-tenant platform where we want to roll-out a feature by percentage such that all users in a given tenancy get a consistent experience"
- I think this can be achieved using this functionality + transient traits
I'm sure there are other use cases that we've received feedback about that we're trying to achieve with this too. What about different device types, are there use cases there?
Also, on a general functionality point of view, should we consider being able to define logical context values somehow? Like a hash of their identifier, and some other trait value for example? I'm not suggesting this is part of v1, but does it need to be considered as part of the data-model?
I've added 2 use cases in 08b9330 that made sense to me, let me know your thoughts.
I agree this might be a worthwhile endeavour. I can see two ways to achieve that:
If we go route 2, we might want to think early on data accessor format to use for Context values, so the answer to
should be "Yes". |
|
Some additional thoughts as to opportunities unlocked by Context values:
|
|
For reference, these are free logical operations we receive with jsonpath-ng extensions: https://github.com/h2non/jsonpath-ng?tab=readme-ov-file#extensions |
|
Thinking we could use jq syntax as well, if we prove the jq bindings to be performant enough. jq is Turing-complete so this could be an overkill, or just the right solution depending on how flexible we want to allow this feature to be. |
|
Seems abandoned in GitHub. |
matthewelwell
left a comment
There was a problem hiding this comment.
As discussed on our call earlier today, in answer to the questions here, we plan to go ahead with JSONPath for context values in segment conditions.
We verified that there are currently no conditions in our SaaS DB that begin with $. so we can (fairly) safely assume that we can rely on that to determine if a condition is context value or a trait (although thinking about it, the user has to make a decision in defining the segment, so why don't we just store them separately in the data model or add a flag to the model?).
|
One more thought: Looks like we can ditch the |
24ea414 to
3405ef0
Compare
Zaimwa9
left a comment
There was a problem hiding this comment.
Approving because it's already good as of but I have 2 minor comments that I let you decide if worth
| To avoid persisting the `organisation_name` trait on the user identity, mark it as | ||
| [transient](../advanced-use/transient-traits.md). |
There was a problem hiding this comment.
Out of clarity, I would add just a sentence before explaining the default behavior that would store the organisation_name and why that transient trait would be preferable in some situations
There was a problem hiding this comment.
I'd like to avoid duplicating the trait docs tbh. I think the word "persisting" gives a strong hint here.
Co-authored-by: Zaimwa9 <wadii.zaim@flagsmith.com>
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
Co-authored-by: Zaimwa9 <wadii.zaim@flagsmith.com> Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature!Changes
Closes #5615.
This PR outlines the Context values for Segments functionality primarily aimed to solve the use case outlined in #5557, open the door for solving #136, #5635, #3971, and more.
Context values are used as Segment rule properties to enable more flexible segmentation. Currently, Context values include the Environment Name, Identity Identifier, and Identity Traits. The
% Splitoperator, previously locked to Identity Identifier, can now be used with any Context value just as any other operator.In the future, we'll be able to add more useful predefined Context values like:
The PR contains the following changes:
How did you test this code?
N/A