/** * @youranalytics/web-sdk Utility Functions * Performance-focused utilities with browser compatibility */ import type { UtmParams, NetworkInfo, ConnectionType } from './types'; /** * Parse query string into key-value object. * Uses URLSearchParams if available, falls back to manual parsing. * * @param search - Query string (with or without leading '?') * @returns Parsed key-value pairs * * @example * parseQueryString('?foo=bar&baz=qux') * // Returns: { foo: 'bar', baz: 'qux' } */ export declare function parseQueryString(search: string): Record; /** * Extract UTM parameters from current URL query string. * Handles both standard query strings and hash-based routing. * * @returns UTM parameters found in URL * * @example * // URL: https://example.com?utm_source=google&utm_medium=cpc * getUtmParams() * // Returns: { source: 'google', medium: 'cpc' } */ export declare function getUtmParams(): UtmParams; /** Navigator connection interface for Network Information API */ export interface NavigatorConnection { effectiveType?: string; downlink?: number; rtt?: number; saveData?: boolean; addEventListener?: (type: string, listener: () => void) => void; removeEventListener?: (type: string, listener: () => void) => void; } /** * Get network connection from navigator. */ export declare function getNavigatorConnection(): NavigatorConnection | null; /** * Get detailed network quality information. * Uses the Network Information API when available. * * @returns Network info or null if API not available */ export declare function getConnectionInfo(): NetworkInfo | null; /** * Get simplified connection type. * Returns 'unknown' if Network Information API is not available. * * @returns Connection type: 'slow-2g' | '2g' | '3g' | '4g' | 'unknown' */ export declare function getConnectionType(): ConnectionType; /** * Detect if the current user agent is a bot or crawler. * Used to skip tracking for automated traffic. */ export declare function isBot(): boolean; /** * Debounce function calls. * Delays execution until after wait milliseconds have elapsed * since the last time the function was invoked. * * @param func - Function to debounce * @param wait - Milliseconds to wait * @returns Debounced function */ export declare function debounce unknown>(func: T, wait: number): (...args: Parameters) => void; /** * Throttle function calls. * Ensures function runs at most once per specified time period. * * @param func - Function to throttle * @param limit - Minimum milliseconds between calls * @returns Throttled function */ export declare function throttle unknown>(func: T, limit: number): (...args: Parameters) => void; export declare const supportsBeacon: () => boolean; export declare const supportsFetch: () => boolean; export declare const supportsCompression: () => boolean; export declare function resetCapabilityCache(): void; /** * Sanitize event names for consistency and safety. * - Converts to lowercase * - Replaces spaces with underscores * - Removes special characters (keeps alphanumeric and underscore) * - Limits length to 100 characters * * @param name - Raw event name * @returns Sanitized event name */ export declare function sanitizeEventName(name: string): string; export declare function sanitizeProperties(props: Record): Record; export declare function getPageUrl(): string; export declare function getPageTitle(): string | undefined; export declare function getReferrer(): string | undefined; export declare function getUserAgent(): string; export declare function getScreenDimensions(): { width: number; height: number; }; //# sourceMappingURL=utils.d.ts.map