Skip to content

Commit da2fe0a

Browse files
authored
feat: add ConfigCat to playground (#379)
## This PR - Adds ConfigCat's OpenFeature providers to the playground demo app. --------- Signed-off-by: Peter Csajtai <peter.csajtai@outlook.com>
1 parent 7f4f884 commit da2fe0a

12 files changed

+209
-4
lines changed

.env.example

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ FLAGSMITH_ENV_KEY=
2828
# Harness SDK Key
2929
HARNESS_KEY=
3030

31+
# ConfigCat SDK Key
32+
CONFIGCAT_SDK_KEY=
33+
3134
###############################################
3235
##
3336
## Feature Flag SDK keys (web)
@@ -59,4 +62,7 @@ FLAGD_PORT_WEB=
5962

6063
# Determines if TLS (https) should be used
6164
# @default false
62-
FLAGD_TLS_WEB=
65+
FLAGD_TLS_WEB=
66+
67+
# ConfigCat SDK Key
68+
CONFIGCAT_SDK_KEY_WEB=

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ If you're brand new to feature flagging, consider reviewing the [What are featur
2929
- [LaunchDarkly](#launchdarkly)
3030
- [Flagsmith](#flagsmith)
3131
- [Flipt](#flipt)
32+
- [ConfigCat](#configcat)
3233
- [Experimenting beyond the demo](#experimenting-beyond-the-demo)
3334
- [Evaluation context](#evaluation-context)
3435
- [Troubleshooting](#troubleshooting)
@@ -428,6 +429,38 @@ It's easy to set up, has no seat limits, and is built for developers from scale-
428429

429430
After [starting the demo](#how-to-run-the-demo), the Flipt UI is available at [http://localhost:8080](http://localhost:8080).
430431

432+
### ConfigCat
433+
434+
[ConfigCat](https://configcat.com/) is a user-friendly, scalable and secure feature flagging solution with clear [pricing](https://configcat.com/#pricing). ConfigCat allows for unlimited team members and MAUs across all plans, including the free tier. All ConfigCat plans come with all security measures, including audit logs, two-factor authentication, SSO, SAML and SCIM for secure feature management. ConfigCat offers users the choice to keep data within the EU to comply with GDPR more easily. ConfigCat provides SDKs for all major programming languages and platforms.
435+
436+
<details>
437+
<summary>Follow these steps to set up ConfigCat for the demo:</summary>
438+
439+
1. Sign in to your ConfigCat account. If you don't already have an account, you can [sign up](https://app.configcat.com/auth/signup) for free.
440+
1. Create a new feature flag with the key `new-welcome-message`.
441+
442+
<img src="./images/configcat/new-welcome-message.png">
443+
444+
1. Create a new text setting with the key `hex-color`. Add three percentage options (`+ %` button) with the following values: `c05543`, `2f5230`, and `0d507b`. Set `c05543` to 100%. Set the `To unindentified` value to `c05543`.
445+
446+
<img src="./images/configcat/hex-color.png">
447+
448+
1. Create a new text setting with the key `fib-algo`.
449+
- Add a targeting rule (`+ IF` button) that looks for the `Email` user attribute to end with `@faas.com` and serves `binet`.
450+
- Add five percentage options (`+ %` button) with the following values: `recursive`, `memo`, `loop`, `binet`, and `default`. Set `recursive` to 100%.
451+
- Set the `To unindentified` value to `default`.
452+
453+
<img src="./images/configcat/fib-algo.png">
454+
455+
1. Click on `VIEW SDK KEY` and copy the `SDK Key`.
456+
457+
<img src="./images/configcat/sdk-key.png">
458+
459+
1. Open the `.env` file and set the values of `CONFIGCAT_SDK_KEY` and `CONFIGCAT_SDK_KEY_WEB` to the key copied above.
460+
461+
Now that everything is configured, you should be able to [start the demo](#how-to-run-the-demo). Once it's started, select `configcat` from the provider list located at the bottom right of your screen. You should now be able to control the demo app via ConfigCat!
462+
</details>
463+
431464
## Experimenting beyond the demo
432465

433466
### Evaluation context

docker-compose.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
- LD_KEY
3939
- FLAGSMITH_ENV_KEY
4040
- CLOUDBEES_APP_KEY
41+
- CONFIGCAT_SDK_KEY
4142
## Web
4243
- HARNESS_KEY_WEB
4344
- SPLIT_KEY_WEB
@@ -46,7 +47,8 @@ services:
4647
- CLOUDBEES_APP_KEY_WEB
4748
- FLAGD_HOST_WEB
4849
- FLAGD_PORT_WEB
49-
- FLAGD_TLS_WEB
50+
- FLAGD_TLS_WEB
51+
- CONFIGCAT_SDK_KEY_WEB
5052

5153
fib-service:
5254
image: ghcr.io/open-feature/playground-fib-service:v0.16.0 # x-release-please-version
@@ -74,6 +76,7 @@ services:
7476
- LD_KEY
7577
- FLAGSMITH_ENV_KEY
7678
- CLOUDBEES_APP_KEY
79+
- CONFIGCAT_SDK_KEY
7780

7881
jaeger:
7982
image: jaegertracing/all-in-one:1.60

images/configcat/fib-algo.png

63.5 KB
Loading

images/configcat/hex-color.png

39.1 KB
Loading
32.8 KB
Loading

images/configcat/sdk-key.png

48.9 KB
Loading

package-lock.json

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

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"@nestjs/core": "10.4.1",
2424
"@nestjs/platform-express": "10.4.1",
2525
"@nestjs/serve-static": "^4.0.2",
26+
"@openfeature/config-cat-web-provider": "^0.1.3",
27+
"@openfeature/config-cat-provider": "^0.7.2",
2628
"@openfeature/env-var-provider": "^0.3.0",
2729
"@openfeature/flagd-provider": "^0.13.0",
2830
"@openfeature/flagd-web-provider": "^0.7.0",
@@ -142,6 +144,9 @@
142144
"overrides": {
143145
"braces": ">=3.0.3",
144146
"ws": ">=8.17.1",
145-
"@grpc/grpc-js": ">=1.10.9"
147+
"@grpc/grpc-js": ">=1.10.9",
148+
"@openfeature/config-cat-provider": {
149+
"@openfeature/server-sdk": "1.13.4"
150+
}
146151
}
147152
}

packages/provider/src/lib/provider.service.ts

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { OpenFeatureLogger } from '@openfeature/extra';
1515
import {
1616
AvailableProvider,
1717
CB_PROVIDER_ID,
18+
CONFIGCAT_PROVIDER_ID,
1819
ENV_PROVIDER_ID,
1920
FLAGD_OFREP_PROVIDER_ID,
2021
FLAGD_PROVIDER_ID,
@@ -28,6 +29,8 @@ import {
2829
} from '@openfeature/utils';
2930
import { OFREPProvider } from '@openfeature/ofrep-provider';
3031
import { FliptProvider } from '@openfeature/flipt-provider';
32+
import { ConfigCatProvider } from '@openfeature/config-cat-provider';
33+
import { PollingMode } from 'configcat-node';
3134

3235
type ProviderMap = Record<
3336
ProviderId,
@@ -171,6 +174,18 @@ export class ProviderService {
171174
available: () => !!process.env.FLIPT_URL,
172175
url: process.env.FLIPT_WEB_URL,
173176
},
177+
[CONFIGCAT_PROVIDER_ID]: {
178+
factory: () => {
179+
const sdkKey = process.env.CONFIGCAT_SDK_KEY;
180+
if (!sdkKey) {
181+
throw new Error('"CONFIGCAT_SDK_KEY" must be defined.');
182+
} else {
183+
return ConfigCatProvider.create(sdkKey, PollingMode.AutoPoll, { pollIntervalSeconds: 5 });
184+
}
185+
},
186+
available: () => !!process.env.CONFIGCAT_SDK_KEY && !!process.env.CONFIGCAT_SDK_KEY_WEB,
187+
webCredential: process.env.CONFIGCAT_SDK_KEY_WEB,
188+
},
174189
};
175190

176191
constructor() {

packages/ui/src/app/demos.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FlagdWebProvider } from '@openfeature/flagd-web-provider';
33
import {
44
AvailableProvider,
55
CB_PROVIDER_ID,
6+
CONFIGCAT_PROVIDER_ID,
67
FLAGD_OFREP_PROVIDER_ID,
78
FLAGD_PROVIDER_ID,
89
FLAGSMITH_PROVIDER_ID,
@@ -35,6 +36,7 @@ import { JSON_UPDATED } from './types';
3536
import { getData } from './utils';
3637
import { GoFeatureFlagWebProvider } from '@openfeature/go-feature-flag-web-provider';
3738
import { FliptWebProvider } from '@openfeature/flipt-web-provider';
39+
import { ConfigCatWebProvider } from '@openfeature/config-cat-web-provider';
3840

3941
type ProviderMap = Record<
4042
string,
@@ -138,6 +140,11 @@ export class Demos extends Component<
138140
return new FliptWebProvider('default', { url: fliptConfig?.url });
139141
},
140142
},
143+
[CONFIGCAT_PROVIDER_ID]: {
144+
factory: () => {
145+
return ConfigCatWebProvider.create(this.getProviderCredential(CONFIGCAT_PROVIDER_ID), { pollIntervalSeconds: 5 });
146+
},
147+
},
141148
};
142149

143150
constructor(props: Record<string, never>) {

packages/utils/src/lib/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const CB_PROVIDER_ID = 'cloudbees';
99
export const FLAGSMITH_PROVIDER_ID = 'flagsmith';
1010
export const HARNESS_PROVIDER_ID = 'harness';
1111
export const FLIPT_PROVIDER_ID = 'flipt';
12+
export const CONFIGCAT_PROVIDER_ID = 'configcat';
1213

1314
export type ProviderId =
1415
| typeof ENV_PROVIDER_ID
@@ -21,7 +22,8 @@ export type ProviderId =
2122
| typeof CB_PROVIDER_ID
2223
| typeof FLAGSMITH_PROVIDER_ID
2324
| typeof HARNESS_PROVIDER_ID
24-
| typeof FLIPT_PROVIDER_ID;
25+
| typeof FLIPT_PROVIDER_ID
26+
| typeof CONFIGCAT_PROVIDER_ID;
2527

2628
export interface AvailableProvider {
2729
id: ProviderId;

0 commit comments

Comments
 (0)