View Source Flagsmith.Client (flagsmith_engine v2.1.0)

Link to this section Summary

Functions

Return all flags from an environment as a list. If a Flagsmith.Schemas.Environment.t/0 is passed instead of a Flagsmith.Configuration.t/0 or list of options, then the flags are extracted from it.

Returns an :ok tuple containing a Flagsmith.Schemas.Environment.t/0 struct, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to.

Returns an :ok tuple containing a list of Flagsmith.Schemas.Flag.t/0 structs, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to.

Returns a Flagsmith.Schemas.Flag.t/0 by name, or :not_found if the feature doesn't exist.

Returns a Flagsmith.Schemas.Flag.t/0 by name. If the feature doesn't exist, it returns :not_found by default or in case default_flag_handler has been set returns what the call to that function with the feature name returns.

Returns an :ok tuple containing a list of Flagsmith.Schemas.Flag.t/0 structs, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to. The flags are retrieved based on a user identifier so take into account segments and traits.

Returns the :enabled status of a feature by name, or :not_found if the feature doesn't exist.

Create a Flagsmith.Configuration.t/0 struct with the desired settings to use in requests. All settings are optional with exception of the :environment_key if not configured at the application level. Non specified options will assume defaults, or if set at the application level use that.

Link to this section Types

@type tesla_header_list() :: [{String.t(), String.t()}]

Link to this section Functions

Link to this function

all_flags(config_or_opts_or_env_or_flags \\ [])

View Source
@spec all_flags(config_or_env()) :: [Flagsmith.Schemas.Flag.t()]

Return all flags from an environment as a list. If a Flagsmith.Schemas.Environment.t/0 is passed instead of a Flagsmith.Configuration.t/0 or list of options, then the flags are extracted from it.

Link to this function

get_environment(configuration_or_opts \\ [])

View Source
@spec get_environment(Flagsmith.Configuration.t() | Keyword.t()) ::
  {:ok, Flagsmith.Schemas.Environment.t()} | {:error, term()}

Returns an :ok tuple containing a Flagsmith.Schemas.Environment.t/0 struct, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to.

Passing a Flagsmith.Configuration.t/0 or options with :enable_local_evaluation as true will start a local process for the given api key used, if one is not started yet, which requires you to be running the Flagsmith.Supervisor.

Link to this function

get_environment_flags(configuration_or_env_or_opts \\ [])

View Source
@spec get_environment_flags(config_or_env()) ::
  {:ok, Flagsmith.Schemas.Flags.t()} | {:error, term()}

Returns an :ok tuple containing a list of Flagsmith.Schemas.Flag.t/0 structs, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to.

Passing a Flagsmith.Configuration.t/0 or options with :enable_local_evaluation as true will start a local process for the given api key used, if one is not started yet, which requires you to be running the Flagsmith.Supervisor.

Link to this function

get_feature_value(configuration_or_env_or_opts \\ [], feature_name)

View Source
@spec get_feature_value(config_or_env(), feature_name :: String.t()) ::
  :not_found | term()

Returns a Flagsmith.Schemas.Flag.t/0 by name, or :not_found if the feature doesn't exist.

If a Flagsmith.Schemas.Environment.t/0 is passed instead of a Flagsmith.Configuration.t/0 or list of options, then the feature is looked up in that environment, otherwise a local evaluation or api call is executed according to the configuration or passed options.

Link to this function

get_flag(configuration_or_env_or_opts \\ [], feature_name)

View Source
@spec get_flag(
  config_or_env() | Flagsmith.Schemas.Flags.t(),
  feature_name :: String.t()
) :: Flagsmith.Schemas.Flag.t() | :not_found | term()

Returns a Flagsmith.Schemas.Flag.t/0 by name. If the feature doesn't exist, it returns :not_found by default or in case default_flag_handler has been set returns what the call to that function with the feature name returns.

If a Flagsmith.Schemas.Environment.t/0 is passed instead of a Flagsmith.Configuration.t/0 or list of options, then the feature is looked up in that environment, otherwise a local evaluation or api call is executed according to the configuration or passed options.

Link to this function

get_identity_flags(configuration_or_opts \\ [], identifier, traits)

View Source
@spec get_identity_flags(Flagsmith.Configuration.t() | Keyword.t(), String.t(), [
  map() | Flagsmith.Schemas.Traits.Trait.t()
]) :: {:ok, Flagsmith.Schemas.Flags.t()} | {:error, term()}

Returns an :ok tuple containing a list of Flagsmith.Schemas.Flag.t/0 structs, either from the local evaluation or API depending on the configuration used, or an :error tuple if unable to. The flags are retrieved based on a user identifier so take into account segments and traits.

Note: when using local evaluation there's no way to update the traits, the traits passed on to this function are used to check any segment rule specified on the Flagsmith.Schemas.Environment.t/0 you're accessing. On the other hand, when using the live API evaluation the traits you pass will be used to update the traits associated with the identity you're specifying.

Passing a Flagsmith.Configuration.t/0 or options with :enable_local_evaluation as true will start a local process for the given api key used, if one is not started yet, which requires you to be running the Flagsmith.Supervisor.

Link to this function

is_feature_enabled(configuration_or_env_or_opts \\ [], feature_name)

View Source
@spec is_feature_enabled(config_or_env(), feature_name :: String.t()) ::
  boolean() | :not_found | term()

Returns the :enabled status of a feature by name, or :not_found if the feature doesn't exist.

If a Flagsmith.Schemas.Environment.t/0 is passed instead of a Flagsmith.Configuration.t/0 or list of options, then the feature is evaluated from that environment, otherwise a local evaluation or api call is executed according to the configuration or passed options.

Create a Flagsmith.Configuration.t/0 struct with the desired settings to use in requests. All settings are optional with exception of the :environment_key if not configured at the application level. Non specified options will assume defaults, or if set at the application level use that.