/** * Funnel event types enum * * Special types: * - DIRECT_NAVIGATION: Bypasses step conditions, navigates directly to targetStepId * - BACK_NAVIGATION: Similar to direct_navigation, used for backward navigation * * Common types (for logging/tracking): * - Any string value is accepted, but these are commonly used examples */ export declare enum FunnelEventType { DIRECT_NAVIGATION = "direct_navigation", BACK_NAVIGATION = "back_navigation", PAYMENT_SUCCESS = "payment_success", CUSTOM = "custom" } /** * Data structures for specific event types */ export type NextEvent = T & { [key: string]: any; }; export interface DirectNavigationEventData { targetStepId: string; } export interface BackNavigationEventData { targetStepId: string; } export interface QuizCompletedEventData { quiz: { score: number; [key: string]: any; }; } export interface OfferAcceptedEventData { offer: { accepted: boolean; offerId?: string; [key: string]: any; }; } export interface FormSubmitEventData { [key: string]: any; } export interface PaymentSuccessEventData { payment?: { status: 'success'; amount: number; currency: string; orderId?: string; transactionId?: string; timestamp?: string; [key: string]: any; }; order?: { id: string; amount: number; currency: string; [key: string]: any; }; paymentId?: string; [key: string]: any; } /** * Base properties shared by all FunnelEvent types */ interface BaseFunnelEvent { /** * Event timestamp */ timestamp?: Date; } /** * Discriminated union for FunnelEvent based on event type */ export type FunnelEvent = BaseFunnelEvent & (({ type: FunnelEventType.DIRECT_NAVIGATION; data: NextEvent; }) | ({ type: FunnelEventType.BACK_NAVIGATION; data: NextEvent; }) | ({ type: FunnelEventType.PAYMENT_SUCCESS; data?: NextEvent; }) | ({ type: FunnelEventType.CUSTOM; data?: NextEvent; })); export interface FunnelNavigationAction { type: 'redirect' | 'replace' | 'push' | 'external' | 'none'; url?: string; data?: any; } export interface FunnelNavigationResult { stepId: string; action: FunnelNavigationAction; context: SimpleFunnelContext; tracking?: { from: string; to: string; event: string; timestamp: string; }; } export interface SimpleFunnelContext { customerId: string; storeId: string; sessionId: string; funnelId: string; currentStepId: string; previousStepId?: string; startedAt: number; lastActivityAt: number; metadata?: Record; } export interface UseFunnelOptions { funnelId?: string; currentStepId?: string; onNavigate?: (result: FunnelNavigationResult) => void | boolean; onError?: (error: Error) => void; autoInitialize?: boolean; } export interface UseFunnelResult { next: (event: FunnelEvent) => Promise; goToStep: (stepId: string) => Promise; updateContext: (updates: Partial) => Promise; currentStep: { id: string; }; context: SimpleFunnelContext | null; isLoading: boolean; isInitialized: boolean; initializeSession: (entryStepId?: string) => Promise; endSession: () => Promise; retryInitialization: () => Promise; initializationError: Error | null; } /** * React Hook for Funnel Navigation (Plugin SDK Version) * * Simplified funnel navigation using KV storage for funnel sessions. * Integrates with TagadaPay authentication and plugin routing. */ export declare function useFunnel(options: UseFunnelOptions): UseFunnelResult; /** * Simplified funnel hook for basic step tracking */ export declare function useSimpleFunnel(funnelId: string, initialStepId?: string): { currentStepId: string; next: (event: FunnelEvent) => Promise; goToStep: (stepId: string) => Promise; isLoading: boolean; }; export {};