diff --git a/docs/platform-guides/mobile-tools/nimbus-cli/00-index.mdx b/docs/platform-guides/mobile-tools/nimbus-cli/00-index.mdx index b071c81c6..cd47afa85 100644 --- a/docs/platform-guides/mobile-tools/nimbus-cli/00-index.mdx +++ b/docs/platform-guides/mobile-tools/nimbus-cli/00-index.mdx @@ -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). diff --git a/docs/platform-guides/mobile-tools/nimbus-cli/20-getting-started.mdx b/docs/platform-guides/mobile-tools/nimbus-cli/20-getting-started.mdx index 3f40c0dff..6c40b2641 100644 --- a/docs/platform-guides/mobile-tools/nimbus-cli/20-getting-started.mdx +++ b/docs/platform-guides/mobile-tools/nimbus-cli/20-getting-started.mdx @@ -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 diff --git a/docs/platform-guides/mobile-tools/nimbus-cli/45-testing-targeting.mdx b/docs/platform-guides/mobile-tools/nimbus-cli/45-testing-targeting.mdx new file mode 100644 index 000000000..3c02db1e1 --- /dev/null +++ b/docs/platform-guides/mobile-tools/nimbus-cli/45-testing-targeting.mdx @@ -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 --channel eval-jexl "" +``` + +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 +```