From 0a5c04c60d24c88ea3fe771ecfe470f54dbdc0d8 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Thu, 30 Jul 2026 12:11:12 +0200 Subject: [PATCH 1/2] Improve documentation on evaluation context to User Object mapping for some OpenFeature providers --- .../docs/sdk-reference/openfeature/dotnet.mdx | 21 ++++++++++++------- website/docs/sdk-reference/openfeature/js.mdx | 19 +++++++++++------ .../docs/sdk-reference/openfeature/node.mdx | 19 +++++++++++------ 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/website/docs/sdk-reference/openfeature/dotnet.mdx b/website/docs/sdk-reference/openfeature/dotnet.mdx index 81d9c6730..0bc32375a 100644 --- a/website/docs/sdk-reference/openfeature/dotnet.mdx +++ b/website/docs/sdk-reference/openfeature/dotnet.mdx @@ -91,18 +91,25 @@ The ConfigCat provider translates these evaluation contexts to ConfigCat [User O The following table shows how the different context attributes are mapped to User Object attributes. -| Evaluation context | User Object | Required | -| ------------------ | ------------ | -------- | -| `Id`/`Identifier` | `Identifier` | ☑ | -| `Email` | `Email` | | -| `Country` | `Country` | | -| Any other | `Custom` | | +| Evaluation context | User Object | Required | +| ------------------------------------ | ------------ | -------- | +| `targetingKey` (`Id` / `Identifier`) | `Identifier` | ☑ | +| `Email` | `Email` | | +| `Country` | `Country` | | +| Any other | `Custom` | | + +Remarks: +- If `targetingKey` is present in the evaluation context, it will be mapped to the `Identifier` property. Otherwise, `Id` or `Identifier` will be mapped, whichever occurs first. + (If none of these keys are present, the `Identifier` property will be set to the fallback value `""`.) +- The keys `Id`, `Identifier`, `Email` and `Country` are matched case-insensitively. If the same key appears in multiple cases - e.g. `email` and `Email` - the first occurrence will be mapped to the corresponding property. +- All of the above will also be included in the `Custom` dictionary (except for the exact keys `Identifier`, `Email` and `Country`). This allows them to be referenced using their original names in feature flag rules. +- Other keys are mapped as custom user attributes with their values unchanged. (Although the ConfigCat SDK handles value conversion internally, it's recommended to use the type expected by the referencing feature flag rules. Read more [here](../../dotnet/#user-object-attribute-types).) To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```cs var context = OpenFeature.Model.EvaluationContext.Builder() - .Set("Id", "#SOME-USER-ID#") + .SetTargetingKey("#SOME-USER-ID#") .Set("Email", "configcat@example.com") .Set("Country", "CountryID") .Set("Rating", 4.5) diff --git a/website/docs/sdk-reference/openfeature/js.mdx b/website/docs/sdk-reference/openfeature/js.mdx index 26672cdb5..9ced7731f 100644 --- a/website/docs/sdk-reference/openfeature/js.mdx +++ b/website/docs/sdk-reference/openfeature/js.mdx @@ -68,12 +68,19 @@ The ConfigCat provider translates these evaluation contexts to ConfigCat [User O The following table shows how the different context attributes are mapped to User Object attributes. -| Evaluation context | User Object | Required | -| ------------------ | ------------ | -------- | -| `targetingKey` | `identifier` | ☑ | -| `email` | `email` | | -| `country` | `country` | | -| Any other | `custom` | | +| Evaluation context | User Object | Required | +| ----------------------------- | ------------ | -------- | +| `targetingKey` (`identifier`) | `identifier` | ☑ | +| `email` | `email` | | +| `country` | `country` | | +| Any other | `custom` | | + +Remarks: +- If `targetingKey` is present in the evaluation context, it will be mapped to the `Identifier` property. Otherwise, `identifier` will be mapped. + (If none of these keys are present, the ConfigCat SDK will fall back to using an empty string for the identifier.) +- Predefined keys (i.e., `targetingKey`, `identifier`, `email` and `country`) are matched case-sensitively. (Despite this, never use the keys `Identifier`, `Email` or `Country`, as those are ignored for technical reasons.) +- Predefined keys will also be included in the `custom` object. This allows them to be referenced using their original names in feature flag rules. +- Other keys are mapped as custom user attributes with their values unchanged, except for objects and non-string arrays, which are converted to JSON for historical reasons. (Although the ConfigCat SDK handles value conversion internally, it's recommended to use the type expected by the referencing feature flag rules. Read more [here](../../js/overview#user-object-attribute-types).) To evaluate feature flags for a context, use the OpenFeature Evaluation API: diff --git a/website/docs/sdk-reference/openfeature/node.mdx b/website/docs/sdk-reference/openfeature/node.mdx index 077150e27..370d57a62 100644 --- a/website/docs/sdk-reference/openfeature/node.mdx +++ b/website/docs/sdk-reference/openfeature/node.mdx @@ -68,12 +68,19 @@ The ConfigCat provider translates these evaluation contexts to ConfigCat [User O The following table shows how the different context attributes are mapped to User Object attributes. -| Evaluation context | User Object | Required | -| ------------------ | ------------ | -------- | -| `targetingKey` | `identifier` | ☑ | -| `email` | `email` | | -| `country` | `country` | | -| Any other | `custom` | | +| Evaluation context | User Object | Required | +| ----------------------------- | ------------ | -------- | +| `targetingKey` (`identifier`) | `identifier` | ☑ | +| `email` | `email` | | +| `country` | `country` | | +| Any other | `custom` | | + +Remarks: +- If `targetingKey` is present in the evaluation context, it will be mapped to the `Identifier` property. Otherwise, `identifier` will be mapped. + (If none of these keys are present, the ConfigCat SDK will fall back to using an empty string for the identifier.) +- Predefined keys (i.e., `targetingKey`, `identifier`, `email` and `country`) are matched case-sensitively. (Despite this, never use the keys `Identifier`, `Email` or `Country`, as those are ignored for technical reasons.) +- Predefined keys will also be included in the `custom` object. This allows them to be referenced using their original names in feature flag rules. +- Other keys are mapped as custom user attributes with their values unchanged, except for objects and non-string arrays, which are converted to JSON for historical reasons. (Although the ConfigCat SDK handles value conversion internally, it's recommended to use the type expected by the referencing feature flag rules. Read more [here](../../js/overview#user-object-attribute-types).) To evaluate feature flags for a context, use the OpenFeature Evaluation API: From f81759ea248d826c536925b71ac471adf5df8579 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Fri, 31 Jul 2026 11:11:51 +0200 Subject: [PATCH 2/2] Fix indentation in code examples --- website/docs/sdk-reference/dotnet/_template.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/docs/sdk-reference/dotnet/_template.mdx b/website/docs/sdk-reference/dotnet/_template.mdx index 40a68d3d0..04c71c535 100644 --- a/website/docs/sdk-reference/dotnet/_template.mdx +++ b/website/docs/sdk-reference/dotnet/_template.mdx @@ -265,7 +265,7 @@ using ConfigCat.Extensions.Hosting; { configCatBuilder.AddDefaultClient(options => { - options.SdkKey = "#YOUR-SDK-KEY#"; + options.SdkKey = "#YOUR-SDK-KEY#"; }); }); ``` @@ -301,10 +301,10 @@ using ConfigCat.Extensions.Hosting; ```csharp services.AddConfigCat(configCatBuilder => { - configCatBuilder.AddDefaultClient(options => - { - options.SdkKey = "#YOUR-SDK-KEY#"; - }); + configCatBuilder.AddDefaultClient(options => + { + options.SdkKey = "#YOUR-SDK-KEY#"; + }); }); ```