Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config-cat): Revise readme #1054

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions libs/providers/config-cat-web/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ConfigCat Web Provider

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

## Installation

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

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

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

```
$ npm install @openfeature/client-sdk configcat-js-ssr
$ npm install @openfeature/web-sdk configcat-js-ssr
```

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

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

// Create and set the provider.
const provider = ConfigCatWebProvider.create('<sdk_key>');
OpenFeature.setProvider(provider);
await OpenFeature.setProviderAndWait(provider);

// Create a client instance to evaluate feature flags.
const client = OpenFeature.getClient();

const value = await client.getBooleanValue('isAwesomeFeatureEnabled', false);
console.log(`isAwesomeFeatureEnabled: ${value}`);

// On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client.
await OpenFeature.clearProviders();
```

### Example using different polling options and a setupHook
### Example using custom configuration

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

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

OpenFeature.setProvider(provider);
// ...
```

## Evaluation Context

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

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

Expand Down
22 changes: 11 additions & 11 deletions libs/providers/config-cat-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/providers/config-cat-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},
"peerDependencies": {
"@openfeature/web-sdk": "^1.0.0",
"configcat-js-ssr": "^8.4.2"
"configcat-js-ssr": "^8.4.3"
}
}
30 changes: 23 additions & 7 deletions libs/providers/config-cat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ConfigCat Provider

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

## Installation

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

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

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

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

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

// Create and set the provider.
const provider = ConfigCatProvider.create('<sdk_key>');
OpenFeature.setProvider(provider);
await OpenFeature.setProviderAndWait(provider);

// Obtain a client instance and evaluate feature flags.
const client = OpenFeature.getClient();

const value = await client.getBooleanValue('isAwesomeFeatureEnabled', false);
console.log(`isAwesomeFeatureEnabled: ${value}`);

// On application shutdown, clean up the OpenFeature provider and the underlying ConfigCat client.
await OpenFeature.clearProviders();
```

### Example using different polling options and a setupHook
### Example using a different polling mode and custom configuration

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

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

OpenFeature.setProvider(provider);
// ...
```

## Evaluation Context

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

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

Expand Down
22 changes: 11 additions & 11 deletions libs/providers/config-cat/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/providers/config-cat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
},
"peerDependencies": {
"@openfeature/server-sdk": "^1.13.5",
"configcat-node": "^11.0.0"
"configcat-node": "^11.3.1"
}
}
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@swc/helpers": "0.5.11",
"ajv": "^8.12.0",
"axios": "1.7.4",
"configcat-js-ssr": "^8.3.0",
"configcat-node": "^11.3.0",
"configcat-js-ssr": "^8.4.3",
"configcat-node": "^11.3.1",
"copy-anything": "^3.0.5",
"flagsmith": "^4.0.0",
"imurmurhash": "^0.1.4",
Expand Down
Loading