/** * Analytics Tracking Client * * Unified client for tracking user behavior across CREATE SOMETHING properties. * Features: session management, event batching, DNT respect, silent failures. * * Philosophy: The tracker recedes into transparent operation. * Users experience the product; we understand their intent. * * @packageDocumentation */ import { type AnalyticsConfig, type Property, type EventCategory } from './types.js'; /** * Check if Do Not Track is enabled in the browser * This is always respected regardless of other settings */ export declare function isDNTEnabled(): boolean; export declare class AnalyticsClient { private config; private queue; private flushTimer; private sessionId; private sessionStartedAt; private sessionEndSent; private sourceProperty; private userOptedOut; private isAuthenticated; private userId; constructor(config: AnalyticsConfig); /** * Check if tracking is disabled (DNT, user opt-out, or consent state) */ isTrackingDisabled(): boolean; /** * Update user opt-out preference (called when user changes setting) * Also updates the consent state in localStorage for persistence */ setUserOptOut(optedOut: boolean): void; /** * Set authenticated state (called when user logs in/out) */ setAuthenticated(isAuthenticated: boolean, analyticsOptOut?: boolean, userId?: string): void; /** * Set user ID for cross-property analytics tracking */ setUserId(userId: string | null): void; /** * Get current user ID */ getUserId(): string | null; /** * Track an event */ track(category: EventCategory, action: string, options?: { target?: string; value?: number; metadata?: Record; }): void; /** * Track a property transition (cross-property navigation) */ propertyTransition(fromProperty: Property, toProperty: Property): void; /** * Update session storage with source property */ private updateSessionSourceProperty; /** * Get source property for this session */ getSourceProperty(): Property | null; /** * Track a page view */ pageView(options?: { title?: string; loadTime?: number; }): void; /** * Track a route change (SPA navigation) */ routeChange(fromPath: string, toPath: string): void; /** * Track a button click */ buttonClick(target: string, buttonType?: 'cta' | 'nav' | 'action'): void; /** * Track scroll depth */ scrollDepth(depth: 25 | 50 | 75 | 100): void; /** * Track time on page */ timeOnPage(seconds: number): void; /** * Track a search query */ searchQuery(query: string, resultCount?: number): void; /** * Track search result click */ searchResultClick(resultId: string, position?: number): void; /** * Track an error displayed to user */ errorDisplayed(message: string, errorType?: string, component?: string): void; /** * Track a 404 page */ notFound(requestedUrl: string): void; /** * Track rage clicks (frustration signal) */ rageClick(target: string, clickCount: number): void; /** * Track form interactions */ formStart(formId: string): void; formSubmit(formId: string, success: boolean): void; formAbandon(formId: string, lastField?: string, timeSpent?: number): void; /** * Track content copy */ contentCopy(textLength?: number): void; /** * Track conversion events */ conversion(action: string, metadata?: Record): void; /** * Track Core Web Vitals */ webVital(name: 'lcp' | 'fid' | 'cls' | 'ttfb', value: number, rating?: 'good' | 'needs-improvement' | 'poor'): void; /** * Flush queued events immediately */ flush(): Promise; /** * Get current session ID */ getSessionId(): string; private generateEventId; private enqueue; private sendEvents; private sanitizeQuery; } /** * Initialize the analytics client */ export declare function initAnalytics(config: AnalyticsConfig): AnalyticsClient; /** * Get the analytics client instance */ export declare function getAnalytics(): AnalyticsClient | null; /** * Track an event using the singleton client */ export declare function track(category: EventCategory, action: string, options?: { target?: string; value?: number; metadata?: Record; }): void;