Skip to content

Commit d653f2c

Browse files
authored
docs(browser-sdk): make feature overrides internal for now (#342)
We'll be moving exposing feature overrides through what is returned from the `getFeature()` call rather than exposing it directly on the client.
1 parent 42c79e7 commit d653f2c

3 files changed

Lines changed: 11 additions & 22 deletions

File tree

packages/browser-sdk/README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,6 @@ by down-stream clients, like the React SDK.
174174
Note that accessing `isEnabled` on the object returned by `getFeatures` does not automatically
175175
generate a `check` event, contrary to the `isEnabled` property on the object returned by `getFeature`.
176176

177-
### Feature Overrides
178-
179-
You can override feature flags locally for testing purposes using `setFeatureOverride`:
180-
181-
```ts
182-
// Override a feature to be enabled
183-
bucketClient.setFeatureOverride("huddle", true);
184-
185-
// Override a feature to be disabled
186-
bucketClient.setFeatureOverride("huddle", false);
187-
188-
// Remove the override
189-
bucketClient.setFeatureOverride("huddle", null);
190-
191-
// Get current override value
192-
const override = bucketClient.getFeatureOverride("huddle"); // returns boolean | null
193-
```
194-
195-
Feature overrides are persisted in `localStorage` and will be restored when the page is reloaded.
196-
197177
### Remote config (beta)
198178

199179
Similar to `isEnabled`, each feature has a `config` property. This configuration is managed from within Bucket.

packages/browser-sdk/src/client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,21 @@ export class BucketClient {
770770
};
771771
}
772772

773+
/**
774+
* @internal
775+
*/
773776
setFeatureOverride(key: string, isEnabled: boolean | null) {
774777
this.featuresClient.setFeatureOverride(key, isEnabled);
775778
}
776779

780+
/**
781+
* @internal
782+
*/
777783
getFeatureOverride(key: string): boolean | null {
778784
return this.featuresClient.getFeatureOverride(key);
779785
}
780786

781-
sendCheckEvent(checkEvent: CheckEvent) {
787+
private sendCheckEvent(checkEvent: CheckEvent) {
782788
return this.featuresClient.sendCheckEvent(checkEvent, () => {
783789
this.hooks.trigger(
784790
checkEvent.action == "check-config" ? "configCheck" : "enabledCheck",

packages/browser-sdk/src/feature/features.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type FetchedFeature = {
2020

2121
/**
2222
* Result of feature flag evaluation.
23+
* Note: does not take local overrides into account.
2324
*/
2425
isEnabled: boolean;
2526

@@ -71,9 +72,11 @@ export type FetchedFeature = {
7172

7273
const FEATURES_UPDATED_EVENT = "featuresUpdated";
7374

75+
/**
76+
* @internal
77+
*/
7478
export type FetchedFeatures = Record<string, FetchedFeature | undefined>;
7579

76-
// todo: on next major, come up with a better name for this type. Maybe `LocalFeature`.
7780
export type RawFeature = FetchedFeature & {
7881
/**
7982
* If not null, the result is being overridden locally

0 commit comments

Comments
 (0)