Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7f3c22b
feat: initial cli commit
Swiftwork Aug 29, 2024
1eabe26
feat: implemented create feature
Swiftwork Aug 31, 2024
174c0f9
feat: added spinners
Swiftwork Aug 31, 2024
4713640
updated Cli login mechanism
roncohen Dec 9, 2024
88fc072
fix auth flow, remove envId
roncohen Feb 19, 2025
d6d758f
make this a pre-1.0 release
roncohen Feb 19, 2025
cf1b15f
feat: more work on CLI
Swiftwork Feb 21, 2025
46acd23
feat: new command and cleaned up existing commands
Swiftwork Feb 24, 2025
dc8db11
fix: remove incorrectly committed config file
Swiftwork Feb 24, 2025
07169dc
fix: logs and spinners
Swiftwork Feb 24, 2025
dbda322
feat: removed axios
Swiftwork Feb 25, 2025
b7d592f
feat: allow multiple baseUrls
Swiftwork Feb 25, 2025
b844eee
refactor: minor
Swiftwork Feb 25, 2025
e148e63
style: fix linting errors
Swiftwork Feb 25, 2025
51fa0a8
fix: errors and post request
Swiftwork Feb 25, 2025
f5448f4
feat(browser-sdk,react-sdk): extend the web SDKs to support the new `…
pavkam Jan 29, 2025
6d2b7e7
Forward `toolbar` config in react-sdk (#299)
laander Jan 29, 2025
74c77e5
Bump react + browser SDK to v3.0.0-alpha.2 (#300)
laander Jan 29, 2025
87831e7
feat(node-sdk): support for remote configuration (#295)
pavkam Jan 29, 2025
9f9144d
chore(node-sdk): bump version (#302)
pavkam Feb 3, 2025
d659c56
chore: allow publishing of non `main` branches` (#304)
roncohen Feb 4, 2025
f5da70b
fix(node-sdk): update Feature type to support undefined config
pavkam Feb 4, 2025
cf86bc2
chore(node-sdk): bump version to 1.6.0-alpha.3
pavkam Feb 5, 2025
29b896c
feat(node-sdk): improved flag events (#307)
pavkam Feb 12, 2025
b8710e0
fix(node-sdk): ensure timers don't keep process alive (#303)
roncohen Feb 3, 2025
490e6e0
feat(node-sdk): allow passing `meta` to `getFeature(s)` (#312)
pavkam Feb 9, 2025
ba00acc
chore(deps-dev): bump vitest from 2.0.4 to 2.1.9 (#314)
dependabot[bot] Feb 10, 2025
eadb491
chore(deps-dev): bump vitest from 2.1.4 to 2.1.9 in /packages/node-sd…
dependabot[bot] Feb 10, 2025
6d9f894
feat(openfeature-node-provider): improve flag resolution and context …
pavkam Feb 12, 2025
33acb1d
chore(deps): bump @bucketco/node-sdk from 1.6.0-alpha.3 to 1.6.0-alpha.4
pavkam Feb 12, 2025
8b63880
feat(openfeature-node-provider): enhance todo feature management with…
pavkam Feb 20, 2025
99eb2c8
feat(node-sdk): add configurable exit event flushing (#311)
pavkam Feb 13, 2025
b504803
chore(deps): bump serialize-javascript from 6.0.1 to 6.0.2 (#321)
dependabot[bot] Feb 13, 2025
974fa63
chore: upgrade typedoc-plugin-markdown (#320)
matus-vacula Feb 13, 2025
37b6c57
chore: change docs destination (#327)
matus-vacula Feb 19, 2025
b59088a
refactor(browser-sdk,react-sdk): Remove deprecated and flatten option…
roncohen Feb 6, 2025
07acb56
feat(browser-sdk,react-sdk): use remote feature list instead of local…
roncohen Feb 12, 2025
8e60fee
feat(browser-sdk,node-sdk): add avatar support for user and company c…
pavkam Jan 28, 2025
0b6855a
feat(browser-sdk,react-sdk): check events (#316)
pavkam Feb 12, 2025
09d2d0b
feat(openfeature-web-provider): improve flag resolution and context h…
pavkam Feb 12, 2025
d34837b
chore(openfeature-browser-provider): bump version to 0.4.0-alpha.1
pavkam Feb 12, 2025
75eed5a
refactor(react-sdk): simplify BucketProvider props and improve type d…
pavkam Feb 13, 2025
5516d2d
chore(browser-sdk,react-sdk): bump SDK versions to 3.0.0-alpha.4 and …
pavkam Feb 13, 2025
dcbe08d
fix(browser-sdk,react-sdk): remove featureId option for requestFeedba…
roncohen Feb 13, 2025
705f213
fix(react-sdk): throw error on missing provider (#322)
roncohen Feb 13, 2025
6793fdd
fix(browser-sdk): remove featureDefinition list (#323)
roncohen Feb 13, 2025
811814f
fix(react-sdk): improve type definitions for useFeature hook (#324)
pavkam Feb 17, 2025
6e42f8f
feat(browser-sdk): Event listeners (#325)
roncohen Feb 17, 2025
41cb74c
feat(openfeature-browser-provider): add fallback features and improve…
pavkam Feb 20, 2025
8338f53
chore(open-feature): small PR comments (#332)
pavkam Feb 20, 2025
48c6eaa
feat(react-sdk): add onFeaturesUpdated prop and useClient hook (#329)
pavkam Feb 20, 2025
62b55a8
fix(browser-sdk): Small toolbar polish (#333)
laander Feb 21, 2025
1680d22
docs(react-sdk,browser-sdk): updated various out-of-date docs (#338)
roncohen Feb 26, 2025
29320b7
fix(node-sdk): type errors in tests (#339)
roncohen Feb 26, 2025
ebbb6bd
Official deprecate the tracking-sdk (#340)
Swiftwork Feb 26, 2025
c9e6fbe
fix(browser-sdk): fix e2e test stability (#343)
roncohen Feb 26, 2025
42c79e7
docs: Remote config docs improvements (#341)
roncohen Feb 26, 2025
d653f2c
docs(browser-sdk): make feature overrides internal for now (#342)
roncohen Feb 26, 2025
edfe087
Upgrade ESLint and Prettier (#336)
Swiftwork Feb 26, 2025
7954a79
chore(react-sdk,node-sdk,browser-sdk): new alpha releases (#337)
roncohen Feb 26, 2025
ad62bcc
Merge branch 'main' into feat/cli
Swiftwork Feb 26, 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
3 changes: 0 additions & 3 deletions .github/workflows/package-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
- name: Restore package.json
# This step is necessary because the previous step may have updated package.json
run: git checkout -- package.json packages/*/package.json
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
working-directory: ./packages/tracking-sdk
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
working-directory: ./packages/browser-sdk
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
path: bucket-docs
- name: Copy generated docs to docs repo
run: |
rm -rf bucket-docs/sdk-docs
cp -R dist/docs bucket-docs/sdk-docs
rm -rf bucket-docs/sdk
cp -R dist/docs bucket-docs/sdk
- name: Commit and push changes
run: |
cd bucket-docs
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@bucket.co"
git add sdk-docs
git add sdk
git commit -m "Update documentation" && git push || echo "No docs changes to commit"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ junit.xml

.next
eslint-report.json
bucket.config.json
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"packageManager": "yarn@4.1.1",
"devDependencies": {
"lerna": "^8.1.3",
"prettier": "^3.3.3",
"prettier": "^3.5.2",
"typedoc": "0.27.6",
"typedoc-plugin-frontmatter": "^1.1.2",
"typedoc-plugin-markdown": "^4.4.1",
"typedoc-plugin-markdown": "^4.4.2",
"typedoc-plugin-mdn-links": "^4.0.7",
"typescript": "^5.7.3"
}
Expand Down
8 changes: 1 addition & 7 deletions packages/browser-sdk/FEEDBACK.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,7 @@ properties to your page in your CSS `:root`-scope.

For example, a dark mode theme might look like this:

```html
<img
width="276"
alt="image"
src="https://github.com/bucketco/bucket-tracking-sdk/assets/34348/5d579b7b-a830-4530-8b40-864488a8597e"
/>
```
![image](https://github.com/bucketco/bucket-tracking-sdk/assets/34348/5d579b7b-a830-4530-8b40-864488a8597e)

```css
:root {
Expand Down
68 changes: 16 additions & 52 deletions packages/browser-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-beta).

## Install

First find your `publishableKey` under [environment settings](https://app.bucket.co/envs/current/settings/app-environments) in Bucket.
Expand Down Expand Up @@ -100,15 +102,13 @@ type Configuration = {
sseBaseUrl?: "https://livemessaging.bucket.co";
feedback?: undefined; // See FEEDBACK.md
enableTracking?: true; // set to `false` to stop sending track events and user/company updates to Bucket servers. Useful when you're impersonating a user
featureOptions?: {
fallbackFeatures?:
| string[]
| Record<string, { key: string; payload: any } | true>; // Enable these features if unable to contact bucket.co. Can be a list of feature keys or a record with configuration values
timeoutMs?: number; // Timeout for fetching features (default: 5000ms)
staleWhileRevalidate?: boolean; // Revalidate in the background when cached features turn stale to avoid latency in the UI (default: false)
staleTimeMs?: number; // at initialization time features are loaded from the cache unless they have gone stale. Defaults to 0 which means the cache is disabled. Increase in the case of a non-SPA
expireTimeMs?: number; // In case we're unable to fetch features from Bucket, cached/stale features will be used instead until they expire after `expireTimeMs`. Default is 30 days
};
fallbackFeatures?:
| string[]
| Record<string, { key: string; payload: any } | true>; // Enable these features if unable to contact bucket.co. Can be a list of feature keys or a record with configuration values
timeoutMs?: number; // Timeout for fetching features (default: 5000ms)
staleWhileRevalidate?: boolean; // Revalidate in the background when cached features turn stale to avoid latency in the UI (default: false)
staleTimeMs?: number; // at initialization time features are loaded from the cache unless they have gone stale. Defaults to 0 which means the cache is disabled. Increase this in the case of a non-SPA
expireTimeMs?: number; // In case we're unable to fetch features from Bucket, cached/stale features will be used instead until they expire after `expireTimeMs`. Default is 30 days
};
```

Expand Down Expand Up @@ -174,44 +174,7 @@ 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 returned by `getFeature`.

### Feature Overrides

You can override feature flags locally for testing purposes using `setFeatureOverride`:

```ts
// Override a feature to be enabled
bucketClient.setFeatureOverride("huddle", true);

// Override a feature to be disabled
bucketClient.setFeatureOverride("huddle", false);

// Remove the override
bucketClient.setFeatureOverride("huddle", null);

// Get current override value
const override = bucketClient.getFeatureOverride("huddle"); // returns boolean | null
```

Feature overrides are persisted in `localStorage` and will be restored when the page is reloaded.

### Feature Updates

You can listen for feature updates using `onFeaturesUpdated`:

```ts
// Register a callback for feature updates
const unsubscribe = bucketClient.onFeaturesUpdated(() => {
console.log("Features were updated");
});

// Later, stop listening for updates
unsubscribe();
```

> [!NOTE]
> Note that the callback may be called even if features haven't actually changed.

### 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
Expand Down Expand Up @@ -312,11 +275,12 @@ See details in [Feedback HTTP API](https://docs.bucket.co/reference/http-trackin

Event listeners allow for capturing various events occurring in the `BucketClient`. This is useful to build integrations with other system or for various debugging purposes. There are 5 kinds of events:

- FeaturesUpdated
- User
- Company
- Check
- Track
- `configCheck`: Your code used a feature config
- `enabledCheck`: Your code checked whether a specific feature should be enabled
- `featuresUpdated`: Features were updated. Either because they were loaded as part of initialization or because the user/company updated
- `user`: User information updated (similar to the `identify` call used in tracking terminology)
- `company`: Company information updated (sometimes to the `group` call used in tracking terminology)
- `track`: Track event occurred.

Use the `on()` method to add an event listener to respond to certain events. See the API reference for details on each hook.

Expand Down
24 changes: 22 additions & 2 deletions packages/browser-sdk/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
const base = require("@bucketco/eslint-config/base");
const base = require("@bucketco/eslint-config");

module.exports = [...base, { ignores: ["dist/", "example/"] }];
module.exports = [
...base,
{
// Preact projects
files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
settings: {
react: {
// We only care about marking h() as being a used variable.
pragma: "h",
// We use "react 16.0" to avoid pushing folks to UNSAFE_ methods.
version: "16.0",
},
},
rules: {
// Ignore React attributes that are not valid in Preact.
// Alternatively, we could use the preact/compat alias or turn off the rule.
"react/no-unknown-property": ["off"],
},
},
{ ignores: ["dist/", "example/"] },
];
2 changes: 1 addition & 1 deletion packages/browser-sdk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="color-scheme" content="light dark" />
<title>Bucket Browser SDK</title>
</head>
<body>
<body style="background-color: black">
<div id="app"></div>
<span id="loading">Loading...</span>

Expand Down
19 changes: 9 additions & 10 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.4",
"version": "3.0.0-alpha.6",
"packageManager": "yarn@4.1.1",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -45,23 +45,22 @@
"@bucketco/eslint-config": "0.0.2",
"@bucketco/tsconfig": "0.0.2",
"@playwright/test": "^1.49.1",
"@types/js-cookie": "^3.0.6",
"@types/node": "^22.12.0",
"@types/webpack": "^5.28.5",
"css-loader": "^6.9.0",
"eslint": "^8.57.0",
"@vitest/coverage-v8": "^2.0.4",
"c8": "~10.1.3",
"eslint": "^9.21.0",
"http-server": "^14.1.1",
"jsdom": "^24.1.0",
"msw": "^2.3.4",
"nock": "^14.0.1",
"postcss": "^8.4.33",
"postcss-loader": "^7.3.4",
"postcss-nesting": "^12.0.2",
"postcss-preset-env": "^9.3.0",
"prettier": "^3.2.5",
"style-loader": "^3.3.4",
"prettier": "^3.5.2",
"typescript": "^5.7.3",
"vite": "^5.3.5",
"vite-plugin-dts": "^4.0.0-beta.1",
"vitest": "^2.0.4",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
"vitest": "^2.0.4"
}
}
1 change: 1 addition & 0 deletions packages/browser-sdk/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export default defineConfig({
// separate port to let the app run alongside the tracking sdk tests
command: "npx http-server . -p 8001",
timeout: 120 * 1000,
port: 8001,
},
});
10 changes: 8 additions & 2 deletions packages/browser-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export type FeatureRemoteConfig =
| { key: undefined; payload: undefined };

/**
* A feature.
* Represents a feature.
*/
export interface Feature {
/**
Expand Down Expand Up @@ -770,15 +770,21 @@ export class BucketClient {
};
}

/**
* @internal
*/
setFeatureOverride(key: string, isEnabled: boolean | null) {
this.featuresClient.setFeatureOverride(key, isEnabled);
}

/**
* @internal
*/
getFeatureOverride(key: string): boolean | null {
return this.featuresClient.getFeatureOverride(key);
}

sendCheckEvent(checkEvent: CheckEvent) {
private sendCheckEvent(checkEvent: CheckEvent) {
return this.featuresClient.sendCheckEvent(checkEvent, () => {
this.hooks.trigger(
checkEvent.action == "check-config" ? "configCheck" : "enabledCheck",
Expand Down
4 changes: 2 additions & 2 deletions packages/browser-sdk/src/feature/featureCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class FeatureCache {
if (cachedResponseRaw) {
cacheData = validateCacheData(JSON.parse(cachedResponseRaw)) ?? {};
}
} catch (e) {
} catch {
// ignore errors
}

Expand Down Expand Up @@ -123,7 +123,7 @@ export class FeatureCache {
};
}
}
} catch (e) {
} catch {
// ignore errors
}
return;
Expand Down
7 changes: 5 additions & 2 deletions packages/browser-sdk/src/feature/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type FetchedFeature = {

/**
* Result of feature flag evaluation.
* Note: does not take local overrides into account.
*/
isEnabled: boolean;

Expand Down Expand Up @@ -71,9 +72,11 @@ export type FetchedFeature = {

const FEATURES_UPDATED_EVENT = "featuresUpdated";

/**
* @internal
*/
export type FetchedFeatures = Record<string, FetchedFeature | undefined>;

// todo: on next major, come up with a better name for this type. Maybe `LocalFeature`.
export type RawFeature = FetchedFeature & {
/**
* If not null, the result is being overridden locally
Expand Down Expand Up @@ -328,7 +331,7 @@ export class FeaturesClient {
let errorBody = null;
try {
errorBody = await res.json();
} catch (e) {
} catch {
// ignore
}

Expand Down
2 changes: 1 addition & 1 deletion packages/browser-sdk/src/feedback/promptStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getAuthToken = (userId: string) => {
channel,
token,
};
} catch (e) {
} catch {
return undefined;
}
};
Expand Down
8 changes: 4 additions & 4 deletions packages/browser-sdk/src/feedback/ui/Button.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
0 1px 1px 0 rgba(0, 0, 0, 0.01);
border-radius: var(--bucket-feedback-dialog-border-radius, 6px);
transition-duration: 200ms;
transition-property: background-color, border-color, color, opacity,
box-shadow, transform;
transition-property:
background-color, border-color, color, opacity, box-shadow, transform;

&.primary {
background-color: var(
Expand All @@ -40,8 +40,8 @@
border-color: var(--bucket-feedback-dialog-primary-border-color, #d8d9df);

transition-duration: 200ms;
transition-property: background-color, border-color, color, opacity,
box-shadow, transform;
transition-property:
background-color, border-color, color, opacity, box-shadow, transform;
}

&:focus {
Expand Down
Loading
Loading