From fd8076301a32cbe3d566754bea769a1c455e0935 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Wed, 26 Feb 2025 12:51:56 +0100 Subject: [PATCH 1/5] getting started with remote configs --- packages/react-sdk/README.md | 39 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/react-sdk/README.md b/packages/react-sdk/README.md index 3dda0a89..51bb0ce5 100644 --- a/packages/react-sdk/README.md +++ b/packages/react-sdk/README.md @@ -29,10 +29,6 @@ declare module "@bucketco/react-sdk" { interface Features { huddle: boolean; recordVideo: boolean; - questionnaire?: { - showAll: boolean; - time: 600000; - }; } } ``` @@ -58,7 +54,7 @@ import { BucketProvider } from "@bucketco/react-sdk"; ### 3. Use `useFeature()` to get feature status -Using the `useFeature` hook from your components lets you toggle features on/off and configure features through Remote Config: +Using the `useFeature` hook from your components lets you toggle features on/off and send track when users actually use your features: **Example:** @@ -79,13 +75,13 @@ function StartHuddleButton() { `useFeature` can help you do much more. See a full example for `useFeature` [see below](#usefeature). -## Feature toggles +## Setting `user` and `company` -Bucket determines which features are active for a given `user`/`company`. The `user`/`company` are given in the `BucketProvider` as props. +Bucket determines which features are active for a given `user`/`company` / `otherContext`. You pass these to the `BucketProvider` as props. If you supply `user` or `company` objects, they must include at least the `id` property otherwise they will be ignored in their entirety. In addition to the `id`, you must also supply anything additional that you want to be able to evaluate feature targeting rules against. -The additional attributes are supplied using the `otherContext` prop. +Attributes which are not properties of the `user` or `company` can be supplied using the `otherContext` prop. Attributes cannot be nested (multiple levels) and must be either strings, numbers or booleans. A number of special attributes exist: @@ -114,10 +110,31 @@ generates a `check` event. ## Remote config -Similar to `isEnabled`, each feature accessed using `useFeature()` hook, has a `config` property. This configuration -is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the +In addition to just turning features on/off, Bucket supports remotely configuring features through Remote config. + +Similar to `isEnabled`, each feature accessed using `useFeature()` hook, has a `config` property. This configuration is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the binary `isEnabled` you can have multiple configuration values which are given to different user/companies. +### Get started with Remote config + +1. Update your feature definitions: + +```typescript +import "@bucketco/react-sdk"; + +// Define your features by extending the `Features` interface in @bucketco/react-sdk +declare module "@bucketco/react-sdk" { + interface Features { + huddle: { + // change from `boolean` to an object which sets + // a type for the remote config for `questionnaire` + maxTokens: number; + model: string; + }; + } +} +``` + ```ts const { isEnabled, @@ -130,7 +147,7 @@ const { ``` The `key` is always present while the `payload` is a optional JSON value for arbitrary configuration needs. -If feature has no configuration or, no configuration value was matched against the context, the `config` object +If tjhe feature has no configuration or, no configuration value was matched against the context, the `config` object will be empty, thus, `key` will be `undefined`. Make sure to check against this case when trying to use the configuration in your application. From d189dd2cfca6c894e02f9ee64f59c248c48d946c Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Wed, 26 Feb 2025 12:57:45 +0100 Subject: [PATCH 2/5] intro --- packages/react-sdk/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-sdk/README.md b/packages/react-sdk/README.md index 51bb0ce5..fc08f8ac 100644 --- a/packages/react-sdk/README.md +++ b/packages/react-sdk/README.md @@ -2,6 +2,8 @@ React client side library for [Bucket.co](https://bucket.co) +Bucket supports toggling features, tracking feature usage, [requesting feedback](#userequestfeedback) on features and [remotely configuring features](#remote-config). + ## Install Install via npm: @@ -147,7 +149,7 @@ const { ``` The `key` is always present while the `payload` is a optional JSON value for arbitrary configuration needs. -If tjhe feature has no configuration or, no configuration value was matched against the context, the `config` object +If the feature has no configuration or, no configuration value was matched against the context, the `config` object will be empty, thus, `key` will be `undefined`. Make sure to check against this case when trying to use the configuration in your application. From c9b9c2c0ab19193a8dcf3d6b4c07ba4dbb9b7d3a Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Wed, 26 Feb 2025 13:06:10 +0100 Subject: [PATCH 3/5] more docs updates --- packages/browser-sdk/README.md | 2 ++ packages/node-sdk/README.md | 4 +++- packages/react-sdk/README.md | 15 ++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/browser-sdk/README.md b/packages/browser-sdk/README.md index 82356416..dc16050e 100644 --- a/packages/browser-sdk/README.md +++ b/packages/browser-sdk/README.md @@ -2,6 +2,8 @@ Basic client for Bucket.co. If you're using React, you'll be better off with the Bucket React SDK. +Bucket supports feature toggling, tracking feature usage, [collecting feedback](#qualitative-feedback) on features, and [remotely configuring features](#remote-config). + ## Install First find your `publishableKey` under [environment settings](https://app.bucket.co/envs/current/settings/app-environments) in Bucket. diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 263fbbde..563143c2 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -1,6 +1,8 @@ # Bucket Node.js SDK -Node.js, JavaScriptS/Typescript feature flag and tracking client for [Bucket.co](https://bucket.co). +Node.js, JavaScriptS/Typescript client for [Bucket.co](https://bucket.co). + +Bucket supports feature toggling, tracking feature usage, collecting feedback on features, and [remotely configuring features](#remote-config). ## Installation diff --git a/packages/react-sdk/README.md b/packages/react-sdk/README.md index fc08f8ac..4cd4a18f 100644 --- a/packages/react-sdk/README.md +++ b/packages/react-sdk/README.md @@ -2,7 +2,7 @@ React client side library for [Bucket.co](https://bucket.co) -Bucket supports toggling features, tracking feature usage, [requesting feedback](#userequestfeedback) on features and [remotely configuring features](#remote-config). +Bucket supports feature toggling, tracking feature usage, [requesting feedback](#userequestfeedback) on features, and [remotely configuring features](#remote-config). ## Install @@ -56,7 +56,7 @@ import { BucketProvider } from "@bucketco/react-sdk"; ### 3. Use `useFeature()` to get feature status -Using the `useFeature` hook from your components lets you toggle features on/off and send track when users actually use your features: +Using the `useFeature` hook from your components lets you toggle features on/off and track feature usage: **Example:** @@ -79,7 +79,8 @@ function StartHuddleButton() { ## Setting `user` and `company` -Bucket determines which features are active for a given `user`/`company` / `otherContext`. You pass these to the `BucketProvider` as props. +Bucket determines which features are active for a given `user`, `company`, or `otherContext`. +You pass these to the `BucketProvider` as props. If you supply `user` or `company` objects, they must include at least the `id` property otherwise they will be ignored in their entirety. In addition to the `id`, you must also supply anything additional that you want to be able to evaluate feature targeting rules against. @@ -112,9 +113,9 @@ generates a `check` event. ## Remote config -In addition to just turning features on/off, Bucket supports remotely configuring features through Remote config. +In addition to toggling features on/off, Bucket supports remote configuration of features through Remote config. -Similar to `isEnabled`, each feature accessed using `useFeature()` hook, has a `config` property. This configuration is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the +Similar to `isEnabled`, each feature accessed using the `useFeature()` hook, has a `config` property. This configuration is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the binary `isEnabled` you can have multiple configuration values which are given to different user/companies. ### Get started with Remote config @@ -149,8 +150,8 @@ const { ``` The `key` is always present while the `payload` is a optional JSON value for arbitrary configuration needs. -If the feature has no configuration or, no configuration value was matched against the context, the `config` object -will be empty, thus, `key` will be `undefined`. Make sure to check against this case when trying to use the +If a feature has no configuration or no configuration value was matched against the context, the config object will be empty. +Thus, `key` will be `undefined`. Make sure to check against this case when trying to use the configuration in your application. Note that, similar to `isEnabled`, accessing `config` on the object returned by `useFeature()` automatically From 7b5dd3e9051330a7d42c62a9084276fc521d4fb8 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Wed, 26 Feb 2025 13:07:35 +0100 Subject: [PATCH 4/5] remote config is beta --- packages/browser-sdk/README.md | 2 +- packages/node-sdk/README.md | 2 +- packages/react-sdk/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/browser-sdk/README.md b/packages/browser-sdk/README.md index dc16050e..e6718ae6 100644 --- a/packages/browser-sdk/README.md +++ b/packages/browser-sdk/README.md @@ -194,7 +194,7 @@ const override = bucketClient.getFeatureOverride("huddle"); // returns boolean | Feature overrides are persisted in `localStorage` and will be restored when the page is reloaded. -### Remote config +### Remote config (beta) Similar to `isEnabled`, each feature has a `config` property. This configuration is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the binary `isEnabled` you can have diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 563143c2..33d7e4d9 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -226,7 +226,7 @@ const client = new BucketClient({ }); ``` -### Remote config +### Remote config (beta) Similar to `isEnabled`, each feature has a `config` property. This configuration is managed from within Bucket. It is managed similar to the way access to features is managed, but instead of the binary `isEnabled` you can have diff --git a/packages/react-sdk/README.md b/packages/react-sdk/README.md index 4cd4a18f..67b3327b 100644 --- a/packages/react-sdk/README.md +++ b/packages/react-sdk/README.md @@ -111,7 +111,7 @@ To retrieve features along with their targeting information, use `useFeature(key Note that accessing `isEnabled` on the object returned by `useFeature()` automatically generates a `check` event. -## Remote config +## Remote config (beta) In addition to toggling features on/off, Bucket supports remote configuration of features through Remote config. From 5ae18a76c59c8956844525ac5b47d0d540eac116 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Wed, 26 Feb 2025 13:38:10 +0100 Subject: [PATCH 5/5] fix links --- packages/browser-sdk/README.md | 2 +- packages/node-sdk/README.md | 2 +- packages/react-sdk/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/browser-sdk/README.md b/packages/browser-sdk/README.md index e6718ae6..e47f783a 100644 --- a/packages/browser-sdk/README.md +++ b/packages/browser-sdk/README.md @@ -2,7 +2,7 @@ Basic client for Bucket.co. If you're using React, you'll be better off with the Bucket React SDK. -Bucket supports feature toggling, tracking feature usage, [collecting feedback](#qualitative-feedback) on features, and [remotely configuring features](#remote-config). +Bucket supports feature toggling, tracking feature usage, [collecting feedback](#qualitative-feedback) on features, and [remotely configuring features](#remote-config-beta). ## Install diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 33d7e4d9..8b5089bc 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -2,7 +2,7 @@ Node.js, JavaScriptS/Typescript client for [Bucket.co](https://bucket.co). -Bucket supports feature toggling, tracking feature usage, collecting feedback on features, and [remotely configuring features](#remote-config). +Bucket supports feature toggling, tracking feature usage, collecting feedback on features, and [remotely configuring features](#remote-config-beta). ## Installation diff --git a/packages/react-sdk/README.md b/packages/react-sdk/README.md index 67b3327b..17ce6da8 100644 --- a/packages/react-sdk/README.md +++ b/packages/react-sdk/README.md @@ -2,7 +2,7 @@ React client side library for [Bucket.co](https://bucket.co) -Bucket supports feature toggling, tracking feature usage, [requesting feedback](#userequestfeedback) on features, and [remotely configuring features](#remote-config). +Bucket supports feature toggling, tracking feature usage, [requesting feedback](#userequestfeedback) on features, and [remotely configuring features](#remote-config-beta). ## Install