diff --git a/website/docs/sdk-reference/android.mdx b/website/docs/sdk-reference/android.mdx index 9ad4bd24..e3291596 100644 --- a/website/docs/sdk-reference/android.mdx +++ b/website/docs/sdk-reference/android.mdx @@ -55,7 +55,7 @@ ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#"); ```java boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "", false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -64,7 +64,7 @@ if(isMyAwesomeFeatureEnabled) { // Or asynchronously client.getValueAsync(Boolean.class, "", false) .thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -176,7 +176,7 @@ client.getValueAsync( User.newBuilder().build("#UNIQUE-USER-IDENTIFIER#"), // Optional User Object false // Default value ).thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/docs/sdk-reference/dart.mdx b/website/docs/sdk-reference/dart.mdx index 21293d31..cfe0a9e7 100644 --- a/website/docs/sdk-reference/dart.mdx +++ b/website/docs/sdk-reference/dart.mdx @@ -74,7 +74,7 @@ final client = ConfigCatClient.get( ```dart final isMyAwesomeFeatureEnabled = await client.getValue(key: 'isMyAwesomeFeatureEnabled', defaultValue: false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/docs/sdk-reference/dotnet.mdx b/website/docs/sdk-reference/dotnet.mdx index b545f062..24da989b 100644 --- a/website/docs/sdk-reference/dotnet.mdx +++ b/website/docs/sdk-reference/dotnet.mdx @@ -55,7 +55,7 @@ var client = ConfigCatClient.Get("#YOUR-SDK-KEY#"); ```csharp var isMyAwesomeFeatureEnabled = await client.GetValueAsync("isMyAwesomeFeatureEnabled", false); -if(isMyAwesomeFeatureEnabled) +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } diff --git a/website/docs/sdk-reference/java.mdx b/website/docs/sdk-reference/java.mdx index 2c370c4c..0afdc7f9 100644 --- a/website/docs/sdk-reference/java.mdx +++ b/website/docs/sdk-reference/java.mdx @@ -62,7 +62,7 @@ ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#"); ```java boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "isMyAwesomeFeatureEnabled", false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -183,7 +183,7 @@ client.getValueAsync( User.newBuilder().build("#UNIQUE-USER-IDENTIFIER#"), // Optional User Object false // Default value ).thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/docs/sdk-reference/openfeature/java.mdx b/website/docs/sdk-reference/openfeature/java.mdx index e6f818c1..5090269d 100644 --- a/website/docs/sdk-reference/openfeature/java.mdx +++ b/website/docs/sdk-reference/openfeature/java.mdx @@ -19,6 +19,7 @@ import TabItem from '@theme/TabItem'; ```groovy title="build.gradle" dependencies { implementation 'dev.openfeature.contrib.providers:configcat:0.0.4' + implementation 'dev.openfeature:sdk:1.+' } ``` @@ -27,9 +28,14 @@ dependencies { ```xml title="pom.xml" - dev.openfeature.contrib.providers - configcat - 0.0.4 + dev.openfeature.contrib.providers + configcat + 0.0.4 + + + dev.openfeature + sdk + [1.0,) ``` @@ -42,10 +48,13 @@ The `ConfigCatProvider` constructor takes a `ConfigCatProviderConfig` argument c ```java // Build options for the ConfigCat SDK. ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder() - .sdkKey("#YOUR-SDK-KEY#") - .pollingMode(PollingModes.autoPoll()) - .logLevel(LogLevel.WARNING) - .build(); + .sdkKey("#YOUR-SDK-KEY#") + .options(options -> { + options.pollingMode(PollingModes.autoPoll()); + options.logLevel(LogLevel.WARNING); + // ... + }) + .build(); // Configure the provider. OpenFeatureAPI.getInstance().setProviderAndWait(new ConfigCatProvider(configCatProviderConfig)); @@ -60,7 +69,7 @@ For more information about all the configuration options, see the [Java SDK docu ```java boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false); -if(isAwesomeFeatureEnabled) +if (isAwesomeFeatureEnabled) { doTheNewThing(); } @@ -70,6 +79,14 @@ else } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +OpenFeatureAPI.getInstance().shutdown(); +``` + ## 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. @@ -87,11 +104,11 @@ 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: ```java -MutableContext evaluationContext = new MutableContext(); -evaluationContext.setTargetingKey("#SOME-USER-ID#"); -evaluationContext.add("Email", "configcat@example.com"); -evaluationContext.add("Country", "CountryID"); -evaluationContext.add("Rating", 4.5); +MutableContext context = new MutableContext(); +context.setTargetingKey("#SOME-USER-ID#"); +context.add("Email", "configcat@example.com"); +context.add("Country", "CountryID"); +context.add("Rating", 4.5); boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false, context); ``` diff --git a/website/docs/sdk-reference/openfeature/php.mdx b/website/docs/sdk-reference/openfeature/php.mdx index 994bd9ba..280a9318 100644 --- a/website/docs/sdk-reference/openfeature/php.mdx +++ b/website/docs/sdk-reference/openfeature/php.mdx @@ -56,7 +56,7 @@ For more information about all the configuration options, see the [PHP SDK docum ```php $isAwesomeFeatureEnabled = $client->getBooleanValue('isAwesomeFeatureEnabled', false); -if(is_bool($isAwesomeFeatureEnabled) && $isAwesomeFeatureEnabled) { +if (is_bool($isAwesomeFeatureEnabled) && $isAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/docs/sdk-reference/php.mdx b/website/docs/sdk-reference/php.mdx index 6c99e084..f9b39363 100644 --- a/website/docs/sdk-reference/php.mdx +++ b/website/docs/sdk-reference/php.mdx @@ -35,7 +35,7 @@ $client = new \ConfigCat\ConfigCatClient("#YOUR-SDK-KEY#"); ```php $isMyAwesomeFeatureEnabled = $client->getValue("isMyAwesomeFeatureEnabled", false); -if(is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) { +if (is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/versioned_docs/version-V1/sdk-reference/android.mdx b/website/versioned_docs/version-V1/sdk-reference/android.mdx index eab92f94..9e3f1594 100644 --- a/website/versioned_docs/version-V1/sdk-reference/android.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/android.mdx @@ -61,7 +61,7 @@ ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#"); ```java boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "", false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -70,7 +70,7 @@ if(isMyAwesomeFeatureEnabled) { // Or asynchronously client.getValueAsync(Boolean.class, "", false) .thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -182,7 +182,7 @@ client.getValueAsync( User.newBuilder().build("#UNIQUE-USER-IDENTIFIER#"), // Optional User Object false // Default value ).thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/versioned_docs/version-V1/sdk-reference/dart.mdx b/website/versioned_docs/version-V1/sdk-reference/dart.mdx index c95ebf44..7b39fd51 100644 --- a/website/versioned_docs/version-V1/sdk-reference/dart.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/dart.mdx @@ -80,7 +80,7 @@ final client = ConfigCatClient.get( ```dart final isMyAwesomeFeatureEnabled = await client.getValue(key: 'isMyAwesomeFeatureEnabled', defaultValue: false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx b/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx index 653b795f..6cf69261 100644 --- a/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/dotnet.mdx @@ -61,7 +61,7 @@ var client = ConfigCatClient.Get("#YOUR-SDK-KEY#"); ```csharp var isMyAwesomeFeatureEnabled = client.GetValue("isMyAwesomeFeatureEnabled", false); -if(isMyAwesomeFeatureEnabled) +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } diff --git a/website/versioned_docs/version-V1/sdk-reference/java.mdx b/website/versioned_docs/version-V1/sdk-reference/java.mdx index 2f2171df..f76b53d8 100644 --- a/website/versioned_docs/version-V1/sdk-reference/java.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/java.mdx @@ -68,7 +68,7 @@ ConfigCatClient client = ConfigCatClient.get("#YOUR-SDK-KEY#"); ```java boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "isMyAwesomeFeatureEnabled", false); -if(isMyAwesomeFeatureEnabled) { +if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); @@ -188,7 +188,7 @@ client.getValueAsync( User.newBuilder().build("#UNIQUE-USER-IDENTIFIER#"), // Optional User Object false // Default value ).thenAccept(isMyAwesomeFeatureEnabled -> { - if(isMyAwesomeFeatureEnabled) { + if (isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/versioned_docs/version-V1/sdk-reference/openfeature/java.mdx b/website/versioned_docs/version-V1/sdk-reference/openfeature/java.mdx index e6f818c1..5090269d 100644 --- a/website/versioned_docs/version-V1/sdk-reference/openfeature/java.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/openfeature/java.mdx @@ -19,6 +19,7 @@ import TabItem from '@theme/TabItem'; ```groovy title="build.gradle" dependencies { implementation 'dev.openfeature.contrib.providers:configcat:0.0.4' + implementation 'dev.openfeature:sdk:1.+' } ``` @@ -27,9 +28,14 @@ dependencies { ```xml title="pom.xml" - dev.openfeature.contrib.providers - configcat - 0.0.4 + dev.openfeature.contrib.providers + configcat + 0.0.4 + + + dev.openfeature + sdk + [1.0,) ``` @@ -42,10 +48,13 @@ The `ConfigCatProvider` constructor takes a `ConfigCatProviderConfig` argument c ```java // Build options for the ConfigCat SDK. ConfigCatProviderConfig configCatProviderConfig = ConfigCatProviderConfig.builder() - .sdkKey("#YOUR-SDK-KEY#") - .pollingMode(PollingModes.autoPoll()) - .logLevel(LogLevel.WARNING) - .build(); + .sdkKey("#YOUR-SDK-KEY#") + .options(options -> { + options.pollingMode(PollingModes.autoPoll()); + options.logLevel(LogLevel.WARNING); + // ... + }) + .build(); // Configure the provider. OpenFeatureAPI.getInstance().setProviderAndWait(new ConfigCatProvider(configCatProviderConfig)); @@ -60,7 +69,7 @@ For more information about all the configuration options, see the [Java SDK docu ```java boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false); -if(isAwesomeFeatureEnabled) +if (isAwesomeFeatureEnabled) { doTheNewThing(); } @@ -70,6 +79,14 @@ else } ``` +### 4. Cleaning up + +On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client. + +```cs +OpenFeatureAPI.getInstance().shutdown(); +``` + ## 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. @@ -87,11 +104,11 @@ 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: ```java -MutableContext evaluationContext = new MutableContext(); -evaluationContext.setTargetingKey("#SOME-USER-ID#"); -evaluationContext.add("Email", "configcat@example.com"); -evaluationContext.add("Country", "CountryID"); -evaluationContext.add("Rating", 4.5); +MutableContext context = new MutableContext(); +context.setTargetingKey("#SOME-USER-ID#"); +context.add("Email", "configcat@example.com"); +context.add("Country", "CountryID"); +context.add("Rating", 4.5); boolean isAwesomeFeatureEnabled = client.getBooleanValue("isAwesomeFeatureEnabled", false, context); ``` diff --git a/website/versioned_docs/version-V1/sdk-reference/openfeature/php.mdx b/website/versioned_docs/version-V1/sdk-reference/openfeature/php.mdx index 994bd9ba..280a9318 100644 --- a/website/versioned_docs/version-V1/sdk-reference/openfeature/php.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/openfeature/php.mdx @@ -56,7 +56,7 @@ For more information about all the configuration options, see the [PHP SDK docum ```php $isAwesomeFeatureEnabled = $client->getBooleanValue('isAwesomeFeatureEnabled', false); -if(is_bool($isAwesomeFeatureEnabled) && $isAwesomeFeatureEnabled) { +if (is_bool($isAwesomeFeatureEnabled) && $isAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); diff --git a/website/versioned_docs/version-V1/sdk-reference/php.mdx b/website/versioned_docs/version-V1/sdk-reference/php.mdx index 296fdf98..35966d67 100644 --- a/website/versioned_docs/version-V1/sdk-reference/php.mdx +++ b/website/versioned_docs/version-V1/sdk-reference/php.mdx @@ -41,7 +41,7 @@ $client = new \ConfigCat\ConfigCatClient("#YOUR-SDK-KEY#"); ```php $isMyAwesomeFeatureEnabled = $client->getValue("isMyAwesomeFeatureEnabled", false); -if(is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) { +if (is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing();