FlagDiligence docs
Targeting and segments
Serve the right value to the right users.
Targeting rules
Open a flag, choose the environment, and select Add rule. A rule has a name, one or more conditions, and the variation to serve. Rules run in priority order, lowest number first, and the first match wins.
Priority 1 email ENDS_WITH "@yourcompany.com" -> new feature (100%)
Priority 2 custom.betaOptIn EQUALS "true" -> new feature (100%)
Default everyone else -> new feature (25% rollout)
Operators
| Operator | Matches | Example |
|---|---|---|
| EQUALS / NOT_EQUALS | An exact value, or anything else | plan NOT_EQUALS "free" |
| CONTAINS / NOT_CONTAINS | A piece of text | email CONTAINS "@company.com" |
| STARTS_WITH / ENDS_WITH | The start or end of text | email ENDS_WITH "@company.com" |
| IN / NOT_IN | A list of values | country IN ["US","CA","UK"] |
| GREATER_THAN / LESS_THAN | A number | accountDays LESS_THAN 30 |
Attributes you can target
You can target on key, email, name and any custom attribute you pass in the user object:
const user = {
key: 'user-123', // required, stable and unique
email: 'user@example.com',
name: 'Asha Rao',
custom: {
plan: 'enterprise',
country: 'IN',
deviceType: 'mobile',
betaOptIn: true,
},
};
Browser, device, operating system, language, country and screen size are not collected for you. Detect them in your app and pass them as custom attributes, then target on them. Create the user object once when your app starts, not on every render.
Segments
A segment is a reusable group defined by rules, such as Beta testers or Enterprise customers. Build it once under Segments, then pick Use segment when you add a rule to any flag.
| Segment | Rule |
|---|---|
| Beta testers | custom.betaOptIn EQUALS "true" |
| Mobile users | custom.deviceType IN ["mobile","tablet"] |
| Paid users | custom.plan IN ["starter","pro","enterprise"] |
| North America | custom.country IN ["US","CA"] |
| English speakers | custom.language STARTS_WITH "en" |
Combining rules with a rollout
A common pattern is internal users first at 100%, opt-in beta users next, and then a percentage of everyone else. Raise the percentage in steps as you watch your metrics.
Need help with FlagDiligence?
Open the app, or tell us what you are trying to do.
