How to target specific users
A rule is a configuration that allows to serve a variation based on some conditions.
|Name of your rule.
This is needed when your are updating a rule using a scheduled rollout.
Query represents an antlr query in the nikunjy/rules format.
See query format to have the syntax.
Note: if you use the field
|Name of the variation to return.
Represents the percentage we should give to each variation.
The format is the name of the variation and the percentage for this one.
Note: if your total is not equals to 100% this rule will be considered as invalid.
Allow to ramp up the percentage of your flag over time.
You can decide at which percentage you starts with and at what percentage you ends with in your release ramp. Before the start date we will serve the initial percentage and, after we will serve the end percentage.
See progressive rollout to have more info on how to use it.
progressiveRollout are optional but you must have one of the 3.
If you have more than one field we will use the first one in that order
The rule format is based on the
All the operations can be written capitalized or lowercase (ex:
EQ can be used).
Logical Operations supported are
Compare Expression and their definitions (
a|b means you can use either one of the two
|not equals to
|less than equal to
|greater than equal to
|in a list
|not of a logical expression
Select a specific user:
key eq "email@example.com"
Select all identified users:
anonymous ne true
Select a user with a custom property:
userId eq "12345"
Select on multiple criteria: All users with ids finishing by
@test.comthat have the role
backend engineerin the
proenvironment for the company
(key ew "@test.com") and (role eq "backend engineer") and (env eq "pro") and (company eq "go-feature-flag")
When you initialise
go-feature-flag you can set an environment for the instance of this SDK.
When an environment is set, it adds a new field in your user called
env that you can use in your queries.
It means that you can decide to activate a flag only for some environment.
Example of flag configuration based on the environment:
- name: Target pre environment
query: env eq "pre"
- name: Target pro environment
query: env eq "pro"
Get the rule name in the metadata
When you use a rule in your targeting, you can get the name of the rule in the metadata of the variation.
The information on what rule has been used to serve the variation is available in the metadata of the variation in the field called
If you are interested about this information, you have to name your rules by adding the field
name in your rule. This name will be extract and added in the
evaluatedRuleName field of the metadata.