/** * Chat Extension Types * * Type definitions for the chat widget extension. * Core types are re-exported from globals.ts for consistency. */ export type { BubbleOffset, ChatMessage, ChatChannel, ChatChannelSummary, ChatConfig, ChatTheme, ChatWidgetView, LazyLoadedChatInterface, SendChatMessageContent, SendChatMessageOptions, } from "../../utils/globals"; export { messageUsesRichRendering, normalizeSendChatMessageContent, } from "./normalize-send-content"; export type { NormalizedOutgoingMessage } from "./normalize-send-content"; /** * Sender types for chat messages */ export type SenderType = "user" | "agent" | "ai" | "system"; /** * Channel status */ export type ChannelStatus = "open" | "closed" | "snoozed"; /** * Content types for messages */ export type ContentType = "text" | "html" | "attachment"; /** * Widget position options */ export type WidgetPosition = "bottom-right" | "bottom-left"; /** * Connection state for realtime */ export type ConnectionState = "connecting" | "connected" | "disconnected" | "error"; /** * Typing status event */ export interface TypingStatus { channel_id: string; sender_type: SenderType; sender_id: string; is_typing: boolean; timestamp: number; } /** * Presence status for users */ export interface PresenceStatus { distinct_id: string; status: "online" | "away" | "offline"; last_seen_at: string; current_page_url?: string; } /** * Normalized channel event names for analytics tracking * * Message events are tracked client-side via capture() for full enrichment * (session, page URL, device, person properties, etc.). * Widget UI events (open/close) are exposed via callbacks in ChatConfig. * * All channel message events use $channel_message with normalized properties: * - $channel_type: channel discriminator ('chat', 'email', 'sms') * - $conversation_id: conversation identifier * - $message_id: message identifier * - $direction: 'inbound' | 'outbound' * - $sender_type: 'user' | 'ai' | 'agent' | 'system' * - $content_preview: first 100 chars of content * * Tracking is gated by remote config: * - chatTracking.trackUserMessages → captures when $sender_type=user * - chatTracking.trackAgentMessages → captures when $sender_type=ai|agent */ export declare const CHANNEL_EVENTS: { readonly MESSAGE: "$channel_message"; }; export interface ChannelMessageEventProperties { $channel_type: string; $conversation_id: string; $message_id: string; $direction: "inbound" | "outbound"; $sender_type: SenderType; $content_preview: string; $ai_mode?: boolean; } /** * Message callback type */ export type MessageCallback = (message: import("../../utils/globals").ChatMessage) => void; /** * Typing callback type */ export type TypingCallback = (isTyping: boolean, senderType: string) => void; /** * Connection callback type */ export type ConnectionCallback = (connected: boolean) => void; /** * Unsubscribe function type */ export type Unsubscribe = () => void; /** * API response for creating a channel */ export interface CreateChannelResponse { channel: import("../../utils/globals").ChatChannel; config: { ai_enabled: boolean; ai_greeting: string | null; widget_greeting: string | null; }; } /** * API response for sending a message */ export interface SendMessageResponse { message: import("../../utils/globals").ChatMessage; ai_response?: import("../../utils/globals").ChatMessage; } /** * Ably realtime channel for chat */ export interface AblyChannel { subscribe: (event: string, callback: (message: unknown) => void) => void; unsubscribe: () => void; publish: (event: string, data: unknown) => Promise; }