UNPKG

thrivestack-analytics

Version:

ThriveStack Analytics - Privacy-first web analytics for Node.js and browsers

137 lines (136 loc) 4.07 kB
interface ThriveStackOptions { apiKey: string; apiEndpoint?: string; trackClicks?: boolean; trackForms?: boolean; respectDoNotTrack?: boolean; enableConsent?: boolean; batchSize?: number; batchInterval?: number; geoIpServiceUrl?: string; source?: string; sessionTimeout?: number; debounceDelay?: number; defaultConsent?: boolean; } interface LocationInfo { city?: string | null; region?: string | null; country?: string | null; postal?: string | null; loc?: string | null; timezone?: string | null; } interface ConsentCategories { functional: boolean; analytics: boolean; marketing: boolean; } interface InteractionHistory { type: string; details: any; timestamp: string; sequence: number; } interface EventData { event_name: string; properties: Record<string, any>; user_id?: string; context: { group_id?: string; device_id?: string | null; session_id?: string; source?: string; }; timestamp: string; } interface IdentifyData { user_id: string; traits: Record<string, any>; timestamp: string; } interface GroupData { group_id: string; user_id?: string; traits: Record<string, any>; timestamp: string; } export declare class ThriveStack { private apiKey; private apiEndpoint; private respectDoNotTrack; private trackClicks; private trackForms; private enableConsent; private source; private geoIpServiceUrl; private ipAddress; private locationInfo; private eventQueue; private queueTimer; private batchSize; private batchInterval; private interactionHistory; private maxHistoryLength; private consentCategories; private userId; private groupId; private deviceId; private deviceIdReady; private sessionTimeout; private debounceDelay; private sessionUpdateTimer; private debugMode; constructor(options: ThriveStackOptions | string); private initializeDeviceId; private generateRandomDeviceId; private setDeviceIdCookie; private getDeviceIdFromCookie; private fetchIpAndLocationInfo; private setLocationInfoCookie; private getLocationInfoFromCookie; init(userId?: string, source?: string): Promise<void>; private shouldTrack; private isTrackingAllowed; setConsent(category: keyof ConsentCategories, hasConsent: boolean): void; setUserId(userId: string): void; setGroupId(groupId: string): void; setSource(source: string): void; private setUserIdCookie; private getUserIdFromCookie; private setGroupIdCookie; private getGroupIdFromCookie; private queueEvent; private processQueueIfReady; private processQueue; track(events: EventData[]): Promise<any>; identify(data: IdentifyData | IdentifyData[]): Promise<any>; group(data: GroupData | GroupData[]): Promise<any>; getDeviceId(): string | null; private getSessionId; private createNewSession; private migrateOldSession; private setSessionCookie; private updateSessionActivity; private updateSessionActivityImmediate; private setupSessionTracking; capturePageVisit(): Promise<void>; captureEvent(eventName: string, properties?: Record<string, any>): Promise<void>; private addToInteractionHistory; private cleanPIIFromEventData; setUser(userId: string, emailId?: string, properties?: Record<string, any>): Promise<any | null>; setGroup(groupId: string, groupDomain?: string, groupName?: string, properties?: Record<string, any>): Promise<any | null>; enableDebugMode(): void; getInteractionHistory(): InteractionHistory[]; getLocationInfo(): LocationInfo | null; getIpAddress(): string | null; private getUtmParameters; private autoCapturePageVisit; private autoCaptureClickEvents; private captureClickEvent; private getElementHierarchy; private getElementSelector; private autoCaptureFormEvents; private captureFormEvent; } export {};