# `Featurevisor`
[🔗](https://github.com/featurevisor/featurevisor-elixir/blob/v2.1.0/lib/featurevisor.ex#L1)

Feature flags, experiments, and remote configuration for Elixir.

Create an isolated instance with `create_featurevisor/1`, then evaluate flags,
variations, and variables against a Featurevisor schema version 4 or legacy schema version 2 datafile.

# `options`

```elixir
@type options() :: %{
  optional(:datafile) =&gt; map() | String.t(),
  optional(:context) =&gt; map(),
  optional(:log_level) =&gt; Featurevisor.Diagnostic.level(),
  optional(:on_diagnostic) =&gt; (Featurevisor.Diagnostic.t() -&gt; any()),
  optional(:sticky_features) =&gt; map(),
  optional(:sticky_variables) =&gt; map(),
  optional(:modules) =&gt; [Featurevisor.Module.t()],
  optional(:name) =&gt; GenServer.name()
}
```

# `t`

```elixir
@opaque t()
```

# `add_module`

Registers an SDK module. Returns an idempotent removal function or nil.

# `apply_variable_operations`

```elixir
@spec apply_variable_operations(term(), [map()]) :: term()
```

Applies variable mutation operations to a value, as datafile overrides do,
for packages that change their entries by the same notation. Raises
`ArgumentError` for an operation the interpreter refuses.

# `close`

Closes modules, subscriptions, listeners, caches, and the instance owner.

# `create_featurevisor`

```elixir
@spec create_featurevisor(options() | keyword()) :: t()
```

Creates an isolated Featurevisor instance.

# `enabled?`

Returns whether a feature is enabled.

# `evaluate_flag`

Evaluates a feature flag and returns details.

# `evaluate_global_variable`

Evaluates a global variable and returns details.

# `evaluate_variable`

Evaluates a variable and returns details.

# `evaluate_variation`

Evaluates a variation and returns details.

# `get_context`

Returns stored context merged with optional evaluation context.

# `get_feature`

Returns a feature definition.

# `get_feature_evaluations`

Evaluates all or selected features.

# `get_feature_keys`

Returns all feature keys. Ordering is not guaranteed.

# `get_global_variable`

Returns a global variable value or nil. JSON variables are decoded.

# `get_global_variable_array`

Returns a typed list global variable.

# `get_global_variable_boolean`

Returns a typed boolean global variable.

# `get_global_variable_evaluations`

Evaluates all or selected global variables.

# `get_global_variable_integer`

Returns a typed integer global variable.

# `get_global_variable_json`

Returns a decoded JSON global variable.

# `get_global_variable_keys`

Returns all global variable keys. Ordering is not guaranteed.

# `get_global_variable_number`

Returns a typed number global variable, whole or fractional.

# `get_global_variable_object`

Returns a typed map global variable.

# `get_global_variable_string`

Returns a typed string global variable.

# `get_revision`

Returns the current datafile revision.

# `get_schema_version`

Returns the informational datafile schema version.

# `get_segment`

Returns a segment definition.

# `get_variable`

Returns a variable value or nil. JSON variables are decoded.

# `get_variable_array`

Returns a list variable after runtime type checking.

# `get_variable_boolean`

Returns a boolean variable after runtime type checking.

# `get_variable_integer`

Returns an integer variable after runtime type checking.

# `get_variable_json`

Returns a decoded JSON variable.

# `get_variable_keys`

Returns variable keys for a feature.

# `get_variable_number`

Returns a finite number variable, whole or fractional, after runtime type checking.

# `get_variable_object`

Returns a map variable after runtime type checking.

# `get_variable_string`

Returns a string variable after runtime type checking.

# `get_variation`

Returns a variation value or nil.

# `has_module?`

```elixir
@spec has_module?(t(), String.t()) :: boolean()
```

Whether a module with the supplied name is registered, as a package that
registers under its own name checks before adding a second.

# `has_variations?`

Returns whether a feature defines variations.

# `instance`

```elixir
@spec instance(GenServer.server()) :: t()
```

Returns a Featurevisor handle for a running owner process or registered name.

# `on`

Subscribes to an event and returns an idempotent unsubscribe function.

# `portable_timestamp`

```elixir
@spec portable_timestamp(term()) :: integer() | nil
```

Milliseconds since the epoch of a portable timestamp, as `before` and `after`
read one, such as `2026-01-31T09:00:00Z`, or nil for a value that is not one.

# `remove_module`

Removes every module with the supplied name.

# `set_context`

Merges or replaces the stored context.

# `set_datafile`

```elixir
@spec set_datafile(t(), map() | String.t(), boolean()) :: boolean()
```

Merges or replaces the stored datafile.

Returns true when accepted, including unchanged input, or false when rejected or closed.

# `set_log_level`

Changes the diagnostic threshold.

# `set_sticky_features`

Merges or replaces sticky feature evaluations.

# `set_sticky_variables`

Merges or replaces sticky global variable values.

# `spawn`

Spawns a child instance with isolated context and sticky state.

# `start_link`

```elixir
@spec start_link(options() | keyword()) :: GenServer.on_start()
```

Starts a supervised Featurevisor owner process.

# `valid_version?`

```elixir
@spec valid_version?(term()) :: boolean()
```

Whether a value is a version the semver operators accept.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
