@bucketco/browser-sdk
Advanced tools
Comparing version 2.5.0 to 2.5.1
import { CheckEvent, FeaturesOptions, RawFeatures } from './feature/features'; | ||
import { Feedback, FeedbackOptions as FeedbackOptions, RequestFeedbackData } from './feedback/feedback'; | ||
import { Feedback, FeedbackOptions, RequestFeedbackData } from './feedback/feedback'; | ||
import { CompanyContext, UserContext } from './context'; | ||
@@ -7,3 +7,9 @@ import { Logger } from './logger'; | ||
export type User = { | ||
/** | ||
* Identifier of the user | ||
*/ | ||
userId: string; | ||
/** | ||
* User attributes | ||
*/ | ||
attributes?: { | ||
@@ -16,4 +22,13 @@ name?: string; | ||
export type Company = { | ||
/** | ||
* User identifier | ||
*/ | ||
userId: string; | ||
/** | ||
* Company identifier | ||
*/ | ||
companyId: string; | ||
/** | ||
* Company attributes | ||
*/ | ||
attributes?: { | ||
@@ -26,5 +41,17 @@ name?: string; | ||
export type TrackedEvent = { | ||
/** | ||
* Event name | ||
*/ | ||
event: string; | ||
/** | ||
* User identifier | ||
*/ | ||
userId: string; | ||
/** | ||
* Company identifier | ||
*/ | ||
companyId?: string; | ||
/** | ||
* Event attributes | ||
*/ | ||
attributes?: Record<string, any>; | ||
@@ -36,7 +63,30 @@ context?: PayloadContext; | ||
}; | ||
/** | ||
* BucketClient initialization options. | ||
*/ | ||
export interface InitOptions { | ||
/** | ||
* Publishable key for authentication | ||
*/ | ||
publishableKey: string; | ||
/** | ||
* User related context. If you provide `id` Bucket will enrich the evaluation context with user attributes on Bucket servers. | ||
*/ | ||
user?: UserContext; | ||
/** | ||
* Company related context. If you provide `id` Bucket will enrich the evaluation context with company attributes on Bucket servers. | ||
*/ | ||
company?: CompanyContext; | ||
/** | ||
* Context not related to users or companies | ||
*/ | ||
otherContext?: Record<string, any>; | ||
/** | ||
* 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: | ||
* ```javascript | ||
* options.logger = window.console; | ||
* ``` | ||
*/ | ||
logger?: Logger; | ||
@@ -48,2 +98,5 @@ /** | ||
host?: string; | ||
/** | ||
* Base URL of Bucket servers. You can override this to use your mocked server. | ||
*/ | ||
apiBaseUrl?: string; | ||
@@ -55,5 +108,17 @@ /** | ||
sseHost?: string; | ||
/** | ||
* Base URL of Bucket servers for SSE connections used by AutoFeedback. | ||
*/ | ||
sseBaseUrl?: string; | ||
/** | ||
* AutoFeedback specific configuration | ||
*/ | ||
feedback?: FeedbackOptions; | ||
/** | ||
* Feature flag specific configuration | ||
*/ | ||
features?: FeaturesOptions; | ||
/** | ||
* Version of the SDK | ||
*/ | ||
sdkVersion?: string; | ||
@@ -63,6 +128,17 @@ enableTracking?: boolean; | ||
export interface Feature { | ||
/** | ||
* Result of feature flag evaluation | ||
*/ | ||
isEnabled: boolean; | ||
/** | ||
* Function to send analytics events for this feature | ||
* | ||
*/ | ||
track: () => Promise<Response | undefined>; | ||
requestFeedback: (options: Omit<RequestFeedbackData, "featureKey" | "featureId">) => void; | ||
} | ||
/** | ||
* BucketClient lets you interact with the Bucket API. | ||
* | ||
*/ | ||
export declare class BucketClient { | ||
@@ -73,3 +149,2 @@ private publishableKey; | ||
private requestFeedbackOptions; | ||
private logger; | ||
private httpClient; | ||
@@ -79,2 +154,6 @@ private autoFeedback; | ||
private featuresClient; | ||
readonly logger: Logger; | ||
/** | ||
* Create a new BucketClient instance. | ||
*/ | ||
constructor(opts: InitOptions); | ||
@@ -89,3 +168,3 @@ /** | ||
* Update the user context. | ||
* @description Performs a shallow merge with the existing user context. | ||
* Performs a shallow merge with the existing user context. | ||
* Attempting to update the user ID will log a warning and be ignored. | ||
@@ -112,4 +191,2 @@ * | ||
* Updates to the company ID will be ignored. | ||
* | ||
* @param company | ||
*/ | ||
@@ -125,4 +202,3 @@ updateOtherContext(otherContext: { | ||
* | ||
* @param callback this will be called when the features are updated. | ||
* @param options passed as-is to addEventListener | ||
* @param cb this will be called when the features are updated. | ||
*/ | ||
@@ -141,3 +217,2 @@ onFeaturesUpdated(cb: () => void): () => void; | ||
* @returns | ||
* @param payload | ||
*/ | ||
@@ -183,1 +258,2 @@ feedback(payload: Feedback): Promise<Response | undefined>; | ||
} | ||
//# sourceMappingURL=client.d.ts.map |
@@ -6,1 +6,2 @@ export declare const API_BASE_URL = "https://front.bucket.co"; | ||
export declare const FEATURE_EVENTS_PER_MIN = 1; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -0,16 +1,51 @@ | ||
/** | ||
* Context is a set of key-value pairs. | ||
* Id should always be present so that it can be referenced to an existing company. | ||
*/ | ||
export interface CompanyContext { | ||
/** | ||
* Company id | ||
*/ | ||
id: string | number | undefined; | ||
/** | ||
* Company name | ||
*/ | ||
name?: string | undefined; | ||
/** | ||
* Other company attributes | ||
*/ | ||
[key: string]: string | number | undefined; | ||
} | ||
export interface UserContext { | ||
/** | ||
* User id | ||
*/ | ||
id: string | number | undefined; | ||
/** | ||
* User name | ||
*/ | ||
name?: string | undefined; | ||
/** | ||
* User email | ||
*/ | ||
email?: string | undefined; | ||
/** | ||
* Other user attributes | ||
*/ | ||
[key: string]: string | number | undefined; | ||
} | ||
export interface BucketContext { | ||
/** | ||
* Company related context | ||
*/ | ||
company?: CompanyContext; | ||
/** | ||
* User related context | ||
*/ | ||
user?: UserContext; | ||
/** | ||
* Context which is not related to a user or a company | ||
*/ | ||
otherContext?: Record<string, string | number | undefined>; | ||
} | ||
//# sourceMappingURL=context.d.ts.map |
@@ -34,1 +34,2 @@ import { RawFeatures } from './features'; | ||
export {}; | ||
//# sourceMappingURL=featureCache.d.ts.map |
@@ -7,4 +7,13 @@ import { HttpClient } from '../httpClient'; | ||
export type RawFeature = { | ||
/** | ||
* Feature key | ||
*/ | ||
key: string; | ||
/** | ||
* Result of feature flag evaluation | ||
*/ | ||
isEnabled: boolean; | ||
/** | ||
* Version of targeting rules | ||
*/ | ||
targetingVersion?: number; | ||
@@ -14,4 +23,15 @@ }; | ||
export type FeaturesOptions = { | ||
/** | ||
* Feature keys for which `isEnabled` should fallback to true | ||
* if SDK fails to fetch features from Bucket servers. | ||
*/ | ||
fallbackFeatures?: string[]; | ||
/** | ||
* Timeout in miliseconds | ||
*/ | ||
timeoutMs?: number; | ||
/** | ||
* If set to true client will return cached value when its stale | ||
* but refetching | ||
*/ | ||
staleWhileRevalidate?: boolean; | ||
@@ -28,3 +48,9 @@ staleTimeMs?: number; | ||
export type FeaturesResponse = { | ||
/** | ||
* `true` if call was successful | ||
*/ | ||
success: boolean; | ||
/** | ||
* List of enabled features | ||
*/ | ||
features: RawFeatures; | ||
@@ -37,5 +63,17 @@ }; | ||
export declare function flattenJSON(obj: Record<string, any>): Record<string, any>; | ||
/** | ||
* Event representing checking the feature flag evaluation result | ||
*/ | ||
export interface CheckEvent { | ||
/** | ||
* Feature key | ||
*/ | ||
key: string; | ||
/** | ||
* Result of feature flag evaluation | ||
*/ | ||
value: boolean; | ||
/** | ||
* Version of targeting rules | ||
*/ | ||
version?: number; | ||
@@ -49,2 +87,5 @@ } | ||
export declare const FEATURES_EXPIRE_MS: number; | ||
/** | ||
* @internal | ||
*/ | ||
export declare class FeaturesClient { | ||
@@ -93,1 +134,2 @@ private httpClient; | ||
export {}; | ||
//# sourceMappingURL=features.d.ts.map |
@@ -8,4 +8,13 @@ import { HttpClient } from '../httpClient'; | ||
export type FeedbackOptions = { | ||
/** | ||
* Enables automatic feedback prompting if it's set up in Bucket | ||
*/ | ||
enableAutoFeedback?: boolean; | ||
/** | ||
* | ||
*/ | ||
autoFeedbackHandler?: FeedbackPromptHandler; | ||
/** | ||
* With these options you can override the look of the feedback prompt | ||
*/ | ||
ui?: { | ||
@@ -22,7 +31,13 @@ /** | ||
}; | ||
/** | ||
* @deprecated Use `enableAutoFeedback` instead | ||
*/ | ||
enableLiveSatisfaction?: boolean; | ||
/** | ||
* @deprecated Use `autoFeedbackHandler` instead | ||
*/ | ||
liveSatisfactionHandler?: FeedbackPromptHandler; | ||
}; | ||
export declare function handleDeprecatedFeedbackOptions(opts?: FeedbackOptions): FeedbackOptions; | ||
type FeatureIdentifier = { | ||
export type FeatureIdentifier = { | ||
/** | ||
@@ -51,5 +66,2 @@ * Bucket feature ID. | ||
* copy of the feedback in your own application or CRM. | ||
* | ||
* @param {Object} data | ||
* @param data. | ||
*/ | ||
@@ -115,6 +127,21 @@ onAfterSubmit?: (data: FeedbackSubmission) => void; | ||
export type FeedbackPrompt = { | ||
/** | ||
* Specific question user was asked | ||
*/ | ||
question: string; | ||
/** | ||
* Feedback prompt should appear only after this time | ||
*/ | ||
showAfter: Date; | ||
/** | ||
* Feedback prompt will not be shown after this time | ||
*/ | ||
showBefore: Date; | ||
/** | ||
* Id of the prompt | ||
*/ | ||
promptId: string; | ||
/** | ||
* Feature ID from Bucket | ||
*/ | ||
featureId: string; | ||
@@ -172,2 +199,2 @@ }; | ||
} | ||
export {}; | ||
//# sourceMappingURL=feedback.d.ts.map |
@@ -7,1 +7,2 @@ import { FeedbackPrompt } from './feedback'; | ||
export declare const processPromptMessage: (userId: string, prompt: FeedbackPrompt, displayHandler: FeedbackPromptDisplayHandler) => boolean; | ||
//# sourceMappingURL=prompts.d.ts.map |
@@ -9,1 +9,2 @@ export declare const markPromptMessageCompleted: (userId: string, promptId: string, expiresAt: Date) => void; | ||
export declare const forgetAuthToken: (userId: string) => void; | ||
//# sourceMappingURL=promptStorage.d.ts.map |
@@ -7,1 +7,2 @@ import { FunctionComponent, h } from 'preact'; | ||
export declare const Button: FunctionComponent<ButtonProps>; | ||
//# sourceMappingURL=Button.d.ts.map |
import { FeedbackTranslations } from '../types'; | ||
/** | ||
* {@includeCode ./defaultTranslations.tsx} | ||
*/ | ||
export declare const DEFAULT_TRANSLATIONS: FeedbackTranslations; | ||
//# sourceMappingURL=defaultTranslations.d.ts.map |
@@ -0,2 +1,11 @@ | ||
/** | ||
* ID of HTML DIV element which contains the feedback dialog | ||
*/ | ||
export declare const feedbackContainerId = "bucket-feedback-dialog-container"; | ||
/** | ||
* These events will be propagated to the feedback dialog | ||
* | ||
* @see [https://developer.mozilla.org/en-US/docs/Web/API/Element#events](https://developer.mozilla.org/en-US/docs/Web/API/Element#events) | ||
*/ | ||
export declare const propagatedEvents: string[]; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -6,1 +6,2 @@ import { FunctionComponent } from 'preact'; | ||
export declare const FeedbackDialog: FunctionComponent<FeedbackDialogProps>; | ||
//# sourceMappingURL=FeedbackDialog.d.ts.map |
@@ -15,1 +15,2 @@ import { FunctionComponent } from 'preact'; | ||
export {}; | ||
//# sourceMappingURL=FeedbackForm.d.ts.map |
@@ -14,1 +14,2 @@ export declare const useTimer: ({ initialDuration, enabled, onEnd, }: { | ||
}; | ||
//# sourceMappingURL=useTimer.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Check: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Check.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const CheckCircle: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=CheckCircle.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Close: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Close.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Dissatisfied: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Dissatisfied.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Logo: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Logo.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Neutral: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Neutral.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const Satisfied: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=Satisfied.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const VeryDissatisfied: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=VeryDissatisfied.d.ts.map |
import { FunctionComponent, h } from 'preact'; | ||
export declare const VerySatisfied: FunctionComponent<h.JSX.SVGAttributes<SVGSVGElement>>; | ||
//# sourceMappingURL=VerySatisfied.d.ts.map |
@@ -5,1 +5,2 @@ import { FeedbackPosition, OpenFeedbackFormOptions } from './types'; | ||
export declare function openFeedbackForm(options: OpenFeedbackFormOptions): void; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -25,1 +25,2 @@ import { Middleware, Padding } from '@floating-ui/core'; | ||
export declare const arrow: (options: Options | ((state: MiddlewareState) => Options)) => Middleware; | ||
//# sourceMappingURL=arrow.d.ts.map |
export { arrow } from './arrow'; | ||
export { useFloating } from './useFloating'; | ||
export { autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size, } from '@floating-ui/dom'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -73,1 +73,2 @@ import { ComputePositionConfig, ComputePositionReturn, VirtualElement } from '@floating-ui/dom'; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -8,1 +8,2 @@ import { ReferenceType, UseFloatingOptions, UseFloatingReturn } from './types'; | ||
export declare function useFloating<RT extends ReferenceType = ReferenceType>(options?: UseFloatingOptions): UseFloatingReturn<RT>; | ||
//# sourceMappingURL=useFloating.d.ts.map |
export declare function deepEqual(a: any, b: any): boolean; | ||
//# sourceMappingURL=deepEqual.d.ts.map |
export declare function getDPR(element: Element): number; | ||
//# sourceMappingURL=getDPR.d.ts.map |
export declare function roundByDPR(element: Element, value: number): number; | ||
//# sourceMappingURL=roundByDPR.d.ts.map |
export declare function useLatestRef<T>(value: T): import('preact/hooks').MutableRef<T>; | ||
//# sourceMappingURL=useLatestRef.d.ts.map |
import { FunctionComponent } from 'preact'; | ||
export declare const Plug: FunctionComponent; | ||
//# sourceMappingURL=Plug.d.ts.map |
@@ -7,1 +7,2 @@ import { FunctionComponent } from 'preact'; | ||
}>; | ||
//# sourceMappingURL=RadialProgress.d.ts.map |
@@ -11,1 +11,2 @@ import { FunctionComponent, h } from 'preact'; | ||
export declare const StarRating: FunctionComponent<StarRatingProps>; | ||
//# sourceMappingURL=StarRating.d.ts.map |
@@ -61,3 +61,10 @@ export type WithRequired<T, K extends keyof T> = T & { | ||
} | ||
/** | ||
* You can use this to override text values in the feedback form | ||
* with desired language translation | ||
*/ | ||
export type FeedbackTranslations = { | ||
/** | ||
* | ||
*/ | ||
DefaultQuestionLabel: string; | ||
@@ -76,1 +83,2 @@ QuestionPlaceholder: string; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -22,1 +22,2 @@ export interface HttpClientOptions { | ||
} | ||
//# sourceMappingURL=httpClient.d.ts.map |
@@ -5,5 +5,7 @@ export type { Feature, InitOptions } from './client'; | ||
export type { CheckEvent, FeaturesOptions, RawFeature, RawFeatures, } from './feature/features'; | ||
export type { Feedback, FeedbackOptions, RequestFeedbackData, RequestFeedbackOptions, UnassignedFeedback, } from './feedback/feedback'; | ||
export type { FeatureIdentifier, Feedback, FeedbackOptions, FeedbackPrompt, FeedbackPromptHandler, FeedbackPromptHandlerCallbacks, FeedbackPromptHandlerOpenFeedbackFormOptions, FeedbackPromptReply, FeedbackPromptReplyHandler, RequestFeedbackData, RequestFeedbackOptions, UnassignedFeedback, } from './feedback/feedback'; | ||
export type { DEFAULT_TRANSLATIONS } from './feedback/ui/config/defaultTranslations'; | ||
export { feedbackContainerId, propagatedEvents } from './feedback/ui/constants'; | ||
export type { FeedbackTranslations } from './feedback/ui/types'; | ||
export type { FeedbackPlacement, FeedbackPosition, FeedbackScoreSubmission, FeedbackSubmission, FeedbackTranslations, Offset, OnScoreSubmitResult, OpenFeedbackFormOptions, } from './feedback/ui/types'; | ||
export type { Logger } from './logger'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -14,1 +14,2 @@ export interface Logger { | ||
export declare function loggerWithPrefix(logger: Logger, prefix: string): Logger; | ||
//# sourceMappingURL=logger.d.ts.map |
@@ -10,1 +10,2 @@ import { Logger } from './logger'; | ||
} | ||
//# sourceMappingURL=rateLimiter.d.ts.map |
@@ -39,1 +39,2 @@ import { HttpClient } from './httpClient'; | ||
export declare function closeAblySSEChannel(channel: AblySSEChannel): void; | ||
//# sourceMappingURL=sse.d.ts.map |
export {}; | ||
//# sourceMappingURL=client.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=acceptance.browser.spec.d.ts.map |
@@ -7,1 +7,2 @@ declare global { | ||
export {}; | ||
//# sourceMappingURL=feedback-widget.browser.spec.d.ts.map |
@@ -9,1 +9,2 @@ import { FeatureCache } from '../src/feature/featureCache'; | ||
}; | ||
//# sourceMappingURL=featureCache.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=features.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=httpClient.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=init.test.d.ts.map |
@@ -12,1 +12,2 @@ import { DefaultBodyType, HttpResponse, StrictRequest } from 'msw'; | ||
export declare const handlers: import('msw').HttpHandler[]; | ||
//# sourceMappingURL=handlers.d.ts.map |
export declare const server: import('msw/node').SetupServerApi; | ||
//# sourceMappingURL=server.d.ts.map |
export {}; | ||
//# sourceMappingURL=prompts.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=promptStorage.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=rateLimiter.test.d.ts.map |
export {}; | ||
//# sourceMappingURL=sse.test.d.ts.map |
@@ -8,1 +8,2 @@ export declare const testLogger: { | ||
}; | ||
//# sourceMappingURL=testLogger.d.ts.map |
export {}; | ||
//# sourceMappingURL=usage.test.d.ts.map |
{ | ||
"name": "@bucketco/browser-sdk", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"packageManager": "yarn@4.1.1", | ||
@@ -67,3 +67,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "75e512992a98b5a8ffad702b2cf483ee5215e436" | ||
"gitHead": "d0e75be197e6af3d1c626162732054a3a4298ce0" | ||
} |
@@ -56,3 +56,3 @@ # Bucket Browser SDK | ||
See [example/browser.html](example/browser.html) for a working example: | ||
See [example/browser.html](https://github.com/bucketco/bucket-javascript-sdk/tree/main/packages/browser-sdk/example/browser.html) for a working example: | ||
@@ -59,0 +59,0 @@ ```html |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
972063
121
5088