Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 6 additions & 38 deletions packages/vue-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BucketProvider } from "@bucketco/vue-sdk";
</script>

<BucketProvider
:publishableKey="publishableKey"
:publishable-key="publishableKey"
:user="{ id: 'user_123', name: 'John Doe', email: 'john@acme.com' }"
:company="{ id: 'acme_inc', plan: 'pro' }"
>
Expand All @@ -46,23 +46,6 @@ const huddle = useFeature("huddle");
<template>
<div v-if="huddle.isEnabled">
<button @click="huddle.track()">Start huddle!</button>
<button
@click="
(e) =>
huddle.requestFeedback({
title:
huddle.config.payload?.question ??
'How do you like the Huddles feature?',
position: {
type: 'POPOVER',
anchor: e.currentTarget as HTMLElement,
},
})
"
>
Give feedback!
</button>
</div>
</template>
```

Expand All @@ -84,7 +67,7 @@ A number of special attributes exist:

```vue
<BucketProvider
:publishableKey="publishableKey"
:publishable-key="publishableKey"
:user="{ id: 'user_123', name: 'John Doe', email: 'john@acme.com' }"
:company="{ id: 'acme_inc', plan: 'pro' }"
></BucketProvider>
Expand Down Expand Up @@ -126,26 +109,9 @@ The `<BucketProvider>` initializes the Bucket SDK, fetches features and starts l

- `publishableKey` is used to connect the provider to an _environment_ on Bucket. Find your `publishableKey` under [environment settings](https://app.bucket.co/envs/current/settings/app-environments) in Bucket,
- `company`, `user` and `otherContext` make up the _context_ that is used to determine if a feature is enabled or not. `company` and `user` contexts are automatically transmitted to Bucket servers so the Bucket app can show you which companies have access to which features etc.

> [!Note]
> If you specify `company` and/or `user` they must have at least the `id` property, otherwise they will be ignored in their entirety. You should also supply anything additional you want to be able to evaluate feature targeting against,
- `fallbackFeatures`: A list of strings which specify which features to consider enabled if the SDK is unable to fetch features. Can be provided in two formats:

```ts
// Simple array of feature keys
fallbackFeatures={["feature1", "feature2"]}

// Or with configuration overrides
fallbackFeatures: {
"feature1": true, // just enable the feature
"feature2": { // enable with configuration
key: "variant-a",
payload: {
limit: 100,
mode: "test"
}
}
}
```

- `timeoutMs`: Timeout in milliseconds when fetching features from the server,
- `staleWhileRevalidate`: If set to `true`, stale features will be returned while refetching features in the background,
Expand All @@ -167,7 +133,7 @@ BucketProvider lets you define a template to be shown while BucketProvider is in
```vue
<template>
<BucketProvider
:publishableKey="publishableKey"
:publishable-key="publishableKey"
:user="user"
:company="{ id: 'acme_inc', plan: 'pro' }"
>
Expand Down Expand Up @@ -217,6 +183,8 @@ const huddle = useFeature("huddle");
</template>
```

See the reference docs for details.

### `useTrack()`

`useTrack()` lets you send custom events to Bucket. Use this whenever a user _uses_ a feature.
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-sdk/dev/plain/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const publishableKey = import.meta.env.VITE_PUBLISHABLE_KEY || "";
</div>
<BucketProvider
v-else
:publishableKey="publishableKey"
:publishable-key="publishableKey"
:user="user"
:company="{ id: 'acme_inc', plan: 'pro' }"
>
Expand Down