Reference
Classes
BucketClient
BucketClient lets you interact with the Bucket API.
Constructors
new BucketClient()
Create a new BucketClient instance.
Parameters
opts
Returns
Properties
logger
readonly
Methods
feedback()
Submit user feedback to Bucket. Must include either score
or comment
, or both.
Parameters
payload
The feedback details to submit.
Returns
Promise
< | undefined
| Response
>
The server response.
getConfig()
Get the current configuration.
Returns
getFeature()
Return a feature. Accessing isEnabled
or config
will automatically send a check
event.
Parameters
key
string
Returns
A feature.
getFeatureOverride()
Internal
Parameters
key
string
Returns
null
| boolean
getFeatures()
Returns a map of enabled features. Accessing a feature will not send a check event and isEnabled
does not take any feature overrides into account.
Returns
Map of features.
initialize()
Initialize the Bucket SDK.
Must be called before calling other SDK methods.
Returns
Promise
<void
>
off()
Remove an event listener
Type Parameters
Parameters
type
THookType
Type of event to remove.
handler
The same function that was passed to on
.
Returns
void
A function to remove the hook.
on()
Add an event listener
Type Parameters
Parameters
type
THookType
Type of events to listen for
handler
The function to call when the event is triggered.
Returns
Function
A function to remove the hook.
Returns
void
requestFeedback()
Display the Bucket feedback form UI programmatically.
This can be used to collect feedback from users in Bucket in cases where Automated Feedback Surveys isn't appropriate.
Parameters
options
Returns
void
setFeatureOverride()
Internal
Parameters
key
string
isEnabled
null
| boolean
Returns
void
stop()
Stop the SDK. This will stop any automated feedback surveys.
Returns
Promise
<void
>
track()
Track an event in Bucket.
Parameters
eventName
string
The name of the event.
attributes
?
Any attributes you want to attach to the event.
Returns
Promise
< | undefined
| Response
>
updateCompany()
Update the company context. Performs a shallow merge with the existing company context. Attempting to update the company ID will log a warning and be ignored.
Parameters
company
{}
The company details.
Returns
Promise
<void
>
updateOtherContext()
Update the company context. Performs a shallow merge with the existing company context. Updates to the company ID will be ignored.
Parameters
otherContext
{}
Additional context.
Returns
Promise
<void
>
updateUser()
Update the user context. Performs a shallow merge with the existing user context. Attempting to update the user ID will log a warning and be ignored.
Parameters
user
{}
Returns
Promise
<void
>
Interfaces
BucketContext
Properties
company?
Company related context
otherContext?
Context which is not related to a user or a company
user?
User related context
CheckEvent
Event representing checking the feature flag evaluation result
Properties
action
"check-is-enabled"
| "check-config"
check-is-enabled
means isEnabled
was checked, check-config
means config
was checked.
key
string
Feature key.
missingContextFields?
string
[]
Missing context fields.
ruleEvaluationResults?
boolean
[]
Rule evaluation results.
value?
| boolean
| { key
: string
; payload
: any
; }
Result of feature flag or configuration evaluation. If action
is check-is-enabled
, this is the result of the feature flag evaluation and value
is a boolean. If action
is check-config
, this is the result of the configuration evaluation.
version?
number
Version of targeting rules.
CompanyContext
Context is a set of key-value pairs. Id should always be present so that it can be referenced to an existing company.
Indexable
Properties
id
undefined
| string
| number
Company id
name?
string
Company name
Config
BucketClient configuration.
Properties
apiBaseUrl
string
Base URL of Bucket servers.
appBaseUrl
string
Base URL of the Bucket web app.
enableTracking
boolean
Whether to enable tracking.
sseBaseUrl
string
Base URL of Bucket servers for SSE connections used by AutoFeedback.
Feature
Represents a feature.
Properties
config
‐
isEnabled
boolean
Result of feature flag evaluation.
requestFeedback
Function to request feedback for this feature.
track
Function to send analytics events for this feature.
FeedbackScoreSubmission
Properties
feedbackId?
string
question
string
score
number
FeedbackSubmission
Properties
comment
string
feedbackId?
string
question
string
score
number
HookArgs
Properties
check
‐
company
‐
configCheck
Deprecated: Use check
instead.
Deprecated
enabledCheck
Deprecated: Use check
instead.
Deprecated
featuresUpdated
‐
track
‐
user
‐
Logger
Methods
debug()
Parameters
message
string
...args
any
[]
Returns
void
error()
Parameters
message
string
...args
any
[]
Returns
void
info()
Parameters
message
string
...args
any
[]
Returns
void
warn()
Parameters
message
string
...args
any
[]
Returns
void
OnScoreSubmitResult
Properties
feedbackId
string
OpenFeedbackFormOptions
Properties
key
string
‐
onClose?
() => void
‐
onDismiss?
() => void
‐
onScoreSubmit?
‐
onSubmit
‐
openWithCommentVisible?
boolean
Open the form with both the score and comment fields visible. Defaults to false
position?
Control the placement and behavior of the feedback form.
title?
string
‐
translations?
Add your own custom translations for the feedback form. Undefined translation keys fall back to english defaults.
ToolbarPosition
Properties
offset?
placement
UserContext
Indexable
Properties
email?
string
User email
id
undefined
| string
| number
User id
name?
string
User name
Type Aliases
DialogPlacement
FallbackFeatureOverride
FeatureRemoteConfig
A remotely managed configuration value for a feature.
Type declaration
{ key
: string
; payload
: any
; }
key
string
The key of the matched configuration value.
payload
any
The optional user-supplied payload data.
{ key
: undefined
; payload
: undefined
; }
key
undefined
payload
undefined
Feedback
Type declaration
companyId
?
string
Company ID from your own application.
userId
?
string
User ID from your own application.
FeedbackOptions
Type declaration
autoFeedbackHandler
?
‐
enableAutoFeedback
?
boolean
Enables automatic feedback prompting if it's set up in Bucket
ui
?
With these options you can override the look of the feedback prompt
ui.position
?
Control the placement and behavior of the feedback form.
ui.translations
?
Add your own custom translations for the feedback form. Undefined translation keys fall back to english defaults.
FeedbackPrompt
Type declaration
featureId
string
Feature ID from Bucket
promptId
string
Id of the prompt
question
string
Specific question user was asked
showAfter
Feedback prompt should appear only after this time
showBefore
Feedback prompt will not be shown after this time
FeedbackPromptHandler()
Parameters
prompt
handlers
Returns
void
FeedbackPromptHandlerCallbacks
Type declaration
openFeedbackForm
reply
FeedbackPromptHandlerOpenFeedbackFormOptions
FeedbackPromptReply
Type declaration
comment
?
string
companyId
?
string
question
string
score
?
number
FeedbackPromptReplyHandler()
Type Parameters
Parameters
reply
T
Returns
T
extends null
? Promise
<void
> : Promise
<{ feedbackId
: string
; }>
FeedbackTranslations
You can use this to override text values in the feedback form with desired language translation
Type declaration
DefaultQuestionLabel
string
QuestionPlaceholder
string
ScoreDissatisfiedLabel
string
ScoreNeutralLabel
string
ScoreSatisfiedLabel
string
ScoreStatusDescription
string
ScoreStatusLoading
string
ScoreStatusReceived
string
ScoreVeryDissatisfiedLabel
string
ScoreVerySatisfiedLabel
string
SendButton
string
SuccessMessage
string
FetchedFeature
A feature fetched from the server.
Type declaration
config
?
{ key
: string
; missingContextFields
: string
[]; payload
: any
; ruleEvaluationResults
: boolean
[]; version
: number
; }
Optional user-defined dynamic configuration.
config.key
string
The key of the matched configuration value.
config.missingContextFields
?
string
[]
The missing context fields.
config.payload
?
any
The optional user-supplied payload data.
config.ruleEvaluationResults
?
boolean
[]
The rule evaluation results.
config.version
?
number
The version of the matched configuration value.
isEnabled
boolean
Result of feature flag evaluation. Note: does not take local overrides into account.
key
string
Feature key.
missingContextFields
?
string
[]
Missing context fields.
ruleEvaluationResults
?
boolean
[]
Rule evaluation results.
targetingVersion
?
number
Version of targeting rules.
InitOptions
BucketClient initialization options.
Type declaration
apiBaseUrl
?
string
Base URL of Bucket servers. You can override this to use your mocked server.
appBaseUrl
?
string
Base URL of the Bucket web app. Links open ín this app by default.
company
?
Company related context. If you provide id
Bucket will enrich the evaluation context with company attributes on Bucket servers.
credentials
?
"include"
| "same-origin"
| "omit"
When proxying requests, you may want to include credentials like cookies so you can authorize the request in the proxy. This option controls the credentials
option of the fetch API.
enableTracking
?
boolean
Whether to enable tracking. Defaults to true
.
expireTimeMs
?
number
If set, features will be cached between page loads for this duration
fallbackFeatures
?
Feature keys for which isEnabled
should fallback to true if SDK fails to fetch features from Bucket servers. If a record is supplied instead of array, the values of each key represent the configuration values and isEnabled
is assume true
.
feedback
?
AutoFeedback specific configuration
logger
?
You can provide a logger to see the logs of the network calls. This is undefined by default. For debugging purposes you can just set the browser console to this property:
otherContext
?
Context not related to users or companies
publishableKey
string
Publishable key for authentication
sdkVersion
?
string
Version of the SDK
sseBaseUrl
?
string
Base URL of Bucket servers for SSE connections used by AutoFeedback.
staleTimeMs
?
number
Stale features will be returned if staleWhileRevalidate is true if no new features can be fetched
staleWhileRevalidate
?
boolean
If set to true stale features will be returned while refetching features
timeoutMs
?
number
Timeout in milliseconds when fetching features
toolbar
?
Toolbar configuration
user
?
User related context. If you provide id
Bucket will enrich the evaluation context with user attributes on Bucket servers.
Offset
Type declaration
x
?
string
| number
Offset from the nearest horizontal screen edge after placement is resolved
y
?
string
| number
Offset from the nearest vertical screen edge after placement is resolved
PopoverPlacement
Position
RawFeature
Type declaration
isEnabledOverride
boolean
| null
If not null, the result is being overridden locally
RawFeatures
RequestFeedbackData
Type declaration
companyId
?
string
Company ID from your own application.
featureKey
string
Bucket feature key.
onAfterSubmit
?
Allows you to handle a copy of the already submitted feedback.
This can be used for side effects, such as storing a copy of the feedback in your own application or CRM.
RequestFeedbackOptions
Type declaration
userId
string
User ID from your own application.
ToolbarOptions
Toolbar options.
TrackEvent
Type declaration
attributes
?
company
?
eventName
string
user
UnassignedFeedback
Type declaration
comment
?
string
User supplied comment about your feature.
featureKey
string
Bucket feature key.
feedbackId
?
string
Bucket feedback ID
promptedQuestion
?
string
The original question. This only needs to be populated if the feedback was submitted through the automated feedback surveys channel.
promptId
?
string
Bucket feedback prompt ID.
This only exists if the feedback was submitted as part of an automated prompt from Bucket.
Used for internal state management of automated feedback.
question
?
string
The question that was presented to the user.
score
?
number
Customer satisfaction score.
source
?
"prompt"
| "sdk"
| "widget"
Source of the feedback, depending on how the user was asked
prompt
- Feedback submitted by way of an automated feedback survey (prompted)widget
- Feedback submitted viarequestFeedback
sdk
- Feedback submitted viafeedback
Variables
DEFAULT_TRANSLATIONS
feedbackContainerId
ID of HTML DIV element which contains the feedback dialog
propagatedEvents
These events will be propagated to the feedback dialog
See
https://developer.mozilla.org/en-US/docs/Web/API/Element#events
Last updated
Was this helpful?