@bucketco/browser-sdk
Advanced tools
Comparing version 3.0.0-alpha.0 to 3.0.0-alpha.1
@@ -1,1 +0,1 @@ | ||
export * from '../../browser-sdk/src/index' | ||
export * from '../../src/index' |
{ | ||
"name": "@bucketco/browser-sdk", | ||
"version": "3.0.0-alpha.0", | ||
"version": "3.0.0-alpha.1", | ||
"packageManager": "yarn@4.1.1", | ||
@@ -48,3 +48,3 @@ "license": "MIT", | ||
"@playwright/test": "^1.49.1", | ||
"@types/node": "^20.14.0", | ||
"@types/node": "^22.12.0", | ||
"@types/webpack": "^5.28.5", | ||
@@ -61,3 +61,3 @@ "css-loader": "^6.9.0", | ||
"style-loader": "^3.3.4", | ||
"typescript": "^5.4.5", | ||
"typescript": "^5.7.3", | ||
"vite": "^5.3.5", | ||
@@ -69,3 +69,3 @@ "vite-plugin-dts": "^4.0.0-beta.1", | ||
}, | ||
"gitHead": "a4a7bfd8839346cf057d7f06ecb52c0fe35f100f" | ||
"gitHead": "78ba5739acaf63cc20f54f462b81635cd7057b5c" | ||
} |
@@ -30,6 +30,11 @@ # Bucket Browser SDK | ||
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 | ||
@@ -41,5 +46,9 @@ // Bucket UI. | ||
// 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 }); | ||
} | ||
@@ -114,5 +123,7 @@ | ||
Attributes cannot be nested (multiple levels) and must be either strings, integers or booleans. | ||
Some attributes are special and used in Bucket UI: | ||
- `name` is a special attribute and is used to display name for user/company | ||
- for `user`, `email` is also special and will be highlighted in the Bucket UI if available | ||
- `name` is used to display name for `user`/`company`, | ||
- `email` is accepted for `user`s and will be highlighted in the Bucket UI if available, | ||
- `avatar` can be provided for both `user` and `company` and should be an URL to an image. | ||
@@ -122,4 +133,13 @@ ```ts | ||
publishableKey, | ||
user: { id: "user_123", name: "John Doe", email: "john@acme.com" }, | ||
company: { id: "company_123", name: "Acme, Inc" }, | ||
user: { | ||
id: "user_123", | ||
name: "John Doe", | ||
email: "john@acme.com" | ||
avatar: "https://example.com/images/udsy6363" | ||
}, | ||
company: { | ||
id: "company_123", | ||
name: "Acme, Inc", | ||
avatar: "https://example.com/images/31232ds" | ||
}, | ||
}); | ||
@@ -134,2 +154,3 @@ ``` | ||
// isEnabled: true, | ||
// config: { key: "zoom", payload: { ... } }, | ||
// track: () => Promise<Response> | ||
@@ -148,2 +169,3 @@ // requestFeedback: (options: RequestFeedbackData) => void | ||
// targetingVersion: 42, | ||
// config: ... | ||
// } | ||
@@ -157,4 +179,32 @@ // } | ||
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 | ||
@@ -274,2 +324,2 @@ | ||
Copyright (c) 2024 Bucket ApS | ||
Copyright (c) 2025 Bucket ApS |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1084082
5858
318