UNPKG

@hangarx/helix-node

Version:

Helix Analytics Node.js SDK for server-side event tracking with enhanced business intelligence capabilities

82 lines 2.06 kB
export interface AnalyticsEvent { type: 'track' | 'identify' | 'page' | 'screen'; userId?: string; sessionId?: string; event?: string; properties?: Record<string, any>; traits?: Record<string, any>; context: EventContext; timestamp: string; } export interface EventContext { library: { name: string; version: string; }; userAgent?: string; ip?: string; [key: string]: any; } export interface HelixNodeConfig { apiKey: string; endpoint?: string; batchSize?: number; flushInterval?: number; maxRetries?: number; timeout?: number; debug?: boolean; } export interface BatchResponse { success: boolean; message?: string; error?: string; } export declare class HelixAnalytics { private client; private apiKey; private batchSize; private flushInterval; private maxRetries; private debug; private queue; private flushTimer?; constructor(config: HelixNodeConfig); /** * Track an event */ track(userId: string, event: string, properties?: Record<string, any>): Promise<void>; /** * Identify a user */ identify(userId: string, traits?: Record<string, any>): Promise<void>; /** * Track a page view */ page(userId: string, name?: string, properties?: Record<string, any>): Promise<void>; /** * Track a screen view (for mobile apps) */ screen(userId: string, name?: string, properties?: Record<string, any>): Promise<void>; /** * Manually flush the queue */ flush(): Promise<void>; /** * Get current queue size */ getQueueSize(): number; /** * Shutdown the client gracefully */ shutdown(): Promise<void>; private enqueue; private sendBatch; private startBatchProcessor; private setupGracefulShutdown; private getContext; private generateSessionId; private sleep; } export default HelixAnalytics; export { HelixAnalytics as Analytics }; //# sourceMappingURL=index.d.ts.map