Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The principle goals for the `nimbus-cli` is to make testing and developing exper
Additionally, it is useful to be developers to investigate problems with the apps and with the internal state of the Nimbus SDK:

- to [test feature configurations](/technical-reference/nimbus-cli/working-with-features) without needing to interact with experimenter
- to [test targeting expressions](/technical-reference/nimbus-cli/testing-targeting) to validate experiment eligibility logic
- to [validate experiments and feature configurations](/technical-reference/nimbus-cli/fml) against the app's feature manifest
- to [display and capture the logs](/technical-reference/nimbus-cli/working-with-logs) of the device
- to [display the state of the Nimbus SDK in the logs](/technical-reference/nimbus-cli/working-with-logs#log-state).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ Notice:
- the targeting string is a JEXL expression, generated by Experimenter, and is the test all clients must pass in order to be considered _eligible_ for this experiment.
- the bucketing is the percentage of eligible clients that will enroll in the experiment, across all branches.

:::tip
You can test JEXL targeting expressions directly on a device or simulator using the [`eval-jexl` command](/technical-reference/nimbus-cli/testing-targeting).
:::

You can also get this outputed to a file as JSON or YAML with the `--output` parameter.

```sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
id: nimbus-cli-testing-targeting
title: Targeting
slug: /technical-reference/nimbus-cli/testing-targeting
---

The `eval-jexl` command evaluates [JEXL targeting expressions](/advanced/behavioral-targeting) against the app's runtime context.

## `eval-jexl`

```sh
nimbus-cli --app <APP> --channel <CHANNEL> eval-jexl "<EXPRESSION>"
```

For example, to test a locale targeting expression:

```sh
nimbus-cli --app fenix --channel developer eval-jexl "locale == 'en-US'"
```

If the expression is true on the device:

```json
{
"success": true,
"result": true
}
```

If the expression is false on the device:

```json
{
"success": true,
"result": false
}
```

The `success` field indicates whether the expression was evaluated without errors. The `result` field contains the boolean result of the expression evaluation.

### Examples

Test app version comparisons using the `versionCompare` filter:

```sh
nimbus-cli --app fenix --channel release eval-jexl "app_version|versionCompare('120.0') >= 0"
```

```sh
nimbus-cli --app firefox_ios --channel beta eval-jexl "app_version|versionCompare('120.0') >= 0"
```

Test whether the app is the default browser:

```sh
nimbus-cli --app fenix --channel developer eval-jexl "is_default_browser"
```

Test complex logical expressions:

```sh
nimbus-cli --app fenix --channel release eval-jexl "locale == 'en-US' && app_version|versionCompare('120.0') >= 0"
```

```sh
nimbus-cli --app firefox_ios --channel developer eval-jexl "locale == 'en-CA'"
```

### Options

The `--pbcopy` option copies the deeplink result to your clipboard:

```sh
nimbus-cli --app fenix --channel developer eval-jexl "is_default_browser" --pbcopy
```