@bucketco/browser-sdk
Advanced tools
Comparing version 2.5.1 to 3.0.0-alpha.0
import { CheckEvent, FeaturesOptions, RawFeatures } from './feature/features'; | ||
import { Feedback, FeedbackOptions, RequestFeedbackData } from './feedback/feedback'; | ||
import { ToolbarPosition } from './toolbar/Toolbar'; | ||
import { CompanyContext, UserContext } from './context'; | ||
@@ -60,2 +61,13 @@ import { Logger } from './logger'; | ||
}; | ||
interface Config { | ||
apiBaseUrl: string; | ||
appBaseUrl: string; | ||
sseBaseUrl: string; | ||
enableTracking: boolean; | ||
} | ||
export type ToolbarOptions = boolean | { | ||
show?: boolean; | ||
position?: ToolbarPosition; | ||
}; | ||
export type FeatureDefinitions = Readonly<Array<string>>; | ||
/** | ||
@@ -100,2 +112,6 @@ * BucketClient initialization options. | ||
/** | ||
* Base URL of the Bucket web app. Links open ín this app by default. | ||
*/ | ||
appBaseUrl?: string; | ||
/** | ||
* @deprecated | ||
@@ -122,2 +138,12 @@ * Use `sseBaseUrl` instead. | ||
enableTracking?: boolean; | ||
/** | ||
* Toolbar configuration (alpha) | ||
* @ignore | ||
*/ | ||
toolbar?: ToolbarOptions; | ||
/** | ||
* Local-first definition of features (alpha) | ||
* @ignore | ||
*/ | ||
featureList?: FeatureDefinitions; | ||
} | ||
@@ -161,2 +187,6 @@ export interface Feature { | ||
/** | ||
* Get the current configuration. | ||
*/ | ||
getConfig(): Config; | ||
/** | ||
* Update the user context. | ||
@@ -222,2 +252,4 @@ * Performs a shallow merge with the existing user context. | ||
* Accessing a feature will *not* send a check event | ||
* and `isEnabled` does not take any feature overrides | ||
* into account. | ||
* | ||
@@ -232,2 +264,4 @@ * @returns Map of features | ||
getFeature(key: string): Feature; | ||
setFeatureOverride(key: string, isEnabled: boolean | null): void; | ||
getFeatureOverride(key: string): boolean | null; | ||
sendCheckEvent(checkEvent: CheckEvent): Promise<boolean>; | ||
@@ -251,2 +285,3 @@ /** | ||
} | ||
export {}; | ||
//# sourceMappingURL=client.d.ts.map |
export declare const API_BASE_URL = "https://front.bucket.co"; | ||
export declare const APP_BASE_URL = "https://app.bucket.co"; | ||
export declare const SSE_REALTIME_BASE_URL = "https://livemessaging.bucket.co"; | ||
@@ -3,0 +4,0 @@ export declare const SDK_VERSION_HEADER_NAME = "bucket-sdk-version"; |
@@ -1,2 +0,2 @@ | ||
import { RawFeatures } from './features'; | ||
import { FetchedFeatures } from './features'; | ||
@@ -10,7 +10,7 @@ interface StorageItem { | ||
staleAt: number; | ||
features: RawFeatures; | ||
features: FetchedFeatures; | ||
} | ||
export declare function parseAPIFeaturesResponse(featuresInput: any): RawFeatures | undefined; | ||
export declare function parseAPIFeaturesResponse(featuresInput: any): FetchedFeatures | undefined; | ||
export interface CacheResult { | ||
features: RawFeatures; | ||
features: FetchedFeatures; | ||
stale: boolean; | ||
@@ -28,3 +28,3 @@ } | ||
set(key: string, { features, }: { | ||
features: RawFeatures; | ||
features: FetchedFeatures; | ||
}): CacheData; | ||
@@ -31,0 +31,0 @@ get(key: string): CacheResult | undefined; |
@@ -6,3 +6,3 @@ import { HttpClient } from '../httpClient'; | ||
export type RawFeature = { | ||
export type FetchedFeature = { | ||
/** | ||
@@ -21,3 +21,10 @@ * Feature key | ||
}; | ||
export type RawFeatures = Record<string, RawFeature | undefined>; | ||
export type FetchedFeatures = Record<string, FetchedFeature | undefined>; | ||
export type RawFeature = FetchedFeature & { | ||
/** | ||
* If not null, the result is being overridden locally | ||
*/ | ||
isEnabledOverride: boolean | null; | ||
}; | ||
export type RawFeatures = Record<string, RawFeature>; | ||
export type FeaturesOptions = { | ||
@@ -30,12 +37,17 @@ /** | ||
/** | ||
* Timeout in miliseconds | ||
* Timeout in milliseconds when fetching features | ||
*/ | ||
timeoutMs?: number; | ||
/** | ||
* If set to true client will return cached value when its stale | ||
* but refetching | ||
* If set to true stale features will be returned while refetching features | ||
*/ | ||
staleWhileRevalidate?: boolean; | ||
/** | ||
* If set, features will be cached between page loads for this duration | ||
*/ | ||
expireTimeMs?: number; | ||
/** | ||
* Stale features will be returned if staleWhileRevalidate is true if no new features can be fetched | ||
*/ | ||
staleTimeMs?: number; | ||
expireTimeMs?: number; | ||
}; | ||
@@ -56,7 +68,7 @@ type Config = { | ||
*/ | ||
features: RawFeatures; | ||
features: FetchedFeatures; | ||
}; | ||
export declare function validateFeaturesResponse(response: any): { | ||
success: any; | ||
features: RawFeatures; | ||
features: FetchedFeatures; | ||
} | undefined; | ||
@@ -93,3 +105,6 @@ export declare function flattenJSON(obj: Record<string, any>): Record<string, any>; | ||
private context; | ||
private featureDefinitions; | ||
private cache; | ||
private fetchedFeatures; | ||
private featureOverrides; | ||
private features; | ||
@@ -101,3 +116,3 @@ private config; | ||
private abortController; | ||
constructor(httpClient: HttpClient, context: context, logger: Logger, options?: FeaturesOptions & { | ||
constructor(httpClient: HttpClient, context: context, featureDefinitions: Readonly<string[]>, logger: Logger, options?: FeaturesOptions & { | ||
cache?: FeatureCache; | ||
@@ -122,3 +137,4 @@ rateLimiter?: RateLimiter; | ||
getFeatures(): RawFeatures; | ||
fetchFeatures(): Promise<RawFeatures | undefined>; | ||
getFetchedFeatures(): FetchedFeatures; | ||
fetchFeatures(): Promise<FetchedFeatures | undefined>; | ||
/** | ||
@@ -131,7 +147,10 @@ * Send a feature "check" event. | ||
sendCheckEvent(checkEvent: CheckEvent): Promise<boolean>; | ||
private setFeatures; | ||
private triggerFeaturesChanged; | ||
private setFetchedFeatures; | ||
private fetchParams; | ||
private maybeFetchFeatures; | ||
setFeatureOverride(key: string, isEnabled: boolean | null): void; | ||
getFeatureOverride(key: string): boolean | null; | ||
} | ||
export {}; | ||
//# sourceMappingURL=features.d.ts.map |
import { HttpClient } from '../httpClient'; | ||
import { Logger } from '../logger'; | ||
import { FeedbackPosition, FeedbackSubmission, FeedbackTranslations, OpenFeedbackFormOptions } from './ui/types'; | ||
import { Position } from '../ui/types'; | ||
import { FeedbackSubmission, FeedbackTranslations, OpenFeedbackFormOptions } from './ui/types'; | ||
import { FeedbackPromptCompletionHandler } from './prompts'; | ||
@@ -23,3 +24,3 @@ | ||
*/ | ||
position?: FeedbackPosition; | ||
position?: Position; | ||
/** | ||
@@ -41,3 +42,3 @@ * Add your own custom translations for the feedback form. | ||
export declare function handleDeprecatedFeedbackOptions(opts?: FeedbackOptions): FeedbackOptions; | ||
export type FeatureIdentifier = { | ||
type FeatureIdentifier = { | ||
/** | ||
@@ -66,2 +67,5 @@ * Bucket feature ID. | ||
* copy of the feedback in your own application or CRM. | ||
* | ||
* @param {Object} data | ||
* @param data. | ||
*/ | ||
@@ -166,3 +170,3 @@ onAfterSubmit?: (data: FeedbackSubmission) => void; | ||
promptHandler: FeedbackPromptHandler; | ||
feedbackPosition: FeedbackPosition; | ||
feedbackPosition: Position; | ||
translations: {}; | ||
@@ -182,3 +186,3 @@ autoFeedbackEnabled: boolean; | ||
private sseChannel; | ||
constructor(sseBaseUrl: string, logger: Logger, httpClient: HttpClient, feedbackPromptHandler: FeedbackPromptHandler, userId: string, position?: FeedbackPosition, feedbackTranslations?: Partial<FeedbackTranslations>); | ||
constructor(sseBaseUrl: string, logger: Logger, httpClient: HttpClient, feedbackPromptHandler: FeedbackPromptHandler, userId: string, position?: Position, feedbackTranslations?: Partial<FeedbackTranslations>); | ||
/** | ||
@@ -200,2 +204,3 @@ * Start receiving automated feedback surveys. | ||
} | ||
export {}; | ||
//# sourceMappingURL=feedback.d.ts.map |
@@ -1,5 +0,6 @@ | ||
import { FeedbackPosition, OpenFeedbackFormOptions } from './types'; | ||
import { Position } from '../../ui/types'; | ||
import { OpenFeedbackFormOptions } from './types'; | ||
export declare const DEFAULT_POSITION: FeedbackPosition; | ||
export declare const DEFAULT_POSITION: Position; | ||
export declare function openFeedbackForm(options: OpenFeedbackFormOptions): void; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,25 +1,6 @@ | ||
import { Position } from '../../ui/types'; | ||
export type WithRequired<T, K extends keyof T> = T & { | ||
[P in K]-?: T[P]; | ||
}; | ||
export type FeedbackPlacement = "bottom-right" | "bottom-left" | "top-right" | "top-left"; | ||
export type Offset = { | ||
/** | ||
* Offset from the nearest horizontal screen edge after placement is resolved | ||
*/ | ||
x?: string | number; | ||
/** | ||
* Offset from the nearest vertical screen edge after placement is resolved | ||
*/ | ||
y?: string | number; | ||
}; | ||
export type FeedbackPosition = { | ||
type: "MODAL"; | ||
} | { | ||
type: "DIALOG"; | ||
placement: FeedbackPlacement; | ||
offset?: Offset; | ||
} | { | ||
type: "POPOVER"; | ||
anchor: HTMLElement | null; | ||
}; | ||
export interface FeedbackSubmission { | ||
@@ -45,3 +26,3 @@ question: string; | ||
*/ | ||
position?: FeedbackPosition; | ||
position?: Position; | ||
/** | ||
@@ -48,0 +29,0 @@ * Add your own custom translations for the feedback form. |
@@ -1,10 +0,10 @@ | ||
export type { Feature, InitOptions } from './client'; | ||
export type { Feature, InitOptions, ToolbarOptions } from './client'; | ||
export { BucketClient } from './client'; | ||
export type { BucketContext, CompanyContext, UserContext } from './context'; | ||
export type { CheckEvent, FeaturesOptions, RawFeature, RawFeatures, } from './feature/features'; | ||
export type { FeatureIdentifier, Feedback, FeedbackOptions, FeedbackPrompt, FeedbackPromptHandler, FeedbackPromptHandlerCallbacks, FeedbackPromptHandlerOpenFeedbackFormOptions, FeedbackPromptReply, FeedbackPromptReplyHandler, RequestFeedbackData, RequestFeedbackOptions, UnassignedFeedback, } from './feedback/feedback'; | ||
export type { 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 { FeedbackPlacement, FeedbackPosition, FeedbackScoreSubmission, FeedbackSubmission, FeedbackTranslations, Offset, OnScoreSubmitResult, OpenFeedbackFormOptions, } from './feedback/ui/types'; | ||
export type { FeedbackScoreSubmission, FeedbackSubmission, FeedbackTranslations, OnScoreSubmitResult, OpenFeedbackFormOptions, } from './feedback/ui/types'; | ||
export type { Logger } from './logger'; | ||
export { feedbackContainerId, propagatedEvents } from './ui/constants'; | ||
//# sourceMappingURL=index.d.ts.map |
import { DefaultBodyType, HttpResponse, StrictRequest } from 'msw'; | ||
import { Features } from '../../../node-sdk/src/types'; | ||
import { FeaturesResponse } from '../../src/feature/features'; | ||
@@ -7,3 +6,10 @@ | ||
export declare const featureResponse: FeaturesResponse; | ||
export declare const featuresResult: Features; | ||
export declare const featuresResult: { | ||
featureA: { | ||
isEnabled: boolean; | ||
key: string; | ||
targetingVersion: number; | ||
isEnabledOverride: null; | ||
}; | ||
}; | ||
export declare function getFeatures({ request, }: { | ||
@@ -10,0 +16,0 @@ request: StrictRequest<DefaultBodyType>; |
{ | ||
"name": "@bucketco/browser-sdk", | ||
"version": "2.5.1", | ||
"version": "3.0.0-alpha.0", | ||
"packageManager": "yarn@4.1.1", | ||
@@ -67,3 +67,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "d0e75be197e6af3d1c626162732054a3a4298ce0" | ||
"gitHead": "a4a7bfd8839346cf057d7f06ecb52c0fe35f100f" | ||
} |
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 not supported yet
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 not supported yet
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 not supported yet
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 not supported yet
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 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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1068547
135
5700
2