import { InjectionKey } from '../vue/dist/vue.esm-bundler.js'; import { HookArgs, InitOptions, ReflagClient, RequestFeedbackData, SetOptInOptions, UnassignedFeedback } from '@reflag/browser-sdk'; import { FlagKey, ProviderContextType, TypedFlags, UseOptInFlagsResult } from './types'; export declare const ProviderSymbol: InjectionKey; /** * Returns the ReflagClient for a given publishable key. * Only creates a new ReflagClient if not already created or if it hook is run on the server. * @internal */ export declare function useReflagClient(initOptions: InitOptions & { debug?: boolean; }): ReflagClient; /** * Vue composable for getting the state of a given flag for the current context. * * This composable returns an object with the state of the flag for the current context. * * @param key - The key of the flag to get the state of. * @returns An object with the state of the flag. * * @example * ```ts * import { useFlag } from '@reflag/vue-sdk'; * * const { isEnabled, config, track, requestFeedback } = useFlag("huddles"); * * function StartHuddlesButton() { * const { isEnabled, config: { payload }, track } = useFlag("huddles"); * if (isEnabled) { * return ; * } * ``` */ export declare function useFlag(key: TKey): TypedFlags[TKey]; /** * Vue composable for getting opt-in-enabled flags and their loading state for * the current context. * * The loading state is only used with `ReflagBootstrappedProvider` while * opt-in metadata is fetched on demand. Regular providers load opt-in metadata * with the initial flags; use {@link useIsLoading} for their loading state. * * If fetching opt-in metadata fails, loading ends without exposing an error. * Call `refresh()` on the client returned by {@link useClient} to retry. */ export declare function useOptInFlags(): UseOptInFlagsResult; /** * Vue composable for setting whether the current user or company has opted into a flag. * * Check the returned Response's `ok` property and catch promise rejections. * HTTP failures return a non-OK Response; offline mode, invalid arguments, or * missing scoped context return undefined. Confirmation failures can reject * after the membership changed remotely. See {@link ReflagClient.setOptIn}. */ export declare function useSetOptIn(): (key: FlagKey, options: SetOptInOptions) => Promise; /** * Vue composable for tracking custom events. * * This composable returns a function that can be used to track custom events * with the Reflag SDK. * * @example * ```ts * import { useTrack } from '@reflag/vue-sdk'; * * const track = useTrack(); * * // Track a custom event * track('button_clicked', { buttonName: 'Start Huddles' }); * ``` * * @returns A function that tracks an event. The function accepts: * - `eventName`: The name of the event to track. * - `attributes`: (Optional) Additional attributes to associate with the event. */ export declare function useTrack(): (eventName: string, attributes?: Record | null) => Promise; /** * Vue composable for requesting user feedback. * * This composable returns a function that can be used to trigger the feedback * collection flow with the Reflag SDK. You can use this to prompt users for * feedback at any point in your application. * * @example * ```ts * import { useRequestFeedback } from '@reflag/vue-sdk'; * * const requestFeedback = useRequestFeedback(); * * // Request feedback from the user * requestFeedback({ * prompt: "How was your experience?", * metadata: { page: "dashboard" } * }); * ``` * * @returns A function that requests feedback from the user. The function accepts: * - `options`: An object containing feedback request options. */ export declare function useRequestFeedback(): (options: RequestFeedbackData) => void; /** * Vue composable for sending feedback. * * This composable returns a function that can be used to send feedback to the * Reflag SDK. You can use this to send feedback from your application. * * @example * ```ts * import { useSendFeedback } from '@reflag/vue-sdk'; * * const sendFeedback = useSendFeedback(); * * // Send feedback from the user * sendFeedback({ * feedback: "I love this flag!", * metadata: { page: "dashboard" } * }); * ``` * * @returns A function that sends feedback to the Reflag SDK. The function accepts: * - `options`: An object containing feedback options. */ export declare function useSendFeedback(): (opts: UnassignedFeedback) => Promise; /** * Vue composable for updating the user context. * * This composable returns a function that can be used to update the user context * with the Reflag SDK. You can use this to update the user context at any point * in your application. * * @example * ```ts * import { useUpdateUser } from '@reflag/vue-sdk'; * * const updateUser = useUpdateUser(); * * // Update the user context * updateUser({ id: "123", name: "John Doe" }); * ``` * * @returns A function that updates the user context. The function accepts: * - `opts`: An object containing the user context to update. */ export declare function useUpdateUser(): (opts: { [key: string]: string | number | undefined; }) => Promise; /** * Vue composable for updating the company context. * * This composable returns a function that can be used to update the company * context with the Reflag SDK. You can use this to update the company context * at any point in your application. * * @example * ```ts * import { useUpdateCompany } from '@reflag/vue-sdk'; * * const updateCompany = useUpdateCompany(); * * // Update the company context * updateCompany({ id: "123", name: "Acme Inc." }); * ``` * * @returns A function that updates the company context. The function accepts: * - `opts`: An object containing the company context to update. */ export declare function useUpdateCompany(): (opts: { [key: string]: string | number | undefined; }) => Promise; /** * Vue composable for updating the other context. * * This composable returns a function that can be used to update the other * context with the Reflag SDK. You can use this to update the other context * at any point in your application. * * @example * ```ts * import { useUpdateOtherContext } from '@reflag/vue-sdk'; * * const updateOtherContext = useUpdateOtherContext(); * * // Update the other context * updateOtherContext({ id: "123", name: "Acme Inc." }); * ``` * * @returns A function that updates the other context. The function accepts: * - `opts`: An object containing the other context to update. */ export declare function useUpdateOtherContext(): (opts: { [key: string]: string | number | undefined; }) => Promise; /** * Vue composable for getting the Reflag client. * * This composable returns the Reflag client. You can use this to get the Reflag * client at any point in your application. * * @example * ```ts * import { useClient } from '@reflag/vue-sdk'; * * const client = useClient(); * * console.log(client.getContext()); * ``` * @returns The Reflag client. */ export declare function useClient(): ReflagClient; /** * Vue composable for checking if the Reflag client is loading. * * This composable returns a boolean value that indicates whether the Reflag client is loading. * You can use this to check if the Reflag client is loading at any point in your application. * Initially, the value will be true until the client is initialized. * * @example * ```ts * import { useIsLoading } from '@reflag/vue-sdk'; * * const isLoading = useIsLoading(); * * console.log(isLoading); * ``` */ export declare function useIsLoading(): import('../vue/dist/vue.esm-bundler.js').Ref; /** * Vue composable for listening to Reflag client events. * * @example * ```ts * import { useOnEvent } from '@reflag/vue-sdk'; * * useOnEvent("flagsUpdated", () => { * console.log("flags updated"); * }); * ``` * * @param event - The event to listen to. * @param handler - The function to call when the event is triggered. * @param client - The Reflag client to listen to. If not provided, the client will be retrieved from the context. */ export declare function useOnEvent(event: THookType, handler: (arg0: HookArgs[THookType]) => void, client?: ReflagClient): void; //# sourceMappingURL=hooks.d.ts.map