/** * Analytics Event Types for GLIDE SDK * * These events allow clients to track user behavior and conversions * through their own analytics platforms (e.g., Amplitude, Mixpanel, etc.) */ /** * Base context included with every analytics event * This allows segmentation by client/project and user identification */ export type GlideAnalyticsContext = { projectId?: string; appSlug: string; sdkVersion: string; referrerDomain?: string; walletAddress?: string; device: { isMobile: boolean; platform: "ios" | "android" | "windows" | "macos" | "linux" | "unknown"; browser: string; }; }; /** * Raw event types (without context - used internally in the widget) */ export type GlideAnalyticsEventType = { type: "modal_opened"; timestamp: number; } | { type: "modal_closed"; timestamp: number; completedTransaction: boolean; } | { type: "mode_selected"; mode: "deposit" | "withdraw" | "pay" | "call" | "buy"; timestamp: number; } | { type: "step_viewed"; step: string; timestamp: number; } | { type: "step_exited"; step: string; timestamp: number; direction: "forward" | "back"; } | { type: "payment_method_selected"; paymentMethod: "wallet" | "transfer" | "coinbase" | "coinbase_app" | "fiat" | "interac" | "debit_card_alias"; timestamp: number; } | { type: "funding_source_viewed"; availableOptions: string[]; timestamp: number; } | { type: "funding_source_selected"; fundingSource: "wallet" | "crypto" | "fiat"; timestamp: number; } | { type: "wallet_connect_started"; timestamp: number; } | { type: "wallet_connected"; address: string; chainId: number; timestamp: number; } | { type: "wallet_connection_failed"; error: string; timestamp: number; } | { type: "wallet_disconnected"; timestamp: number; } | { type: "chain_selected"; chainId: string; chainName: string; timestamp: number; } | { type: "currency_selected"; currencyId: string; currencySymbol: string; chainId: string; timestamp: number; } | { type: "amount_entered"; amount: string; currencySymbol: string; amountUSD?: number; timestamp: number; } | { type: "session_creation_started"; timestamp: number; } | { type: "session_created"; sessionId: string; paymentMethod: string; estimatedAmountUSD?: number; timestamp: number; } | { type: "session_creation_failed"; error: string; timestamp: number; } | { type: "transaction_started"; sessionId: string; paymentMethod: string; fromToken: string; toToken: string; amount: string; estimatedAmountUSD?: number; timestamp: number; } | { type: "transaction_signature_requested"; sessionId: string; timestamp: number; } | { type: "transaction_signed"; sessionId: string; txHash: string; timestamp: number; } | { type: "transaction_signature_rejected"; sessionId: string; timestamp: number; } | { type: "transaction_completed"; sessionId: string; txHash: string; paymentMethod: string; success: boolean; amountUSD?: number; timestamp: number; } | { type: "transaction_failed"; sessionId: string; error: string; paymentMethod: string; timestamp: number; } | { type: "onramp_window_opened"; provider: "coinbase" | "moonpay"; timestamp: number; } | { type: "onramp_window_closed"; provider: "coinbase" | "moonpay"; completed: boolean; timestamp: number; } | { type: "deposit_address_generated"; sessionId: string; chainId: string; currencySymbol: string; timestamp: number; } | { type: "deposit_address_copied"; sessionId: string; timestamp: number; } | { type: "waiting_for_deposit"; sessionId: string; chainId: string; currencySymbol: string; timestamp: number; } | { type: "deposit_detected"; sessionId: string; amount: string; currencySymbol: string; timestamp: number; } | { type: "transfer_completed"; sessionId: string; txHash: string; chainId: string; currencySymbol: string; amount: string; amountUSD?: number; timestamp: number; } | { type: "error_occurred"; errorType: string; errorMessage: string; step?: string; timestamp: number; } | { type: "conversion_completed"; sessionId: string; paymentMethod: string; amountUSD?: number; duration: number; timestamp: number; }; /** * Full analytics event with context * This is what clients receive in their callback */ export type GlideAnalyticsEvent = GlideAnalyticsEventType & GlideAnalyticsContext; /** * Callback function type for analytics events */ export type GlideAnalyticsCallback = (event: GlideAnalyticsEvent) => void;