diff --git a/docs/reference/evaluation-context/evaluation-context.mdx b/docs/reference/evaluation-context/evaluation-context.mdx new file mode 100644 index 00000000..1a01f825 --- /dev/null +++ b/docs/reference/evaluation-context/evaluation-context.mdx @@ -0,0 +1,59 @@ +--- +sidebar_position: 1 +id: evaluation-context +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Evaluation Context + +The _evaluation context_ is a container for arbitrary contextual data that can be used as a basis for dynamic evaluation. Static data such as the host or an identifier for the application can be configured globally. Dynamic evaluation context, such as the IP address of the client in a web application, can be implicitly propagated or explicitly passed to during flag evaluation, and can be merged with static values. + +## Providing Evaluation Context + + + +Values relevant for flag evaluation can be included in the evaluation context. + + + + +```ts +// add a value to the invocation context +const context: EvaluationContext = { + myKey: 'myValue', +}; +const boolValue = await client.getBooleanValue('boolFlag', false, context); +``` + + + + +```java +// add a value to the invocation context +EvaluationContext context = new EvaluationContext(); +context.addStringAttribute("myKey", "myValue") +Boolean boolValue = client.getBooleanValue("boolFlag", false, context); +``` + + + + +```csharp +// add a value to the invocation context +var context = new EvaluationContext(); +context.Add("myKey", "myValue"); +var boolValue = await client.GetBooleanValue("boolFlag", false, context); +``` + + + + +## Targeting Key + +Many feature flag management systems require an identifier for the subject of flag evaluation. For many feature flag systems this is required in order to perform fractional evaluation or percentage-based rollouts deterministically. In the case of web applications or mobile apps, the subject is frequently an end user, but in other cases it could be a service or client application. The `evaluation context` includes an optional `targeting key` field for this purpose. The targeting key should contain a string uniquely identifying the subject (i.e.: a UUID, a hash of some user attribute such as an email, or a the hostname of an application or service). Some providers may require this field to be set to function correctly. + +## Personally Identifiable Information (PII) Considerations + +Be thoughtful in your inclusion of personal data in the `evaluation context`. Such data is useful for targeting and dynamic evaluation, but you should consider how the provider in use may handle or persist this data. Hooks (specifically hooks implementing the _before_ stage) can be useful to restrict, filter or anonymize data in the `evaluation context`. diff --git a/docs/reference/intro.md b/docs/reference/intro.md index 4b5262fd..f273d7ed 100644 --- a/docs/reference/intro.md +++ b/docs/reference/intro.md @@ -29,7 +29,7 @@ The [_evaluation API_](./evaluation-api/) is the aspect of OpenFeature that the ### Evaluation Context -The _evaluation context_ is a container for arbitrary contextual data that can be used as a basis for dynamic evaluation. Static data such as the host or an identifier for the application can be configured globally. Dynamic evaluation context, such as the IP address of the client in a web application, can be implicitly propagated or explicitly passed to during flag evaluation, and can be merged with static values. +The [_evaluation context_](./evaluation-context/) is a container for arbitrary contextual data that can be used as a basis for dynamic evaluation. Static data such as the host or an identifier for the application can be configured globally. Dynamic evaluation context, such as the IP address of the client in a web application, can be implicitly propagated or explicitly passed to during flag evaluation, and can be merged with static values. ### Providers diff --git a/sidebars.js b/sidebars.js index 68e31790..a9fe01f2 100644 --- a/sidebars.js +++ b/sidebars.js @@ -23,6 +23,7 @@ const sidebars = { 'reference/evaluation-api/evaluation-api', 'reference/using-open-feature-with-your-flag-system/implement-a-provider', 'reference/hooks/hooks', + 'reference/evaluation-context/evaluation-context' ], }, ],