-
Notifications
You must be signed in to change notification settings - Fork 450
docs: Context values for Segments #5654
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks promising!
Percentage Split deterministically assigns a "bucket" to each identity based on a provided identifier or a | ||
[context value](#context-values). This means that Segment overrides that use Percentage Split will always result in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say I have the following segment setup:
- Identifier
IN
id3,id4,id5 - "some trait"
% Split
50
Can identity "id4" fall into the 50% bucket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the docs, it does. Hopefully the % Split documentation is now clearer after 584a1a1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does
Sorry, not clear: it does, or it can? Given the two rules are combined with an OR
operator, I'd assume it can.
Also, aren't these two paragraphs very similar? To my Friday brain, the explanation around combining traits and context values feels a bit confusing.
L255:
Percentage Split deterministically assigns an Identity to a bucket based on a provided [context value](#context-values)
or a trait. This means that Segment overrides that use Percentage Split will always result in the same feature value for
a given identity in the chosen context.
L262:
Percentage Split deterministically assigns a "bucket" to each identity based on a provided identifier or a
[context value](#context-values). This means that Segment overrides that use Percentage Split will always result in the
same feature value for a given identity in the chosen context.
Here's a suggestion, based on my own understanding. It's close to the first variation above:
Percentage Split deterministically assigns a "bucket" to each identity based on a provided context value or a trait. This means that Segment overrides that use Percentage Split will always result in the same feature evaluation for a given identity.
I feel like the following sounds confusing, though it can be my own lack of familiarity:
- "feature value" makes me wonder if this is also valid for a feature state.
- "in the chosen context" sounds confusing. I know we're introducing the idea of contexts though this phrase sounds like I need to take a step back and learn something.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?).
### Gradual rollout across tenants | ||
|
||
Suppose your application supports users who can belong to multiple organisations. Now imagine you want to roll out a new | ||
feature to 50% of your total user base — but instead of targeting users randomly, you'd like to gradually release the | ||
feature based on the organisations they belong to. | ||
|
||
Here's how you might define a segment to achieve this: | ||
|
||
| Rule Order | Property | Operator | Value | | ||
| ---------- | ------------------------- | -------- | ----- | | ||
| 1 | Identifier | % Split | 50 | | ||
| 2 | `organisation_name` Trait | % Split | 20 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd perhaps argue that, while this use case showcases what's possible, when you think about it, it feels like it boils down to the same as what we have right now where not everyone in a given tenancy is getting a consistent experience. As I understood it, that was the key use case that we're trying to solve.
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
% Split
operator, 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