Featurevisor

Building blocks

Targets

Targets define what goes into generated datafiles.

A target can represent an application, platform, service, frontend, or any other runtime that should receive its own datafile.

Targets

Defining Targets

Create target files in the targets directory:

targets/web.yml
description: Web app datafile

Only description is required. A target with no selectors includes every active feature and global variable:

targets/all.yml
description: Complete datafile

Archived definitions are omitted. Feature exposure settings also remain authoritative.

Generated datafile will be available at datafiles/featurevisor-web.json for this target. If you have environments configured, the datafile will be available at datafiles/production/featurevisor-web.json for the production environment.

Selection model

Features and global variables are filtered independently. Adding a selector for one kind does not make the other kind explicit.

Target selectorsFeaturesGlobal variables
NoneAll active featuresAll active global variables
includeFeatures onlyMatching featuresAll active global variables
excludeFeatures onlyAll except matching onesAll active global variables
includeVariables onlyAll active featuresMatching global variables
excludeVariables onlyAll active featuresAll except matching ones
Both selector familiesFiltered independentlyFiltered independently
tag or tagsMatching tagged featuresMatching tagged variables

Once an include selector is present, selection becomes explicit for that entity kind only. For example, this narrows features while retaining every active global variable:

targets/checkout.yml
description: Checkout features with all global variables
includeFeatures:
- checkout*

Filter both kinds when both should be narrow:

targets/checkout.yml
description: Checkout datafile
includeFeatures:
- checkout*
includeVariables:
- checkout*

To exclude one kind completely, use * with its exclusion selector:

Features only
targets/checkout-features.yml
description: Checkout features
includeFeatures:
- checkout*
excludeVariables: "*"
Global variables only
targets/checkout-variables.yml
description: Checkout global variables
excludeFeatures: "*"
includeVariables:
- checkout*

Required feature dependencies may still be added to a datafile. A global variable that requires a feature brings that feature with it, even when excludeFeatures: "*" is present.

Tags

Target tag selects features and global variables matching one tag:

targets/web.yml
description: Web app
tag: web

Use tags when a target needs a selector with several tags:

targets/mobile.yml
description: Mobile apps
tags:
or:
- ios
- android

Supported shapes:

  • tag: "web"
  • tags: ["web"]
  • tags: { or: ["web", "mobile"] }
  • tags: { and: ["web", "checkout"] }

tag and tags are mutually exclusive. Tag arrays and and or or groups must contain at least one tag. If both properties are omitted, tags do not filter features or global variables.

Features

Use includeFeatures and excludeFeatures to select features by key. Patterns use glob style * matching. A single * can match any number of characters. Empty patterns, surrounding spaces, and repeated ** patterns are rejected.

targets/checkout.yml
description: Checkout datafile
includeFeatures:
- checkout*
- shared.navigation
excludeFeatures:
- checkout.internal*

Exclusions take precedence over inclusions. If includeFeatures is omitted, all features are candidates. Use * directly to state that explicitly:

targets/all.yml
description: All features
includeFeatures: "*"

Feature and tag selectors use AND semantics. A feature must match both selectors:

targets/web-checkout.yml
description: Web checkout features
tag: web
includeFeatures:
- checkout*

In this example, a feature whose key starts with checkout is not included unless it also has the web tag.

Global variables

Use includeVariables and excludeVariables to select global variables by key. They use the same glob style patterns as feature selectors:

targets/checkout.yml
description: Checkout datafile
includeVariables:
- checkout*
- shared.currency
excludeVariables:
- checkout.internal*

Exclusions take precedence. If includeVariables is omitted, all global variables are candidates. Use includeVariables: "*" to state that explicitly.

Tags and variable patterns use AND semantics. A global variable must satisfy both when both are present:

targets/web-checkout.yml
description: Web checkout datafile
tag: web
includeVariables:
- checkout*

This target includes global variables whose keys start with checkout and which also have the web tag.

Dependencies

Target selectors choose the initial features and global variables. Featurevisor then adds the runtime definitions needed to evaluate them correctly:

  • Required feature chains
  • Segments used by selected feature rules and overrides
  • Segments used by selected global variable overrides

Dependency closure takes precedence over feature inclusion and exclusion patterns. This prevents a narrowly filtered datafile from silently changing evaluation results because a required feature is missing.

Context

Target context represents values known while building. Featurevisor applies this context and removes rules or segments that are no longer needed.

targets/chrome.yml
description: Chrome users
tag: web
context:
browser: chrome

Promotable

In a project that uses sets, a target can protect its existing destination definition from later promotions by setting promotable: false at the top level:

sets/production/targets/web.yml
description: Production web datafile
promotable: false
tag: web
includeFeatures:
- checkout*

If the destination target exists, it remains unchanged when either the source or destination target has this field. A missing destination target is still created and retains promotable: false.

When promote --target=web is used, the source target selects the initial features and is included in the promotion. A protected existing destination target is preserved, but feature selection still comes from the source target used by the command.

Build Output

npx featurevisor build writes one datafile per target and environment:

Output
datafiles/staging/featurevisor-web.json
datafiles/production/featurevisor-web.json

Projects without environments write directly under datafiles:

Output
datafiles/featurevisor-web.json

Nested target files keep their directory structure:

Nested target
targets/apps/admin.yml
datafiles/apps/featurevisor-admin.json

Testing

Feature assertions can optionally choose a target:

tests/features/checkout.spec.yml
feature: checkout
assertions:
- target: web
environment: production
at: 50
context:
userId: "123"
expectedToBeEnabled: true

The test runner builds target datafiles in memory automatically.

CLI selection

Targets can be selected optionally in commands that build, inspect, test, or evaluate datafiles:

Commands
$ npx featurevisor build --target=web --target=mobile
$ npx featurevisor test --target=web --target=mobile
$ npx featurevisor evaluate --target=web --feature=checkout --context='{"userId":"123"}'
$ npx featurevisor benchmark --target=web --feature=checkout --context='{"userId":"123"}' --n=1000
$ npx featurevisor assess-distribution --target=web --feature=checkout --context='{}' --populateUuid=userId --n=1000
$ npx featurevisor list --features --target=web --target=mobile
$ npx featurevisor info --target=web --target=mobile

--target is repeatable. Runtime commands process each selected target datafile independently. Without --target, these commands keep their regular whole project behaviour. Normal builds build every target, while build --json and build --print accept at most one target.

Further reading

Previous
Global variables