Context Metadata
CONTEXT_METADATA env var explained
Last updated
CONTEXT_METADATA env var explained
Last updated
What is this Context Metadata thing?
Like METRICS, the CONTEXT_METADATA env var is nothing more than a JSON dictionary of client-defined identifiers to be used to keep the client app state in sync with UpGrade. It will represent a contract of agreed-upon technical terms between the Client app, UpGrade, and users creating/tracking experiments.
You must have at least 1 CONTEXT_METADATA JSON object described in your .env
file in order for backend to compile. There's an example in .env.example
of one you can start with, but you will want to edit it once you are up and running. See also Environment Variables.
Most of these terms are not required, but the object itself is. The benefit will be to help keep UpGrade in sync with identifiers that should be valid for an experiment. The other strong benefit to keeping this metadata up-to-date is for UI autocomplete (see below for examples).
In future UpGrade releases, this context-metadata object will accommodate different app-versions per Client context, as well an API to manage this data instead of an Environment Variable. For now, a context is limited to representing client app state broadly, and must be defined in your backend configuration.
Even if keeping metadata current is not necessary for you application, you will need to at least have a boilerplate ContextMetadata object defined with your application's unique identifier as the root-level key. This key is important as it will be your application's "app-context", which will be used to partition your experiment's data and route its requests.
What exactly can I define? The context metadata object is defined in the Environment Variables and will describe:
An identifier for your app "app_context" (required).
A set of valid strings to identify names of "GROUP_TYPES" of users within your context (if using groups).
A set of valid strings to identify places in codebase where your experiment conditions will be delivered ("Decision Points"). Decision Points are a composite id of two identifiers, Site + Target: - "Sites" (also known as "EXP_POINTS"), e.g. a module or other broad codebase identifier - "Targets" (also known as "EXP_IDS"), e.g. a specific point in code
A set of valid strings to identify the "CONDITIONS" expected by your codebase.
This must be valid JSON, but it may be easier to describe as a Typescript Type interface:
So an example in your .env
files might contain some like this:
Where will I see these values get used? In UpGrade UI, you will see all of these values pop up as you create a new experiment: