Skip to content

Commit 7e1dd72

Browse files
adams85Adam SimonAdam Simon
authored
fix(config-cat): Revise readme (#1054)
Signed-off-by: Adam Simon <[email protected]> Signed-off-by: Adam Simon <[email protected]> Co-authored-by: Adam Simon <[email protected]> Co-authored-by: Adam Simon <[email protected]>
1 parent 29c3669 commit 7e1dd72

File tree

8 files changed

+87
-55
lines changed

8 files changed

+87
-55
lines changed

libs/providers/config-cat-web/README.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ConfigCat Web Provider
22

3-
This provider is an implementation for [ConfigCat](https://configcat.com) a managed feature flag service.
3+
This is an OpenFeature provider implementation for using [ConfigCat](https://configcat.com), a managed feature flag service in JavaScript frontend applications.
44

55
## Installation
66

@@ -14,10 +14,10 @@ The OpenFeature SDK is required as peer dependency.
1414

1515
The minimum required version of `@openfeature/web-sdk` currently is `1.0.0`.
1616

17-
The minimum required version of `configcat-js-ssr` currently is `8.4.1`.
17+
The minimum required version of `configcat-js-ssr` currently is `8.4.3`.
1818

1919
```
20-
$ npm install @openfeature/client-sdk configcat-js-ssr
20+
$ npm install @openfeature/web-sdk configcat-js-ssr
2121
```
2222

2323
## Usage
@@ -32,29 +32,45 @@ The ConfigCat Web Provider only supports the `AutoPolling` mode because it cache
3232
### Example using the default configuration
3333

3434
```javascript
35+
import { OpenFeature } from "@openfeature/web-sdk";
3536
import { ConfigCatWebProvider } from '@openfeature/config-cat-web-provider';
3637

38+
// Create and set the provider.
3739
const provider = ConfigCatWebProvider.create('<sdk_key>');
38-
OpenFeature.setProvider(provider);
40+
await OpenFeature.setProviderAndWait(provider);
41+
42+
// Create a client instance to evaluate feature flags.
43+
const client = OpenFeature.getClient();
44+
45+
const value = await client.getBooleanValue('isAwesomeFeatureEnabled', false);
46+
console.log(`isAwesomeFeatureEnabled: ${value}`);
47+
48+
// On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client.
49+
await OpenFeature.clearProviders();
3950
```
4051

41-
### Example using different polling options and a setupHook
52+
### Example using custom configuration
4253

4354
```javascript
55+
import { OpenFeature } from "@openfeature/web-sdk";
4456
import { ConfigCatWebProvider } from '@openfeature/config-cat-web-provider';
57+
import { createConsoleLogger, LogLevel } from 'configcat-js-ssr';
4558

59+
// Create and set the provider.
4660
const provider = ConfigCatWebProvider.create('<sdk_key>', {
61+
logger: createConsoleLogger(LogLevel.Info),
4762
setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')),
4863
});
64+
await OpenFeature.setProviderAndWait(provider);
4965

50-
OpenFeature.setProvider(provider);
66+
// ...
5167
```
5268

5369
## Evaluation Context
5470

55-
The OpenFeature Evaluation Context is mapped to the [ConfigCat user object](https://configcat.com/docs/advanced/user-object/).
71+
The OpenFeature Evaluation Context is mapped to the [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/).
5672

57-
The [ConfigCat user object](https://configcat.com/docs/advanced/user-object/) has three known attributes,
73+
The [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/) has three predefined attributes,
5874
and allows for additional attributes.
5975
The following shows how the attributes are mapped:
6076

libs/providers/config-cat-web/package-lock.json

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/providers/config-cat-web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
},
88
"peerDependencies": {
99
"@openfeature/web-sdk": "^1.0.0",
10-
"configcat-js-ssr": "^8.4.2"
10+
"configcat-js-ssr": "^8.4.3"
1111
}
1212
}

libs/providers/config-cat/README.md

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ConfigCat Provider
22

3-
This provider is an implementation for [ConfigCat](https://configcat.com) a managed feature flag service.
3+
This is an OpenFeature provider implementation for using [ConfigCat](https://configcat.com), a managed feature flag service in Node.js applications.
44

55
## Installation
66

@@ -14,7 +14,7 @@ The OpenFeature SDK is required as peer dependency.
1414

1515
The minimum required version of `@openfeature/server-sdk` currently is `1.13.5`.
1616

17-
The minimum required version of `configcat-node` currently is `11.0.0`.
17+
The minimum required version of `configcat-node` currently is `11.3.1`.
1818

1919
```
2020
$ npm install @openfeature/server-sdk configcat-node
@@ -31,29 +31,45 @@ The available options can be found in the [ConfigCat Node.js SDK](https://config
3131
### Example using the default configuration
3232

3333
```javascript
34+
import { OpenFeature } from "@openfeature/server-sdk";
3435
import { ConfigCatProvider } from '@openfeature/config-cat-provider';
3536

37+
// Create and set the provider.
3638
const provider = ConfigCatProvider.create('<sdk_key>');
37-
OpenFeature.setProvider(provider);
39+
await OpenFeature.setProviderAndWait(provider);
40+
41+
// Obtain a client instance and evaluate feature flags.
42+
const client = OpenFeature.getClient();
43+
44+
const value = await client.getBooleanValue('isAwesomeFeatureEnabled', false);
45+
console.log(`isAwesomeFeatureEnabled: ${value}`);
46+
47+
// On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client.
48+
await OpenFeature.clearProviders();
3849
```
3950

40-
### Example using different polling options and a setupHook
51+
### Example using a different polling mode and custom configuration
4152

4253
```javascript
54+
import { OpenFeature } from "@openfeature/server-sdk";
4355
import { ConfigCatProvider } from '@openfeature/config-cat-provider';
56+
import { createConsoleLogger, LogLevel, PollingMode } from 'configcat-node';
4457

58+
// Create and set the provider.
4559
const provider = ConfigCatProvider.create('<sdk_key>', PollingMode.LazyLoad, {
60+
logger: createConsoleLogger(LogLevel.Info),
4661
setupHooks: (hooks) => hooks.on('clientReady', () => console.log('Client is ready!')),
4762
});
63+
await OpenFeature.setProviderAndWait(provider);
4864

49-
OpenFeature.setProvider(provider);
65+
// ...
5066
```
5167

5268
## Evaluation Context
5369

54-
The OpenFeature Evaluation Context is mapped to the [ConfigCat user object](https://configcat.com/docs/advanced/user-object/).
70+
The OpenFeature Evaluation Context is mapped to the [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/).
5571

56-
The [ConfigCat user object](https://configcat.com/docs/advanced/user-object/) has three known attributes,
72+
The [ConfigCat User Object](https://configcat.com/docs/advanced/user-object/) has three predefined attributes,
5773
and allows for additional attributes.
5874
The following shows how the attributes are mapped:
5975

libs/providers/config-cat/package-lock.json

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/providers/config-cat/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
},
88
"peerDependencies": {
99
"@openfeature/server-sdk": "^1.13.5",
10-
"configcat-node": "^11.0.0"
10+
"configcat-node": "^11.3.1"
1111
}
1212
}

package-lock.json

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"@swc/helpers": "0.5.11",
2828
"ajv": "^8.12.0",
2929
"axios": "1.7.4",
30-
"configcat-js-ssr": "^8.3.0",
31-
"configcat-node": "^11.3.0",
30+
"configcat-js-ssr": "^8.4.3",
31+
"configcat-node": "^11.3.1",
3232
"copy-anything": "^3.0.5",
3333
"flagsmith": "^4.0.0",
3434
"imurmurhash": "^0.1.4",

0 commit comments

Comments
 (0)