Skip to content

Commit

Permalink
Merge branch 'include-error-state' of github.com:bucketco/bucket-trac…
Browse files Browse the repository at this point in the history
…king-sdk into include-error-state
  • Loading branch information
roncohen committed Jun 18, 2024
2 parents ece03ce + cbba9d9 commit fa209cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/flag-evaluation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"type": "git",
"url": "https://github.com/bucketco/bucket-tracking-sdk.git"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc --project tsconfig.build.json",
"test": "jest",
Expand Down
26 changes: 20 additions & 6 deletions packages/react-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Wrap your application with the `Bucket` higher order component.
This will initialize Bucket, fetch feature flags and start listening for Live Satisfaction events.

```tsx
<Bucket
import BucketProvider from "@bucketco/react-sdk";

<BucketProvider
publishableKey="{YOUR_PUBLISHABLE_KEY}"
context={{
// The context should take the form of { user: { id }, company: { id } }
Expand All @@ -27,7 +29,7 @@ This will initialize Bucket, fetch feature flags and start listening for Live Sa
}}
>
{/* ... */}
</Bucket>
</BucketProvider>;
```

### Props
Expand All @@ -37,16 +39,22 @@ All options which can be passed to `bucket.init` can be passed as props to the B
See the [Tracking SDK documentation](../tracking-sdk/README.md) for more.

```tsx
<Bucket
import BucketProvider from "@bucketco/react-sdk";

<BucketProvider
publishableKey="{YOUR_PUBLISHABLE_KEY}" // The publishable key of your app environment
debug={false} // Enable debug mode to log info and errors
persistUser={true} // See the Tracking SDK documentation under "Persisting Users"
host="https://tracking.bucket.co" // Configure the host Bucket calls are made to
sseHost="https://livemessaging.bucket.co" // Configure the host Bucket SSE calls are made to
feedback={{
// See feedback options here: https://github.com/bucketco/bucket-tracking-sdk/blob/main/packages/tracking-sdk/FEEDBACK.md#global-feedback-configuration
}}
feedback={
{
// See feedback options here: https://github.com/bucketco/bucket-tracking-sdk/blob/main/packages/tracking-sdk/FEEDBACK.md#global-feedback-configuration
}
}
>
{/* ... */}
</BucketProvider>;
```

## Hooks
Expand All @@ -56,6 +64,8 @@ See the [Tracking SDK documentation](../tracking-sdk/README.md) for more.
Returns the instance of the Bucket Tracking SDK in use. This can be used to make calls to Bucket, including `track` and `feedback` calls, e.g.

```ts
import { useBucket } from "@bucketco/react-sdk";

const bucket = useBucket();

bucket.track("sent_message", { foo: "bar" }, "john_doe", "company_id");
Expand All @@ -68,6 +78,8 @@ See the [Tracking SDK documentation](../tracking-sdk/README.md) for usage inform
Returns the state of a given feature flag for the current context, e.g.

```ts
import { useFeatureFlag } from "@bucketco/react-sdk";

const joinHuddleFlag = useFeatureFlag("join-huddle");
// {
// "isLoading": false,
Expand All @@ -80,6 +92,8 @@ const joinHuddleFlag = useFeatureFlag("join-huddle");
Returns feature flags as an object, e.g.

```ts
import { useFeatureFlags } from "@bucketco/react-sdk";

const featureFlags = useFeatureFlags();
// {
// "isLoading": false,
Expand Down

0 comments on commit fa209cd

Please sign in to comment.