Reference

Interfaces

Features

Type Aliases

BucketProps

type BucketProps = BucketContext & {
  apiBaseUrl: string;
  children: ReactNode;
  debug: boolean;
  enableTracking: boolean;
  featureOptions: Omit<FeaturesOptions, "fallbackFeatures"> & {
     fallbackFeatures: FeatureKey[];
    };
  feedback: FeedbackOptions;
  host: string;
  loadingComponent: ReactNode;
  newBucketClient: (...args: ConstructorParameters<typeof BucketClient>) => BucketClient;
  publishableKey: string;
  sseBaseUrl: string;
  sseHost: string;
};

Type declaration

Name
Type
Description

apiBaseUrl?

string

children?

ReactNode

debug?

boolean

enableTracking?

boolean

featureOptions?

feedback?

host?

string

Deprecated

Use apiBaseUrl instead.

loadingComponent?

ReactNode

newBucketClient?

publishableKey

string

sseBaseUrl?

string

sseHost?

string

Deprecated

Use sseBaseUrl instead.


FeatureKey

type FeatureKey = keyof keyof Features extends never ? Record<string, boolean> : Features;

Functions

BucketProvider()

function BucketProvider(__namedParameters: BucketProps): Element

Parameters

Parameter
Type

__namedParameters

Returns

Element


useFeature()

function useFeature(key: string): 
  | {
  isEnabled: boolean;
  isLoading: true;
  requestFeedback: (opts: Omit<RequestFeedbackData, "featureId" | "featureKey">) => undefined | void;
  track: () => undefined | Promise<undefined | Response>;
 }
  | {
  isLoading: false;
  requestFeedback: (opts: Omit<RequestFeedbackData, "featureId" | "featureKey">) => undefined | void;
  track: () => undefined | Promise<undefined | Response>;
  get isEnabled: boolean;
}

Returns the state of a given feature for the current context, e.g.

function HuddleButton() {
  const {isEnabled, track} = useFeature("huddle");
  if (isEnabled) {
   return <button onClick={() => track()}>Start Huddle</button>;
  }
}

Parameters

Parameter
Type

key

string

Returns

| { isEnabled: boolean; isLoading: true; requestFeedback: (opts: Omit<RequestFeedbackData, "featureId" | "featureKey">) => undefined | void; track: () => undefined | Promise<undefined | Response>; } | { isLoading: false; requestFeedback: (opts: Omit<RequestFeedbackData, "featureId" | "featureKey">) => undefined | void; track: () => undefined | Promise<undefined | Response>; get isEnabled: boolean; }


useRequestFeedback()

function useRequestFeedback(): (options: RequestFeedbackData) => undefined | void

Returns a function to open up the feedback form Note: When calling useRequestFeedback, user/company must already be set.

See link for more information

const requestFeedback = useRequestFeedback();
bucket.requestFeedback({
  featureId: "bucket-feature-id",
  title: "How satisfied are you with file uploads?",
});

Returns

Function

Parameters

Parameter
Type

options

Returns

undefined | void


useSendFeedback()

function useSendFeedback(): (opts: UnassignedFeedback) => undefined | Promise<undefined | Response>

Returns a function to manually send feedback collected from a user. Note: When calling useSendFeedback, user/company must already be set.

See link for more information

const sendFeedback = useSendFeedback();
sendFeedback({
  featureId: "fe2323223";;
  question: "How did you like the new huddle feature?";
  score: 5;
  comment: "I loved it!";
});

Returns

Function

Parameters

Parameter
Type

opts

Returns

undefined | Promise<undefined | Response>


useTrack()

function useTrack(): (eventName: string, attributes?: null | Record<string, any>) => undefined | Promise<undefined | Response>

Returns a function to send an event when a user performs an action Note: When calling useTrack, user/company must already be set.

const track = useTrack();
track("Started Huddle", { button: "cta" });

Returns

Function

Parameters

Parameter
Type

eventName

string

attributes?

null | Record<string, any>

Returns

undefined | Promise<undefined | Response>


useUpdateCompany()

function useUpdateCompany(): (opts: {}) => undefined | Promise<void>

Returns a function to update the current company's information. For example, if the company changed plan or opted into a beta-feature.

The method returned is a function which returns a promise that resolves when after the features have been updated as a result of the company update.

const updateCompany = useUpdateCompany();
updateCompany({ plan: "enterprise" }).then(() => console.log("Features updated"));

#### Returns

`Function`

##### Parameters

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>

`opts`

</td>
<td>

\{\}

</td>
</tr>
</tbody>
</table>

##### Returns

`undefined` \| `Promise`\<`void`\>

***

### useUpdateOtherContext()

```ts
function useUpdateOtherContext(): (opts: {}) => undefined | Promise<void>

Returns a function to update the "other" context information. For example, if the user changed workspace, you can set the workspace id here.

The method returned is a function which returns a promise that resolves when after the features have been updated as a result of the update to the "other" context.

const updateOtherContext = useUpdateOtherContext();
updateOtherContext({ workspaceId: newWorkspaceId })
  .then(() => console.log("Features updated"));

#### Returns

`Function`

##### Parameters

<table>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>

`opts`

</td>
<td>

\{\}

</td>
</tr>
</tbody>
</table>

##### Returns

`undefined` \| `Promise`\<`void`\>

***

### useUpdateUser()

```ts
function useUpdateUser(): (opts: {}) => undefined | Promise<void>

Returns a function to update the current user's information. For example, if the user changed role or opted into a beta-feature.

The method returned is a function which returns a promise that resolves when after the features have been updated as a result of the user update.

const updateUser = useUpdateUser();
updateUser({ optInHuddles: "true" }).then(() => console.log("Features updated"));

Returns

Function

Parameters

Parameter
Type

opts

{}

Returns

undefined | Promise<void>

Last updated