Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
b491173
feat: initial cli commit
Swiftwork Aug 29, 2024
24f7750
feat: implemented create feature
Swiftwork Aug 31, 2024
491b224
feat: added spinners
Swiftwork Aug 31, 2024
1908278
updated Cli login mechanism
roncohen Dec 9, 2024
4db5568
Merge branch 'main' into feat/cli-minimal
roncohen Jan 17, 2025
e1d26ba
wip cli
roncohen Jan 19, 2025
b6d9431
more wip
roncohen Jan 19, 2025
e243cdb
extracting from `toolbar`
roncohen Jan 20, 2025
fda0637
bring back comment that were lost in merge conflict
roncohen Jan 20, 2025
3564ccc
fixing more merge conflict related mistakes
roncohen Jan 20, 2025
124c73b
get toggle to work, add open animations, fix example
laander Jan 21, 2025
de7c49c
add override indicator, fix override off state
laander Jan 21, 2025
ee74cda
yarn dev support. more improvements and fixes, sleeker transitions
laander Jan 22, 2025
5ff07ed
feature search, click feature to open, small visual tweaks
laander Jan 22, 2025
e901555
code cleanup and reorganization
laander Jan 22, 2025
8d66a21
Merge branch 'main' into toolbar2
laander Jan 22, 2025
45d8f4f
move css
laander Jan 22, 2025
98442a4
Merge branch 'toolbar2' of https://github.com/bucketco/bucket-javascr…
laander Jan 22, 2025
0aee20f
proper border color
laander Jan 22, 2025
9ff6671
minor cleanup
laander Jan 23, 2025
216f237
optional featureList
laander Jan 23, 2025
b38653a
require passed featureList in order to override locally
laander Jan 23, 2025
0c0200f
refactor Dialog to use an controlled approach with a hook
laander Jan 23, 2025
6417783
toggle icon
laander Jan 23, 2025
9d7da14
fix test
laander Jan 23, 2025
f44e994
fix lint
laander Jan 23, 2025
bcfd676
attempt at adding test for opening feedback widget multiple times (wh…
laander Jan 23, 2025
86ad8f2
pass a unique key to force re-render on every form dialog open
laander Jan 23, 2025
56486c0
few more styling updates
laander Jan 23, 2025
7a99c1b
fix arrow and placement issue, tweak table
laander Jan 24, 2025
9922cf0
fix placement margins, isolate arrow component
laander Jan 24, 2025
2f71ea0
wip
roncohen Jan 24, 2025
e31b057
fix: use explicit showToolbar option if given
roncohen Jan 24, 2025
3c6c5da
revert node-sdk change
roncohen Jan 24, 2025
8012180
fix: only show toolbar on localhost if a featureList was given
roncohen Jan 24, 2025
f8df0ba
wip
roncohen Jan 25, 2025
beb6976
cleanup
roncohen Jan 26, 2025
e89d094
Merge branch 'toolbar2' into feat/cli-minimal
roncohen Jan 26, 2025
1aafaa9
wip
roncohen Jan 28, 2025
02795bb
Merge branch 'main' into feat/cli-minimal
roncohen Jan 28, 2025
0f2362b
updated various bits
roncohen Jan 29, 2025
535be18
more bits
roncohen Jan 29, 2025
d81634f
don't use `FeatureKey` in the base bucket provider
roncohen Jan 29, 2025
afa3640
adding rootDir option to disambiguate root directory
roncohen Jan 29, 2025
3d2c000
cleanups and fixes
roncohen Jan 29, 2025
bcc17ca
fix `init`
roncohen Jan 29, 2025
78ba573
feat(browser-sdk,react-sdk): extend the web SDKs to support the new `…
pavkam Jan 29, 2025
28f8035
update error message for failed init commands
roncohen Jan 29, 2025
9e23bd1
fix vitest rerun
roncohen Jan 29, 2025
9ce8b06
fix gitignore
roncohen Jan 29, 2025
8c7d330
adding in synced fallbacks
roncohen Jan 29, 2025
e0d2fb2
cleanup sync command
roncohen Jan 29, 2025
ecb8a4c
Forward `toolbar` config in react-sdk (#299)
laander Jan 29, 2025
f384857
Bump react + browser SDK to v3.0.0-alpha.2 (#300)
laander Jan 29, 2025
81f5ddc
feat(node-sdk): support for remote configuration (#295)
pavkam Jan 29, 2025
0198ab8
Merge branch 'main' into typesafety-cli
roncohen Jan 30, 2025
5538906
bump versions
roncohen Jan 30, 2025
e9afbe0
cleanups
roncohen Jan 30, 2025
ee6628c
lint fixes + getting package.json into shape
roncohen Jan 30, 2025
77d59de
more cleanups
roncohen Jan 30, 2025
92a42b6
cli should start out as alpha
roncohen Jan 30, 2025
5dce182
more cleanups
roncohen Jan 30, 2025
e964862
cleanup again
roncohen Jan 30, 2025
0b1e1cc
remove ability to pass featureId into requestFeedback
roncohen Jan 30, 2025
430c85e
add constraint to BucketClient
roncohen Jan 30, 2025
34e1988
module
roncohen Jan 30, 2025
e0b6735
fix some types
roncohen Jan 30, 2025
6c9e08b
Merge branch 'main' into typesafety-cli
roncohen Jan 30, 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
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@
"**/*.lock": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.words": [
"bucketco"
]
"cSpell.words": ["bucketco", "openfeature"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build": "lerna run build --stream",
"test:ci": "lerna run test:ci --stream",
"test": "lerna run test --stream",
"format": "lerna run format --stream",
"prettier": "lerna run prettier --stream",
"prettier:fix": "lerna run prettier -- --write",
"lint": "lerna run lint --stream",
Expand Down
47 changes: 43 additions & 4 deletions packages/browser-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,28 @@ const bucketClient = new BucketClient({ publishableKey, user, company });

await bucketClient.initialize();

const { isEnabled, track, requestFeedback } = bucketClient.getFeature("huddle");
const {
isEnabled,
config: { payload: question },
track,
requestFeedback,
} = bucketClient.getFeature("huddle");

if (isEnabled) {
// show feature. When retrieving `isEnabled` the client automatically
// Show feature. When retrieving `isEnabled` the client automatically
// sends a "check" event for the "huddle" feature which is shown in the
// Bucket UI.

// On usage, call `track` to let Bucket know that a user interacted with the feature
track();

// The `payload` is a user-supplied JSON in Bucket that is dynamically picked
// out depending on the user/company.
const question = payload?.question ?? "Tell us what you think of Huddles";

// Use `requestFeedback` to create "Send feedback" buttons easily for specific
// features. This is not related to `track` and you can call them individually.
requestFeedback({ title: "Tell us what you think of Huddles" });
requestFeedback({ title: question });
}

// `track` just calls `bucketClient.track(<featureKey>)` to send an event using the same feature key
Expand Down Expand Up @@ -138,6 +147,7 @@ To retrieve features along with their targeting information, use `getFeature(key
const huddle = bucketClient.getFeature("huddle");
// {
// isEnabled: true,
// config: { key: "zoom", payload: { ... } },
// track: () => Promise<Response>
// requestFeedback: (options: RequestFeedbackData) => void
// }
Expand All @@ -151,6 +161,7 @@ const features = bucketClient.getFeatures();
// huddle: {
// isEnabled: true,
// targetingVersion: 42,
// config: ...
// }
// }
```
Expand All @@ -159,7 +170,35 @@ const features = bucketClient.getFeatures();
by down-stream clients, like the React SDK.

Note that accessing `isEnabled` on the object returned by `getFeatures` does not automatically
generate a `check` event, contrary to the `isEnabled` property on the object return from `getFeature`.
generate a `check` event, contrary to the `isEnabled` property on the object returned by `getFeature`.

### Remote config

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
multiple configuration values which are given to different user/companies.

```ts
const features = bucketClient.getFeatures();
// {
// huddle: {
// isEnabled: true,
// targetingVersion: 42,
// config: {
// key: "gpt-3.5",
// payload: { maxTokens: 10000, model: "gpt-3.5-beta1" }
// }
// }
// }
```

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
will be empty, thus, `key` will be `undefined`. Make sure to check against this case when trying to use the
configuration in your application.

Just as `isEnabled`, accessing `config` on the object returned by `getFeatures` does not automatically
generate a `check` event, contrary to the `config` property on the object returned by `getFeature`.

### Tracking feature usage

Expand Down
27 changes: 23 additions & 4 deletions packages/browser-sdk/example/typescript/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@ import { BucketClient } from "../../src";

const urlParams = new URLSearchParams(window.location.search);
const publishableKey = urlParams.get("publishableKey");
const featureKey = urlParams.get("featureKey") ?? "huddles";

const featureList = ["huddles"];
const featureKey = (urlParams.get("featureKey") ??
"huddles") as keyof FeatureTypes;

if (!publishableKey) {
throw Error("publishableKey is missing");
}

const bucket = new BucketClient({
interface FeatureTypes {
huddles: {
key: "huddles";
isEnabled: boolean;
config: {
title: string;
description: string;
};
};
voiceHuddle: {
key: "voiceHuddle";
isEnabled: boolean;
config: {
volumeMax: number;
};
};
}

const featureList = ["huddles", "voiceHuddle"];

const bucket = new BucketClient<FeatureTypes>({
publishableKey,
user: { id: "42" },
company: { id: "1" },
Expand Down
17 changes: 11 additions & 6 deletions packages/browser-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/browser-sdk",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.3",
"packageManager": "yarn@4.1.1",
"license": "MIT",
"repository": {
Expand All @@ -26,13 +26,18 @@
"files": [
"dist"
],
"main": "./dist/bucket-browser-sdk.umd.js",
"types": "./dist/types/src/index.d.ts",
"main": "./dist/bucket-browser-sdk-index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/bucket-browser-sdk.mjs",
"require": "./dist/bucket-browser-sdk.umd.js",
"types": "./dist/types/src/index.d.ts"
"import": "./dist/bucket-browser-sdk-index.mjs",
"require": "./dist/bucket-browser-sdk.amd.js",
"types": "./dist/index.d.ts"
},
"./configuredClient": {
"import": "./dist/bucket-browser-sdk-configuredClient.mjs",
"require": "./dist/bucket-browser-sdk-configuredClient.amd.js",
"types": "./dist/configuredClient.d.ts"
}
},
"dependencies": {
Expand Down
Loading
Loading