You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -93,19 +93,21 @@ See [example/browser.html](https://github.com/bucketco/bucket-javascript-sdk/tre
93
93
94
94
Supply these to the constructor call:
95
95
96
-
```ts
96
+
```typescript
97
97
typeConfiguration= {
98
98
logger:console; // by default only logs warn/error, by passing `console` you'll log everything
99
99
apiBaseUrl?:"https://front.bucket.co";
100
100
sseBaseUrl?:"https://livemessaging.bucket.co";
101
101
feedback?:undefined; // See FEEDBACK.md
102
-
enableTracking?:true; // set to `false` to stop sending track events and user/company updates to Bucket servers. Useful when you're impersonating a user.
102
+
enableTracking?:true; // set to `false` to stop sending track events and user/company updates to Bucket servers. Useful when you're impersonating a user
103
103
featureOptions?: {
104
-
fallbackFeatures?:string[]; // Enable these features if unable to contact bucket.co
105
-
timeoutMs?:number; // Timeout for fetching features
106
-
staleWhileRevalidate?:boolean; // Revalidate in the background when cached features turn stale to avoid latency in the UI
107
-
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.
108
-
expireTimeMs?:number; // In case we're unable to fetch features from Bucket, cached/stale features will be used instead until they expire after `expireTimeMs`.
104
+
fallbackFeatures?:
105
+
|string[]
106
+
|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
107
+
timeoutMs?:number; // Timeout for fetching features (default: 5000ms)
108
+
staleWhileRevalidate?:boolean; // Revalidate in the background when cached features turn stale to avoid latency in the UI (default: false)
109
+
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
110
+
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
109
111
};
110
112
};
111
113
```
@@ -120,9 +122,9 @@ In addition to the `id`, you must also supply anything additional that you want
120
122
Attributes cannot be nested (multiple levels) and must be either strings, integers or booleans.
121
123
Some attributes are special and used in Bucket UI:
122
124
123
-
-`name`is used to display name for `user`/`company`,
124
-
-`email` is accepted for `user`s and will be highlighted in the Bucket UI if available,
125
-
-`avatar` can be provided for both `user` and `company` and should be an URL to an image.
125
+
-`name`-- display name for `user`/`company`,
126
+
-`email`-- is accepted for `user`s and will be highlighted in the Bucket UI if available,
127
+
-`avatar`-- can be provided for both `user` and `company` and should be an URL to an image.
126
128
127
129
```ts
128
130
const bucketClient =newBucketClient({
@@ -172,6 +174,43 @@ by down-stream clients, like the React SDK.
172
174
Note that accessing `isEnabled` on the object returned by `getFeatures` does not automatically
173
175
generate a `check` event, contrary to the `isEnabled` property on the object returned by `getFeature`.
174
176
177
+
### Feature Overrides
178
+
179
+
You can override feature flags locally for testing purposes using `setFeatureOverride`:
Note that user/company attributes are also stored remotely on the Bucket servers and will automatically be used to evaluate feature targeting if the page is refreshed.
267
+
> [!NOTE] > `user`/`company` attributes are also stored remotely on the Bucket servers and will automatically be used to evaluate feature targeting if the page is refreshed.
229
268
230
269
### Qualitative feedback
231
270
@@ -235,7 +274,8 @@ Bucket can collect qualitative feedback from your users in the form of a [Custom
235
274
236
275
The Bucket Browser SDK comes with automated feedback collection mode enabled by default, which lets the Bucket service ask your users for feedback for relevant features just after they've used them.
237
276
238
-
Note: To get started with automatic feedback collection, make sure you've set `user` in the `BucketClient` constructor.
277
+
> [!NOTE]
278
+
> To get started with automatic feedback collection, make sure you've set `user` in the `BucketClient` constructor.
239
279
240
280
Automated feedback surveys work even if you're not using the SDK to send events to Bucket.
241
281
It works because the Bucket Browser SDK maintains a live connection to Bucket's servers and can automatically show a feedback prompt whenever the Bucket servers determines that an event should trigger a prompt - regardless of how this event is sent to Bucket.
@@ -262,7 +302,7 @@ bucketClient.feedback({
262
302
});
263
303
```
264
304
265
-
####Bucket feedback API
305
+
### Bucket feedback API
266
306
267
307
If you are not using the Bucket Browser SDK, you can still submit feedback using the HTTP API.
268
308
@@ -274,9 +314,9 @@ The Bucket Browser SDK doesn't collect any metadata and HTTP IP addresses are _n
274
314
275
315
For tracking individual users, we recommend using something like database ID as userId, as it's unique and doesn't include any PII (personal identifiable information). If, however, you're using e.g. email address as userId, but prefer not to send any PII to Bucket, you can hash the sensitive data before sending it to Bucket:
276
316
277
-
```
317
+
```ts
278
318
importbucketfrom"@bucketco/browser-sdk";
279
-
import { sha256 } from 'crypto-hash';
319
+
import { sha256 } from"crypto-hash";
280
320
281
321
bucket.user(awaitsha256("john_doe"));
282
322
```
@@ -290,28 +330,27 @@ The two cookies are:
290
330
-`bucket-prompt-${userId}`: store the last automated feedback prompt message ID received to avoid repeating surveys
291
331
-`bucket-token-${userId}`: caching a token used to connect to Bucket's live messaging infrastructure that is used to deliver automated feedback surveys in real time.
292
332
293
-
### Typescript
333
+
### TypeScript
294
334
295
335
Types are bundled together with the library and exposed automatically when importing through a package manager.
296
336
297
337
## Content Security Policy (CSP)
298
338
299
339
If you are running with strict Content Security Policies active on your website, you will need to enable these directives in order to use the SDK:
| connect-src |https://livemessaging.bucket.co| Server sent events for use in automated feedback surveys, which allows for automatically collecting feedback when a user used a feature. |
305
-
| style-src | 'unsafe-inline' | The feedback UI is styled with inline styles. Not having this directive results unstyled HTML elements. |
| connect-src |[https://livemessaging.bucket.co](https://livemessaging.bucket.co)| Server sent events for use in automated feedback surveys, which allows for automatically collecting feedback when a user used a feature. |
345
+
| style-src | 'unsafe-inline' | The feedback UI is styled with inline styles. Not having this directive results unstyled HTML elements. |
306
346
307
347
If you are including the Bucket tracking SDK with a `<script>`-tag from `jsdelivr.net` you will also need:
0 commit comments