UNPKG

@cruxstack/browser-sdk

Version:

A lightweight, privacy-focused JavaScript SDK for web analytics and event tracking. Built with TypeScript, featuring automatic event capture, event-time environment snapshots, intelligent queuing, and robust error handling.

83 lines (82 loc) 1.83 kB
export interface CruxstackConfig { /** Client identifier (required) */ clientId: string; /** Customer identifier (optional) */ customerId?: string; /** Customer name (optional, used as cna) */ customerName?: string; /** User identifier (optional) */ userId?: string; /** Enable/disable automatic event capture (optional, defaults to true) */ autoCapture?: boolean; /** Enable debug logging to console (optional, defaults to false) */ debugLog?: boolean; } export interface Event { id: string; type: string; data: Record<string, any>; timestamp: number; sessionId: string; userId: string | undefined; clientId: string; customerId?: string; customerName?: string; env?: EnvSnapshot; } export interface ApiEvent { cid?: string; cna?: string; uid?: string; eid: string; dtm: number; e: string; ev: Record<string, any>; tv: string; sid: string; tna: string; ua: string; sh: number; sw: number; l: string; tz: string; p: string; an: boolean; vh: number; vw: number; pt: string; pu: string; pp: string; pd: string; pl: number | null; pr: string | null; ip: string | null; } export interface EnvSnapshot { ua: string; sh: number; sw: number; l: string; tz: string; p: string; an: boolean; vh: number; vw: number; pt: string; pu: string; pp: string; pd: string; pl: number | null; pr: string | null; ip: string | null; } export interface SessionData { id: string; startTime: number; lastActivity: number; } export interface StorageInterface { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; }