Skip to content

Commit c55845d

Browse files
feat(cli): Jexl evaluation cli docs (#783)
1 parent b9b3504 commit c55845d

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

docs/platform-guides/mobile-tools/nimbus-cli/00-index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The principle goals for the `nimbus-cli` is to make testing and developing exper
2424
Additionally, it is useful to be developers to investigate problems with the apps and with the internal state of the Nimbus SDK:
2525

2626
- to [test feature configurations](/technical-reference/nimbus-cli/working-with-features) without needing to interact with experimenter
27+
- to [test targeting expressions](/technical-reference/nimbus-cli/testing-targeting) to validate experiment eligibility logic
2728
- to [validate experiments and feature configurations](/technical-reference/nimbus-cli/fml) against the app's feature manifest
2829
- to [display and capture the logs](/technical-reference/nimbus-cli/working-with-logs) of the device
2930
- to [display the state of the Nimbus SDK in the logs](/technical-reference/nimbus-cli/working-with-logs#log-state).

docs/platform-guides/mobile-tools/nimbus-cli/20-getting-started.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ Notice:
204204
- 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.
205205
- the bucketing is the percentage of eligible clients that will enroll in the experiment, across all branches.
206206

207+
:::tip
208+
You can test JEXL targeting expressions directly on a device or simulator using the [`eval-jexl` command](/technical-reference/nimbus-cli/testing-targeting).
209+
:::
210+
207211
You can also get this outputed to a file as JSON or YAML with the `--output` parameter.
208212

209213
```sh
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
id: nimbus-cli-testing-targeting
3+
title: Targeting
4+
slug: /technical-reference/nimbus-cli/testing-targeting
5+
---
6+
7+
The `eval-jexl` command evaluates [JEXL targeting expressions](/advanced/behavioral-targeting) against the app's runtime context.
8+
9+
## `eval-jexl`
10+
11+
```sh
12+
nimbus-cli --app <APP> --channel <CHANNEL> eval-jexl "<EXPRESSION>"
13+
```
14+
15+
For example, to test a locale targeting expression:
16+
17+
```sh
18+
nimbus-cli --app fenix --channel developer eval-jexl "locale == 'en-US'"
19+
```
20+
21+
If the expression is true on the device:
22+
23+
```json
24+
{
25+
"success": true,
26+
"result": true
27+
}
28+
```
29+
30+
If the expression is false on the device:
31+
32+
```json
33+
{
34+
"success": true,
35+
"result": false
36+
}
37+
```
38+
39+
The `success` field indicates whether the expression was evaluated without errors. The `result` field contains the boolean result of the expression evaluation.
40+
41+
### Examples
42+
43+
Test app version comparisons using the `versionCompare` filter:
44+
45+
```sh
46+
nimbus-cli --app fenix --channel release eval-jexl "app_version|versionCompare('120.0') >= 0"
47+
```
48+
49+
```sh
50+
nimbus-cli --app firefox_ios --channel beta eval-jexl "app_version|versionCompare('120.0') >= 0"
51+
```
52+
53+
Test whether the app is the default browser:
54+
55+
```sh
56+
nimbus-cli --app fenix --channel developer eval-jexl "is_default_browser"
57+
```
58+
59+
Test complex logical expressions:
60+
61+
```sh
62+
nimbus-cli --app fenix --channel release eval-jexl "locale == 'en-US' && app_version|versionCompare('120.0') >= 0"
63+
```
64+
65+
```sh
66+
nimbus-cli --app firefox_ios --channel developer eval-jexl "locale == 'en-CA'"
67+
```
68+
69+
### Options
70+
71+
The `--pbcopy` option copies the deeplink result to your clipboard:
72+
73+
```sh
74+
nimbus-cli --app fenix --channel developer eval-jexl "is_default_browser" --pbcopy
75+
```

0 commit comments

Comments
 (0)