CLI: Targeting Rules
Manage
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting get
You will be prompted to select a feature and environment.
If successful you will receive a response which resembles the following (which selected a feature named feature-a
and the Development
environment):
└─ Development
└─ status
└─ enabled
To enable a targeting rule for a Feature, you will follow a similar process to above but using the command
dvc targeting enable
If successful you will receive a response which resembles the following (for enabling the targeting rules for the Staging
environment of a feature):
└─ Staging
├─ status
│ └ ─ enabled
└─ rules
└─ 1. All Users
├─ definition
│ └─ All Users
└─ serve
└─ Variation On
To disable a targeting rule for a Feature, you will follow a similar process to above but using the command
dvc targeting disable
If successful you will receive a response which resembles the following (for disabling the targeting rules for the Staging
environment of a feature):
└─ Staging
├─ status
│ └─ disabled
└─ rules
└─ 1. All Users
├─ definition
│ └─ All Users
└─ serve
└─ Variation On
Create
Once you have installed and authorized the CLI, select your relevant organization then run the following command:
dvc targeting update
You will be prompted to select a feature, environment and what you would like to update (status or targets). For this case you should select only targets
.
You should then select Add Targeting Rule
and will be prompted to define a Name, Variations to serve and a filter. For this case, if you have not yet created any filters, you should select Add Filter
.
Here you will be prompted to select a definition of all (for all users), user (to target a specific user based on an identifier like email, country, etc.) or audienceMatch (see Audiences).
Looking to reuse an audience in user targeting for features? Be sure to check out the our documentation explaining how to create and manage Audiences via our API or within the DevCycle dashboard.
Once you have chosen your relevant definition select Continue
(twice) when prompted. If successful you should see a flow which resembles the following (which represents added a new targeting rule to feature-a
in the Staging Environment
for any users with the email address that contains devcycle
and will serve them a variation named New Variation
):
? Which feature? feature-a
? Which environment? Staging (staging)
? Which fields are you updating targets
🤖 Manage your Targeting
🤖 Current Targeting Rules:
└─ 1. All Users
├─ definition
│ └─ All Users
└─ serve
└─ Variation On
? Select an action: Add Targeting Rule
? Name: New Targeting Rule
? Variation to serve New Variation (new-variation)
🤖 No existing Filters.
? Select an action: Add Filter
? Type for definition user
? Subtype for definition email
? Comparator for definition contain
? List of comma separated values for definition: devcycle
🤖 Manage your filters
🤖 Current Filters:
└─ Email
└─ contains
└─ devcycle
----------------------------------------
? Select an action: Continue
🤖 Manage your filters
🤖 Current Filters:
└─ Email
└─ contains
└─ devcycle
----------------------------------------
🤖 Manage your Targeting
🤖 Current Targeting Rules:
├─ 1. All Users
│ ├─ definition
│ │ └─ All Users
│ └─ serve
│ └─ Variation On
└─ 2. New Targeting Rule
├─ definition
│ └─ Email
│ └─ contains
│ └─ devcycle
└─ serve
└─ new-variation
----------------------------------------
? Select an action: Continue
🤖 Manage your Targeting
🤖 Current Targeting Rules:
├─ 1. All Users