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.

35 lines (34 loc) 1.22 kB
import { Event } from "../common/types"; export declare class ApiClient { private endpoint; private debugLog; private clientId; private customerId?; private customerName?; private ipAddress; private ipFetchInFlight; constructor(clientId: string, customerId?: string, customerName?: string, debugLog?: boolean); get<T = any>(path: string, params?: Record<string, any>, options?: { userId?: string; customHeaders?: Record<string, string>; }): Promise<T>; post<T = any>(path: string, data?: any, options?: { userId?: string; customHeaders?: Record<string, string>; }): Promise<T>; put<T = any>(path: string, data?: any, options?: { userId?: string; customHeaders?: Record<string, string>; }): Promise<T>; delete<T = any>(path: string, options?: { userId?: string; customHeaders?: Record<string, string>; }): Promise<T>; private handleResponse; getUserTraits(customerId: string): Promise<any>; sendEvent(event: Event): Promise<boolean>; sendEventsBatch(events: Event[]): Promise<boolean>; private isUnloadScenario; private fetchIpAddress; getCachedIp(): string | null; }