import { ClientOptions, OpenFlowOptions, FetchFeedbackInput, FetchFeedbackResult, FeedbackInput, SubmitFeedbackResult, Client } from '@getuserfeedback/sdk'; export { ActionsConfig, LinksConfig } from '@getuserfeedback/sdk'; import { ReactNode, ReactElement } from 'react'; /** * Return value for the experimental `useFeedback()` hook. * * @experimental */ interface UseFeedbackReturn { /** Fetch feedback matching each selector for the JWT-authenticated user. */ fetch: (input: FetchFeedbackInput) => Promise; /** True while one or more fetches from this hook are pending. */ isFetching: boolean; /** True while one or more submissions from this hook are pending. */ isSubmitting: boolean; /** Submit feedback about the current app or a specific target. */ submit: (input: FeedbackInput) => Promise; } /** * Options for useFlow(). */ interface UseFlowOptions { /** The flow/survey ID to control. */ flowId: string; /** Prefetch the flow resources on mount so it opens faster. Default `false`. */ prefetchOnMount?: boolean; /** * Where the flow mounts: `"default"` (floating container) or `"custom"` (your container via containerRef). * Default `"default"`. Remount the hook to change this mode. */ container?: "default" | "custom"; /** When true, the view does not show a close button. */ hideCloseButton?: boolean; } /** * Per-open options for useFlow(). These apply to the specific response created * by that open action and do not affect prerendering. */ interface UseFlowOpenOptions { /** Optional response metadata to preserve with the eventual submission. */ metadata?: OpenFlowOptions["metadata"]; } /** * Return value for useFlow() when container is `"default"`: state and callbacks for the floating flow. */ interface UseFlowReturn { readonly container: "default"; /** True when the flow is visible. */ isOpen: boolean; /** True after open is requested while the flow is not visible yet. */ isLoading: boolean; /** Open the flow. */ open: (options?: UseFlowOpenOptions) => Promise; /** Close the flow. */ close: () => Promise; /** Prefetches the flow resources without opening it. */ prefetch: () => Promise; /** Prerendering warms up the flow for instant display later. */ prerender: () => Promise; } /** * Return value for useFlow() when container is `"custom"`: state and callbacks for host-managed container flows. */ interface UseCustomFlowReturn { readonly container: "custom"; /** True when the flow is visible. */ isOpen: boolean; /** True after open is requested while the flow is not visible yet. */ isLoading: boolean; /** True when your host UI should render the custom container element. */ shouldRenderContainer: boolean; /** Open the flow in the custom container. */ open: (options?: UseFlowOpenOptions) => Promise; /** Close the flow. */ close: () => Promise; /** Prefetches the flow resources without opening it. */ prefetch: () => Promise; /** * @deprecated Use `open()` or `close()` instead. Kept for compatibility. */ setOpen: (next: boolean) => Promise; /** Prerendering warms up the flow for instant display later. */ prerender: () => Promise; /** Ref callback: attach this to the container element where the flow should render. */ containerRef: (element: HTMLDivElement | null) => void; } /** * Return value for useFlowContainer(): container ref and aggregate flow state * for flows using the default presentation in the same logical client * (including targeting-engine opens). Mount exactly one consumer per logical * client. */ interface UseFlowContainerReturn { /** True when any flow is visible. */ isOpen: boolean; /** True after any flow open is requested while the flow is not visible yet. */ isLoading: boolean; /** True when your host UI should render the provider-wide flow container. */ shouldRenderContainer: boolean; /** Close all open flows owned by this logical client. */ close: () => Promise; /** Ref callback for the provider-wide flow container element. */ containerRef: (element: HTMLDivElement | null) => void; } interface GetUserFeedbackProviderProps { /** Application subtree that can use getuserfeedback hooks. */ children: ReactNode; /** * Core SDK client options used to create/reuse the underlying client. * Action definitions must remain fixed for the provider's mounted * lifetime; handlers may change while their custom key and version stay * the same. */ clientOptions: ClientOptions; } /** * Provider for getuserfeedback React hooks. * Wrap your app (or a subtree) so `useFlow`, `useFlowContainer`, and * `useGetUserFeedback` can access a client created from `clientOptions`. * * If your app uses `useFlowContainer()`, flows using the default presentation * in this subtree (including targeting-engine opens) target that container. * If the container ref is not mounted yet, loader keeps flows parked until it is. * Mount exactly one `useFlowContainer()` consumer per logical client. Providers * with the same API key and targeting context reuse that client. * * @example Basic usage * ```tsx * function App() { * return ( * * * * ); * } * ``` * * @example Display *any* flow in your own dialog (a shadcn/ui dialog in this example): * ```tsx * function AppFlowContainer() { * const { close, containerRef, shouldRenderContainer } = useFlowContainer(); * * return ( * { * if (!open) { * void close().catch((error) => * console.error("Unable to close feedback", error), * ); * } * }} * > * *
* *
* ); * } * * function App() { * return ( * * * // Targeted flows display in your dialog. * * ); * } * ``` */ declare function GetUserFeedbackProvider({ children, clientOptions, }: GetUserFeedbackProviderProps): ReactElement; /** * @name useFlow * @description Open a flow in the default container or your own container. * @example Default container * ```tsx * const { open, isLoading } = useFlow({ flowId: "sur_123" }); * await open({ * metadata: { * tags: { * journey_stage: "onboarding", * }, * }, * }); * ``` * @example Custom container * ```tsx * const { containerRef, shouldRenderContainer, open } = useFlow({ flowId: "sur_123", container: "custom" }); * ``` * @see https://getuserfeedback.com/docs/guides/advanced/containers */ declare function useFlow(options: UseFlowOptions & { container?: "default"; }): UseFlowReturn; declare function useFlow(options: UseFlowOptions & { container: "custom"; }): UseCustomFlowReturn; /** * @name useFlowContainer * @description Register and control the single default container for this provider subtree. Mount exactly one consumer per logical client. * @example Display any flow in your own dialog * ```tsx * function AppFlowContainer() { * const { close, containerRef, shouldRenderContainer } = useFlowContainer(); * return ( * { * if (!open) { * void close().catch((error) => * console.error("Unable to close feedback", error), * ); * } * }} * > * *
* *
* ); * } * * function App() { * return ( * * * * * ); * } * ``` * @see https://getuserfeedback.com/docs/guides/advanced/containers */ declare function useFlowContainer(): UseFlowContainerReturn; /** * Experimental hook for submitting feedback or explicitly fetching the * JWT-authenticated user's feedback. * * Neither operation runs automatically. Each promise returns the corresponding * SDK result and rejects when the operation fails. * * @experimental */ declare function useFeedback(): UseFeedbackReturn; /** * Hook for accessing the getuserfeedback client instance. * * @see https://getuserfeedback.com/docs/reference/react-sdk-reference * @see https://getuserfeedback.com/docs/reference/events * * @example Basic usage * ```tsx * const client = useGetUserFeedback(); * * async function handleLogin() { * await client.identify("user-123", { email: "user@example.com" }); * } * * async function handleCheckoutStarted() { * await client.track("Checkout Started", { plan: "pro" }); * } * * async function handleLogout() { * await client.reset(); * } * ``` * * @example Override color scheme * ```tsx * const client = useGetUserFeedback(); * await client.configure({ colorScheme: "dark" }); * ``` */ declare function useGetUserFeedback(): Client; declare const REACT_SDK_VERSION: string; export { GetUserFeedbackProvider, REACT_SDK_VERSION, useFeedback, useFlow, useFlowContainer, useGetUserFeedback }; export type { GetUserFeedbackProviderProps, UseCustomFlowReturn, UseFeedbackReturn, UseFlowContainerReturn, UseFlowOpenOptions, UseFlowOptions, UseFlowReturn };