Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4f6ccb6
Add support for feature-specific config payloads
pavkam Jan 10, 2025
7b3a4af
Refactor flag evaluation logic and update SDK version.
pavkam Jan 13, 2025
70f2393
Add feature configuration support and enhance fallback features
pavkam Jan 13, 2025
2e30def
Merge remote-tracking branch 'origin/main' into buc-3198-extend-the-w…
pavkam Jan 13, 2025
d2e9de6
Bump version to 0.4.0
pavkam Jan 13, 2025
5af7fd3
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 22, 2025
340fc9c
feat(browser-sdk): add format script, improve README formatting, and …
pavkam Jan 22, 2025
a6c6678
feat(browser-sdk): update feature configuration handling and improve …
pavkam Jan 22, 2025
f5f250e
feat(react-sdk): enhance feature handling in useFeature hook
pavkam Jan 22, 2025
66f661a
feat(browser-sdk, react-sdk, openfeature-browser-sdk): enhance featur…
pavkam Jan 22, 2025
38975e1
feat(openfeature-browser-provider): revert changes to openfeature ada…
pavkam Jan 24, 2025
f2ba839
chore(browser-sdk, react-sdk): Respond to comments
pavkam Jan 24, 2025
f1383e6
fix(browser-sdk): update README to reflect changes in feature configu…
pavkam Jan 24, 2025
cd276f4
feat(openfeature-browser-provider): update browser-sdk dependency and…
pavkam Jan 24, 2025
5f02bb8
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 27, 2025
295f05d
fix(browser-sdk): update feature remote config type definition
pavkam Jan 27, 2025
0dd5757
chore(react-sdk): remove unused import from index.tsx
pavkam Jan 27, 2025
7173423
feat(browser-sdk): enhance fallback feature configuration handling
pavkam Jan 27, 2025
862df25
test(browser-sdk): remove .only from features test
pavkam Jan 27, 2025
2326f86
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
e22475b
test(browser-sdk): update feature test expectations
pavkam Jan 27, 2025
b6d7b9a
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
31ee556
refactor(react-sdk): simplify feature config retrieval
pavkam Jan 27, 2025
2e62475
refactor(react-sdk): simplify feature config access and reduce payload
pavkam Jan 27, 2025
4b09505
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 27, 2025
13f5f2f
test(browser-sdk): improve test coverage and error handling for flag …
pavkam Jan 27, 2025
2f74252
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 28, 2025
fa735d8
docs(browser-sdk,react-sdk): clarify remote config documentation
pavkam Jan 28, 2025
a6eb451
Merge remote-tracking branch 'origin/main' into buc-3198-extend-the-w…
pavkam Jan 28, 2025
ff3e85a
Merge remote-tracking branch 'origin/buc-3198-extend-the-web-sdks-to-…
pavkam Jan 28, 2025
f986feb
feat(browser-sdk): export FallbackFeatureOverride type
pavkam Jan 28, 2025
7c6c47c
chore(release): bump browser-sdk and react-sdk to 3.0.0-alpha.1
pavkam Jan 28, 2025
352a462
Merge branch 'main' into buc-3198-extend-the-web-sdks-to-expose-the-c…
pavkam Jan 28, 2025
931cf96
Merge branch 'buc-3198-extend-the-web-sdks-to-expose-the-config' into…
pavkam Jan 28, 2025
a75eec8
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.0
pavkam Jan 28, 2025
9d89947
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.1
pavkam Jan 28, 2025
9faa1ac
Merge branch 'main' into buc-3250-extend-the-openfeature-web-sdk-to-u…
pavkam Jan 29, 2025
91a7ae0
chore(deps): upgrade @bucketco/browser-sdk to 3.0.0-alpha.1
pavkam Jan 29, 2025
aee63d5
fix(node-sdk): update Feature type to support undefined config
pavkam Feb 4, 2025
2029f91
chore(node-sdk): bump version to 1.6.0-alpha.3
pavkam Feb 5, 2025
f7f90c1
Merge branch 'node-1.6.alpha' into buc-3250-extend-the-openfeature-we…
pavkam Feb 5, 2025
dc93f93
feat(openfeature-browser-provider): Enhance provider with improved fe…
pavkam Feb 8, 2025
02779b3
feat(openfeature-node-provider): Enhance provider with improved featu…
pavkam Feb 8, 2025
4dd9dea
fix(openfeature-providers): Ensure consistent type conversion for use…
pavkam Feb 8, 2025
6ba06c7
Merge branch 'browser-react-3.0.alpha' into buc-3250-extend-the-openf…
pavkam Feb 8, 2025
98734c4
fix(openfeature-providers): Improve type checking and payload resolut…
pavkam Feb 8, 2025
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
2 changes: 1 addition & 1 deletion packages/node-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/node-sdk",
"version": "1.6.0-alpha.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the browser-react branch, let's keep node-sdk separate

"version": "1.6.0-alpha.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/node-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export type FeatureRemoteConfig =
* Describes a feature
*/
export interface Feature<
TConfig extends FeatureRemoteConfig | never = EmptyFeatureRemoteConfig,
TConfig extends FeatureRemoteConfig | undefined = EmptyFeatureRemoteConfig,
> {
/**
* The key of the feature.
Expand All @@ -148,7 +148,7 @@ export interface Feature<
/*
* Optional user-defined configuration.
*/
config: TConfig extends never ? EmptyFeatureRemoteConfig : TConfig;
config: TConfig extends undefined ? EmptyFeatureRemoteConfig : TConfig;

/**
* Track feature usage in Bucket.
Expand Down
88 changes: 75 additions & 13 deletions packages/openfeature-browser-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The OpenFeature SDK is required as peer dependency.

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

```
$ npm install @openfeature/web-sdk @bucketco/openfeature-browser-provider
```shell
npm install @openfeature/web-sdk @bucketco/openfeature-browser-provider
```

## Sample initialization
Expand All @@ -36,13 +36,69 @@ const client = OpenFeature.getClient();

// use client
const boolValue = client.getBooleanValue("huddles", false);
```

Bucket only supports boolean values.
// use more complex, dynamic config-enabled functionality.
const feedbackConfig = client.getObjectValue("ask-feedback", {
question: "How are you enjoying this feature?",
});
```

Initializing the Bucket Browser Provider will
also initialize [automatic feedback surveys](https://github.com/bucketco/bucket-javascript-sdk/tree/main/packages/browser-sdk#qualitative-feedback).

## Feature resolution methods

The Bucket OpenFeature Provider implements the OpenFeature evaluation interface for different value types. Each method handles the resolution of feature flags according to the OpenFeature specification.

### Common behavior

All resolution methods share these behaviors:

- Return default value with `PROVIDER_NOT_READY` if client is not initialized,
- Return default value with `FLAG_NOT_FOUND` if flag doesn't exist,
- Return default value with `ERROR` if there was a type mismatch,
- Return evaluated value with `TARGETING_MATCH` on successful resolution.

### Type-Specific Methods

#### Boolean Resolution

```ts
client.getBooleanValue("my-flag", false);
```

Returns the feature's enabled state. This is the most common use case for feature flags.

#### String Resolution

```ts
client.getStringValue("my-flag", "default");
```

Returns the feature's remote config key (also known as "variant"). Useful for multi-variate use cases.

#### Number Resolution

```ts
client.getNumberValue("my-flag", 0);
```

Not directly supported by Bucket. Use `getObjectValue` instead for numeric configurations.

#### Object Resolution

```ts
// works for any type:
client.getObjectValue("my-flag", { defaultValue: true });
client.getObjectValue("my-flag", "string-value");
client.getObjectValue("my-flag", 199);
```

Returns the feature's remote config payload with type validation. This is the most flexible method,
allowing for complex configuration objects or simple types.

The object resolution performs runtime type checking between the default value and the feature payload to ensure type safety.

## Context

To convert the OpenFeature context to a Bucket appropriate context
Expand All @@ -61,11 +117,18 @@ const publishableKey = "<your-bucket-publishable-key>";
const contextTranslator = (context?: EvaluationContext) => {
return {
user: {
id: context["trackingKey"],
name: context["name"],
email: context["email"],
id: context.targetingKey ?? context["userId"],
email: context["email"]?.toString(),
name: context["name"]?.toString(),
avatar: context["avatar"]?.toString(),
country: context["country"]?.toString(),
},
company: {
id: context["companyId"],
name: context["companyName"]?.toString(),
avatar: context["companyAvatar"]?.toString(),
plan: context["companyPlan"]?.toString(),
},
company: { id: context["orgId"], name: context["orgName"] },
};
};

Expand All @@ -81,7 +144,7 @@ To update the context, call `OpenFeature.setContext(myNewContext);`
await OpenFeature.setContext({ userId: "my-key" });
```

# Tracking feature usage
## Tracking feature usage

The Bucket OpenFeature Provider supports the OpenFeature tracking API
natively.
Expand All @@ -103,8 +166,7 @@ const client = OpenFeature.getClient();
client.track("huddles");
```

# License

MIT License
## License

Copyright (c) 2025 Bucket ApS
> MIT License
> Copyright (c) 2025 Bucket ApS
4 changes: 2 additions & 2 deletions packages/openfeature-browser-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/openfeature-browser-provider",
"version": "0.3.1",
"version": "0.4.0-alpha.0",
"packageManager": "yarn@4.1.1",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -35,7 +35,7 @@
}
},
"dependencies": {
"@bucketco/browser-sdk": "2.4.0"
"@bucketco/browser-sdk": "3.0.0-alpha.2"
},
"devDependencies": {
"@bucketco/eslint-config": "0.0.2",
Expand Down
Loading