import { HttpClient } from '../httpClient'; import { Logger } from '../logger'; import { Position } from '../ui/types'; import { FeedbackSubmission, FeedbackTranslations, OpenFeedbackFormOptions } from './ui/types'; import { FeedbackPromptCompletionHandler } from './prompts'; export type Key = string; 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?: { /** * Control the placement and behavior of the feedback form. */ position?: Position; /** * Add your own custom translations for the feedback form. * Undefined translation keys fall back to english defaults. */ translations?: Partial; }; }; export type RequestFeedbackData = Omit & { /** * Company ID from your own application. */ companyId?: string; /** * 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. * * @param {Object} data */ onAfterSubmit?: (data: FeedbackSubmission) => void; /** * Bucket feature key. */ featureKey: string; }; export type RequestFeedbackOptions = RequestFeedbackData & { /** * User ID from your own application. */ userId: string; }; export type UnassignedFeedback = { /** * Bucket feature key. */ featureKey: string; /** * Bucket feedback ID */ feedbackId?: string; /** * The question that was presented to the user. */ question?: string; /** * The original question. * This only needs to be populated if the feedback was submitted through the automated feedback surveys channel. */ promptedQuestion?: string; /** * Customer satisfaction score. */ score?: number; /** * User supplied comment about your feature. */ comment?: 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. */ promptId?: string; /** * 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 via `requestFeedback` * - `sdk` - Feedback submitted via `feedback` */ source?: "prompt" | "sdk" | "widget"; }; export type Feedback = UnassignedFeedback & { /** * User ID from your own application. */ userId?: string; /** * Company ID from your own application. */ companyId?: string; }; 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; }; export type FeedbackPromptReply = { question: string; companyId?: string; score?: number; comment?: string; }; export type FeedbackPromptReplyHandler = (reply: T) => T extends null ? Promise : Promise<{ feedbackId: string; }>; export type FeedbackPromptHandlerOpenFeedbackFormOptions = Omit; export type FeedbackPromptHandlerCallbacks = { reply: FeedbackPromptReplyHandler; openFeedbackForm: (options: FeedbackPromptHandlerOpenFeedbackFormOptions) => void; }; export type FeedbackPromptHandler = (prompt: FeedbackPrompt, handlers: FeedbackPromptHandlerCallbacks) => void; export declare const createDefaultFeedbackPromptHandler: (options?: FeedbackPromptHandlerOpenFeedbackFormOptions) => FeedbackPromptHandler; export declare const DEFAULT_FEEDBACK_CONFIG: { promptHandler: FeedbackPromptHandler; feedbackPosition: Position; translations: {}; autoFeedbackEnabled: boolean; }; type FeedbackPayload = Omit & { featureId?: string; featureKey?: string; }; export declare function feedback(httpClient: HttpClient, logger: Logger, payload: FeedbackPayload): Promise; export declare class AutoFeedback { private sseBaseUrl; private logger; private httpClient; private feedbackPromptHandler; private userId; private position; private feedbackTranslations; private initialized; private sseChannel; constructor(sseBaseUrl: string, logger: Logger, httpClient: HttpClient, feedbackPromptHandler: FeedbackPromptHandler | undefined, userId: string, position?: Position, feedbackTranslations?: Partial); /** * Start receiving automated feedback surveys. */ initialize(): Promise; private getChannel; handleFeedbackPromptRequest(userId: string, message: any): void; stop(): void; triggerFeedbackPrompt(userId: string, message: FeedbackPrompt, completionHandler: FeedbackPromptCompletionHandler): Promise; feedbackPromptEvent(args: { event: "received" | "shown" | "dismissed"; featureId: string; promptId: string; promptedQuestion: string; userId: string; }): Promise; } export {}; //# sourceMappingURL=feedback.d.ts.map