View Source Unleash.Context (Unleash v3.0.0)
The Unleash Context, mostly used to evaluate conditional activation strategies. https://docs.getunleash.io/reference/unleash-context.
The Context has a predefined set of fields,
but custom context properties can be set in the :properties
field.
Note that, for hystorical / backwards-compatibility reasons,
both atom and string keys are allowed in the properties map.
You are encouraged to use find/2
to lookup context values in a way
that handles fallback to properties and the different style of keys correctly.
Summary
Functions
Looks for a context value, taking care of some of the nasty details
like fallback to :properties
(a.k.a. custom context values)
with support for both atom and string keys.
Types
@type t() :: %{ optional(:app_name) => String.t(), optional(:environment) => String.t(), optional(:user_id) => String.t(), optional(:session_id) => String.t(), optional(:remote_address) => String.t(), optional(:properties) => %{required(atom() | String.t()) => String.t()}, optional(:current_time) => String.t() }
Functions
Looks for a context value, taking care of some of the nasty details
like fallback to :properties
(a.k.a. custom context values)
with support for both atom and string keys.
Specifically:
- If the key is a standard context key (either in its atom or string form), it looks for it in the standard context fields, without fallbacking to properties.
- Otherwise, it looks for it in properties, trying both the atomized and the stringified version of the key, starting from the supplied one.
NOTE that this can create atom at runtimes, which is dangerous. It is highly recommended you do not call this function with values from untrusted / unbounded sources.