diff --git a/website/docs/sdk-reference/dotnet.mdx b/website/docs/sdk-reference/dotnet.mdx index d15e87ac..d3388768 100644 --- a/website/docs/sdk-reference/dotnet.mdx +++ b/website/docs/sdk-reference/dotnet.mdx @@ -1,7 +1,7 @@ --- id: dotnet -title: .NET, .NET Core SDK Reference -description: ConfigCat .NET, .NET Core SDK Reference. This is a step-by-step guide on how to use feature flags in your .NET, .NET Core application. +title: .NET SDK Reference +description: ConfigCat .NET SDK Reference. This is a step-by-step guide on how to use feature flags in your .NET application. --- import Tabs from '@theme/Tabs'; @@ -956,7 +956,7 @@ Check out our Sample Applications how they use the _ConfigCat SDK_: See the following guides on how to use ConfigCat's .NET SDK: - .NET 6 -- .NET Core +- ASP.NET Core ## Look under the hood diff --git a/website/docs/sdk-reference/openfeature/dotnet.mdx b/website/docs/sdk-reference/openfeature/dotnet.mdx index 948f5913..81d9c673 100644 --- a/website/docs/sdk-reference/openfeature/dotnet.mdx +++ b/website/docs/sdk-reference/openfeature/dotnet.mdx @@ -38,21 +38,23 @@ dotnet add package OpenFeature.Contrib.Providers.ConfigCat ### 2. Initialize the provider -The `ConfigCatProvider` constructor takes the SDK key and an optional `ConfigCatClientOptions` argument containing the additional configuration options for the [ConfigCat .NET SDK](../../dotnet/#creating-the-configcat-client): +The `ConfigCatProvider` constructor takes the SDK key and an optional callback that can be used to specify additional configuration options for the [ConfigCat .NET SDK](../../dotnet/#creating-the-configcat-client): ```cs -using OpenFeature.Contrib.Providers.ConfigCat; +using System; +using ConfigCat.Client; +using OpenFeature.Contrib.ConfigCat; -// Build options for the ConfigCat SDK. -var options = new ConfigCatClientOptions +// Specify options for the ConfigCat SDK. +Action configureOptions = (options) => { - PollingMode = PollingModes.AutoPoll(pollInterval: TimeSpan.FromSeconds(60)); - Logger = new ConsoleLogger(LogLevel.Warning); + options.PollingMode = PollingModes.AutoPoll(pollInterval: TimeSpan.FromSeconds(60)); + options.Logger = new ConsoleLogger(LogLevel.Warning); // ... }; // Configure the provider. -OpenFeature.Api.Instance.SetProvider(new ConfigCatProvider("#YOUR-SDK-KEY#", options)); +await OpenFeature.Api.Instance.SetProviderAsync(new ConfigCatProvider("#YOUR-SDK-KEY#", configureOptions)); // Create a client. var client = OpenFeature.Api.Instance.GetClient(); @@ -64,7 +66,7 @@ For more information about all the configuration options, see the [.NET SDK docu ```cs var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false); -if(isAwesomeFeatureEnabled) +if (isAwesomeFeatureEnabled) { doTheNewThing(); } @@ -74,6 +76,14 @@ else } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.Api.Instance.ShutdownAsync(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -91,12 +101,12 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```cs -var context = new EvaluationContext() +var context = OpenFeature.Model.EvaluationContext.Builder() .Set("Id", "#SOME-USER-ID#") .Set("Email", "configcat@example.com") .Set("Country", "CountryID") .Set("Rating", 4.5) - .Set("RegisteredAt", DateTime.Parse("2023-11-22 12:34:56 +00:00", CultureInfo.InvariantCulture)) + .Set("RegisteredAt", DateTime.Parse("2023-11-22 12:34:56 +00:00", System.Globalization.CultureInfo.InvariantCulture)) .Build(); var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false, context); diff --git a/website/docs/sdk-reference/openfeature/js.mdx b/website/docs/sdk-reference/openfeature/js.mdx index 0552b0a0..aa389fc8 100644 --- a/website/docs/sdk-reference/openfeature/js.mdx +++ b/website/docs/sdk-reference/openfeature/js.mdx @@ -13,41 +13,29 @@ import TabItem from '@theme/TabItem'; ### 1. Install the provider - - - ```bash npm i @openfeature/config-cat-web-provider ``` - - - -```html - -``` - - - ### 2. Initialize the provider The `ConfigCatWebProvider.create()` function takes the SDK key and an optional `options` argument containing additional configuration options for the [ConfigCat JavaScript SDK](../../js/#creating-the-configcat-client): ```js +import { OpenFeature } from "@openfeature/web-sdk"; import { ConfigCatWebProvider } from '@openfeature/config-cat-web-provider'; +import { createConsoleLogger, LogLevel } from "configcat-js-ssr"; // Build options for the ConfigCat SDK. -const options = { - setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), - // ... +const options = { + logger: createConsoleLogger(LogLevel.Info), + setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), + // ... } // Configure the provider. -OpenFeature.setProvider(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', options)); - +await OpenFeature.setProviderAndWait(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', options)); + // Create a client. const client = OpenFeature.getClient(); ``` @@ -58,13 +46,21 @@ For more information about all the configuration options, see the [JavaScript SD ```js const isAwesomeFeatureEnabled = client.getBooleanValue('isAwesomeFeatureEnabled', false); -if(isAwesomeFeatureEnabled) { - doTheNewThing(); +if (isAwesomeFeatureEnabled) { + doTheNewThing(); } else { - doTheOldThing(); + doTheOldThing(); } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.clearProviders(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -82,10 +78,10 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```js -await OpenFeature.setContext({ - targetingKey: '#SOME-USER-ID#', - email: 'configcat@example.com', - country: 'CountryID', +await OpenFeature.setContext({ + targetingKey: '#SOME-USER-ID#', + email: 'configcat@example.com', + country: 'CountryID', }); const isAwesomeFeatureEnabled = client.getBooleanValue('isAwesomeFeatureEnabled', false); diff --git a/website/docs/sdk-reference/openfeature/node.mdx b/website/docs/sdk-reference/openfeature/node.mdx index fec6ad45..a3f2aad1 100644 --- a/website/docs/sdk-reference/openfeature/node.mdx +++ b/website/docs/sdk-reference/openfeature/node.mdx @@ -1,7 +1,7 @@ --- id: node title: OpenFeature Provider for Node.js -description: ConfigCat OpenFeature Provider for Node. This is a step-by-step guide on how to use ConfigCat with the OpenFeature Node.js SDK. +description: ConfigCat OpenFeature Provider for Node.js. This is a step-by-step guide on how to use ConfigCat with the OpenFeature Node.js SDK. --- import Tabs from '@theme/Tabs'; @@ -22,17 +22,20 @@ npm i @openfeature/config-cat-provider The `ConfigCatProvider.create()` function takes the SDK key and an optional `options` argument containing additional configuration options for the [ConfigCat Node.js SDK](../../node/#creating-the-configcat-client): ```js +import { OpenFeature } from "@openfeature/server-sdk"; import { ConfigCatProvider } from '@openfeature/config-cat-provider'; +import { createConsoleLogger, LogLevel, PollingMode } from "configcat-node"; // Build options for the ConfigCat SDK. -const options = { - setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), - // ... +const options = { + logger: createConsoleLogger(LogLevel.Info), + setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), + // ... } // Configure the provider. -OpenFeature.setProvider(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', PollingMode.AutoPoll, options)); - +await OpenFeature.setProviderAndWait(ConfigCatProvider.create('#YOUR-SDK-KEY#', PollingMode.AutoPoll, options)); + // Create a client. const client = OpenFeature.getClient(); ``` @@ -43,13 +46,21 @@ For more information about all the configuration options, see the [Node.js SDK d ```js const isAwesomeFeatureEnabled = await client.getBooleanValue('isAwesomeFeatureEnabled', false); -if(isAwesomeFeatureEnabled) { - doTheNewThing(); +if (isAwesomeFeatureEnabled) { + doTheNewThing(); } else { - doTheOldThing(); + doTheOldThing(); } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.clearProviders(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -67,10 +78,10 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```js -const context = { - targetingKey: '#SOME-USER-ID#', - email: 'configcat@example.com', - country: 'CountryID', +const context = { + targetingKey: '#SOME-USER-ID#', + email: 'configcat@example.com', + country: 'CountryID', }; const isAwesomeFeatureEnabled = await client.getBooleanValue('isAwesomeFeatureEnabled', false, context); diff --git a/website/docs/sdk-reference/overview.mdx b/website/docs/sdk-reference/overview.mdx index c57c95d7..a4c5e8a4 100644 --- a/website/docs/sdk-reference/overview.mdx +++ b/website/docs/sdk-reference/overview.mdx @@ -1,7 +1,7 @@ --- id: overview title: ConfigCat SDK Overview -description: List of all supported technologies like .NET, .NET Core, Java, JavaScript, PHP, Python, Ruby, Go, Node.js, Android, Swift, iOS, Elixir, Dart, React, Angular, Vue.js, React, Chromium, Deno, Kotlin Multiplatform, Laravel, Server-Side Rendered apps, etc. +description: List of all supported technologies like .NET, Java, JavaScript, PHP, Python, Ruby, Go, Node.js, Android, Swift, iOS, Elixir, Dart, React, Angular, Vue.js, React, Chromium, Deno, Kotlin Multiplatform, Laravel, Server-Side Rendered apps, etc. --- The purpose of the SDKs is to download and cache feature flag values and to evaluate Targeting Rules. All SDKs provide a simple interface for accessing your feature flags from your application. diff --git a/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx b/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx index c090f511..464ec104 100644 --- a/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx @@ -1,7 +1,7 @@ --- id: dotnet -title: .NET, .NET Core SDK Reference -description: ConfigCat .NET, .NET Core SDK Reference. This is a step-by-step guide on how to use feature flags in your .NET, .NET Core application. +title: .NET SDK Reference +description: ConfigCat .NET SDK Reference. This is a step-by-step guide on how to use feature flags in your .NET application. --- import Tabs from '@theme/Tabs'; @@ -776,7 +776,7 @@ Check out our Sample Applications how they use the _ConfigCat SDK_: See the following guides on how to use ConfigCat's .NET SDK: - .NET 6 -- .NET Core +- ASP.NET Core ## Look under the hood diff --git a/website/versioned_docs/version-V1/sdk-reference/openfeature/dotnet.mdx b/website/versioned_docs/version-V1/sdk-reference/openfeature/dotnet.mdx index 948f5913..81d9c673 100644 --- a/website/versioned_docs/version-V1/sdk-reference/openfeature/dotnet.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/openfeature/dotnet.mdx @@ -38,21 +38,23 @@ dotnet add package OpenFeature.Contrib.Providers.ConfigCat ### 2. Initialize the provider -The `ConfigCatProvider` constructor takes the SDK key and an optional `ConfigCatClientOptions` argument containing the additional configuration options for the [ConfigCat .NET SDK](../../dotnet/#creating-the-configcat-client): +The `ConfigCatProvider` constructor takes the SDK key and an optional callback that can be used to specify additional configuration options for the [ConfigCat .NET SDK](../../dotnet/#creating-the-configcat-client): ```cs -using OpenFeature.Contrib.Providers.ConfigCat; +using System; +using ConfigCat.Client; +using OpenFeature.Contrib.ConfigCat; -// Build options for the ConfigCat SDK. -var options = new ConfigCatClientOptions +// Specify options for the ConfigCat SDK. +Action configureOptions = (options) => { - PollingMode = PollingModes.AutoPoll(pollInterval: TimeSpan.FromSeconds(60)); - Logger = new ConsoleLogger(LogLevel.Warning); + options.PollingMode = PollingModes.AutoPoll(pollInterval: TimeSpan.FromSeconds(60)); + options.Logger = new ConsoleLogger(LogLevel.Warning); // ... }; // Configure the provider. -OpenFeature.Api.Instance.SetProvider(new ConfigCatProvider("#YOUR-SDK-KEY#", options)); +await OpenFeature.Api.Instance.SetProviderAsync(new ConfigCatProvider("#YOUR-SDK-KEY#", configureOptions)); // Create a client. var client = OpenFeature.Api.Instance.GetClient(); @@ -64,7 +66,7 @@ For more information about all the configuration options, see the [.NET SDK docu ```cs var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false); -if(isAwesomeFeatureEnabled) +if (isAwesomeFeatureEnabled) { doTheNewThing(); } @@ -74,6 +76,14 @@ else } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.Api.Instance.ShutdownAsync(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -91,12 +101,12 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```cs -var context = new EvaluationContext() +var context = OpenFeature.Model.EvaluationContext.Builder() .Set("Id", "#SOME-USER-ID#") .Set("Email", "configcat@example.com") .Set("Country", "CountryID") .Set("Rating", 4.5) - .Set("RegisteredAt", DateTime.Parse("2023-11-22 12:34:56 +00:00", CultureInfo.InvariantCulture)) + .Set("RegisteredAt", DateTime.Parse("2023-11-22 12:34:56 +00:00", System.Globalization.CultureInfo.InvariantCulture)) .Build(); var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false, context); diff --git a/website/versioned_docs/version-V1/sdk-reference/openfeature/js.mdx b/website/versioned_docs/version-V1/sdk-reference/openfeature/js.mdx index 0552b0a0..aa389fc8 100644 --- a/website/versioned_docs/version-V1/sdk-reference/openfeature/js.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/openfeature/js.mdx @@ -13,41 +13,29 @@ import TabItem from '@theme/TabItem'; ### 1. Install the provider - - - ```bash npm i @openfeature/config-cat-web-provider ``` - - - -```html - -``` - - - ### 2. Initialize the provider The `ConfigCatWebProvider.create()` function takes the SDK key and an optional `options` argument containing additional configuration options for the [ConfigCat JavaScript SDK](../../js/#creating-the-configcat-client): ```js +import { OpenFeature } from "@openfeature/web-sdk"; import { ConfigCatWebProvider } from '@openfeature/config-cat-web-provider'; +import { createConsoleLogger, LogLevel } from "configcat-js-ssr"; // Build options for the ConfigCat SDK. -const options = { - setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), - // ... +const options = { + logger: createConsoleLogger(LogLevel.Info), + setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), + // ... } // Configure the provider. -OpenFeature.setProvider(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', options)); - +await OpenFeature.setProviderAndWait(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', options)); + // Create a client. const client = OpenFeature.getClient(); ``` @@ -58,13 +46,21 @@ For more information about all the configuration options, see the [JavaScript SD ```js const isAwesomeFeatureEnabled = client.getBooleanValue('isAwesomeFeatureEnabled', false); -if(isAwesomeFeatureEnabled) { - doTheNewThing(); +if (isAwesomeFeatureEnabled) { + doTheNewThing(); } else { - doTheOldThing(); + doTheOldThing(); } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.clearProviders(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -82,10 +78,10 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```js -await OpenFeature.setContext({ - targetingKey: '#SOME-USER-ID#', - email: 'configcat@example.com', - country: 'CountryID', +await OpenFeature.setContext({ + targetingKey: '#SOME-USER-ID#', + email: 'configcat@example.com', + country: 'CountryID', }); const isAwesomeFeatureEnabled = client.getBooleanValue('isAwesomeFeatureEnabled', false); diff --git a/website/versioned_docs/version-V1/sdk-reference/openfeature/node.mdx b/website/versioned_docs/version-V1/sdk-reference/openfeature/node.mdx index fec6ad45..a3f2aad1 100644 --- a/website/versioned_docs/version-V1/sdk-reference/openfeature/node.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/openfeature/node.mdx @@ -1,7 +1,7 @@ --- id: node title: OpenFeature Provider for Node.js -description: ConfigCat OpenFeature Provider for Node. This is a step-by-step guide on how to use ConfigCat with the OpenFeature Node.js SDK. +description: ConfigCat OpenFeature Provider for Node.js. This is a step-by-step guide on how to use ConfigCat with the OpenFeature Node.js SDK. --- import Tabs from '@theme/Tabs'; @@ -22,17 +22,20 @@ npm i @openfeature/config-cat-provider The `ConfigCatProvider.create()` function takes the SDK key and an optional `options` argument containing additional configuration options for the [ConfigCat Node.js SDK](../../node/#creating-the-configcat-client): ```js +import { OpenFeature } from "@openfeature/server-sdk"; import { ConfigCatProvider } from '@openfeature/config-cat-provider'; +import { createConsoleLogger, LogLevel, PollingMode } from "configcat-node"; // Build options for the ConfigCat SDK. -const options = { - setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), - // ... +const options = { + logger: createConsoleLogger(LogLevel.Info), + setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')), + // ... } // Configure the provider. -OpenFeature.setProvider(ConfigCatWebProvider.create('#YOUR-SDK-KEY#', PollingMode.AutoPoll, options)); - +await OpenFeature.setProviderAndWait(ConfigCatProvider.create('#YOUR-SDK-KEY#', PollingMode.AutoPoll, options)); + // Create a client. const client = OpenFeature.getClient(); ``` @@ -43,13 +46,21 @@ For more information about all the configuration options, see the [Node.js SDK d ```js const isAwesomeFeatureEnabled = await client.getBooleanValue('isAwesomeFeatureEnabled', false); -if(isAwesomeFeatureEnabled) { - doTheNewThing(); +if (isAwesomeFeatureEnabled) { + doTheNewThing(); } else { - doTheOldThing(); + doTheOldThing(); } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +await OpenFeature.clearProviders(); +``` + ## Evaluation Context An evaluation context in the OpenFeature specification is a container for arbitrary contextual data that can be used as a basis for feature flag evaluation. @@ -67,10 +78,10 @@ The following table shows how the different context attributes are mapped to Use To evaluate feature flags for a context, use the OpenFeature Evaluation API: ```js -const context = { - targetingKey: '#SOME-USER-ID#', - email: 'configcat@example.com', - country: 'CountryID', +const context = { + targetingKey: '#SOME-USER-ID#', + email: 'configcat@example.com', + country: 'CountryID', }; const isAwesomeFeatureEnabled = await client.getBooleanValue('isAwesomeFeatureEnabled', false, context); diff --git a/website/versioned_docs/version-V1/sdk-reference/overview.mdx b/website/versioned_docs/version-V1/sdk-reference/overview.mdx index c57c95d7..a4c5e8a4 100644 --- a/website/versioned_docs/version-V1/sdk-reference/overview.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/overview.mdx @@ -1,7 +1,7 @@ --- id: overview title: ConfigCat SDK Overview -description: List of all supported technologies like .NET, .NET Core, Java, JavaScript, PHP, Python, Ruby, Go, Node.js, Android, Swift, iOS, Elixir, Dart, React, Angular, Vue.js, React, Chromium, Deno, Kotlin Multiplatform, Laravel, Server-Side Rendered apps, etc. +description: List of all supported technologies like .NET, Java, JavaScript, PHP, Python, Ruby, Go, Node.js, Android, Swift, iOS, Elixir, Dart, React, Angular, Vue.js, React, Chromium, Deno, Kotlin Multiplatform, Laravel, Server-Side Rendered apps, etc. --- The purpose of the SDKs is to download and cache feature flag values and to evaluate Targeting Rules. All SDKs provide a simple interface for accessing your feature flags from your application.