@datalyr/web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Identity Management Module
3
+ * Handles anonymous_id, user_id, and identity resolution
4
+ */
5
+ export declare class IdentityManager {
6
+ private anonymousId;
7
+ private userId;
8
+ private sessionId;
9
+ constructor();
10
+ /**
11
+ * Get or create anonymous ID (device/browser identifier)
12
+ */
13
+ private getOrCreateAnonymousId;
14
+ /**
15
+ * Get stored user ID from previous session
16
+ */
17
+ private getStoredUserId;
18
+ /**
19
+ * Get the anonymous ID
20
+ */
21
+ getAnonymousId(): string;
22
+ /**
23
+ * Get the user ID (if identified)
24
+ */
25
+ getUserId(): string | null;
26
+ /**
27
+ * Get the distinct ID (primary identifier)
28
+ * Returns user_id if identified, otherwise anonymous_id
29
+ */
30
+ getDistinctId(): string;
31
+ /**
32
+ * Get canonical ID (alias for distinct_id)
33
+ */
34
+ getCanonicalId(): string;
35
+ /**
36
+ * Set the session ID
37
+ */
38
+ setSessionId(sessionId: string): void;
39
+ /**
40
+ * Get the session ID
41
+ */
42
+ getSessionId(): string | null;
43
+ /**
44
+ * Identify a user
45
+ * Links anonymous_id to user_id
46
+ */
47
+ identify(userId: string, traits?: Record<string, any>): Record<string, any>;
48
+ /**
49
+ * Alias one ID to another
50
+ */
51
+ alias(userId: string, previousId?: string): Record<string, any>;
52
+ /**
53
+ * Reset the current user (on logout)
54
+ * Clears user_id but keeps anonymous_id
55
+ */
56
+ reset(): void;
57
+ /**
58
+ * Get all identity fields for event payload
59
+ */
60
+ getIdentityFields(): Record<string, any>;
61
+ }
62
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAuB;;IAOxC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAW9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAuB/E;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAgB/D;;;OAGG;IACH,KAAK,IAAI,IAAI;IAUb;;OAEG;IACH,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAqBzC"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Datalyr Web SDK
3
+ * Modern attribution tracking for web applications
4
+ */
5
+ import type { DatalyrConfig, EventProperties, UserTraits, PageProperties, SessionData, Attribution, TouchPoint, ConsentConfig, NetworkStatus, ErrorInfo } from './types';
6
+ export * from './types';
7
+ declare class Datalyr {
8
+ private config;
9
+ private identity;
10
+ private session;
11
+ private attribution;
12
+ private queue;
13
+ private fingerprint;
14
+ private cookies;
15
+ private container?;
16
+ private superProperties;
17
+ private userProperties;
18
+ private optedOut;
19
+ private initialized;
20
+ private errors;
21
+ private MAX_ERRORS;
22
+ private heavyFingerprintCollected;
23
+ constructor();
24
+ /**
25
+ * Initialize the SDK
26
+ */
27
+ init(config: DatalyrConfig): void;
28
+ /**
29
+ * Track an event
30
+ */
31
+ track(eventName: string, properties?: EventProperties): void;
32
+ /**
33
+ * Identify a user
34
+ */
35
+ identify(userId: string, traits?: UserTraits): void;
36
+ /**
37
+ * Track a page view
38
+ */
39
+ page(properties?: PageProperties): void;
40
+ /**
41
+ * Track a screen view (for SPAs)
42
+ */
43
+ screen(screenName: string, properties?: Record<string, any>): void;
44
+ /**
45
+ * Associate user with a group/account
46
+ */
47
+ group(groupId: string, traits?: Record<string, any>): void;
48
+ /**
49
+ * Alias one ID to another
50
+ */
51
+ alias(userId: string, previousId?: string): void;
52
+ /**
53
+ * Reset the current user
54
+ */
55
+ reset(): void;
56
+ /**
57
+ * Get the current anonymous ID
58
+ */
59
+ getAnonymousId(): string;
60
+ /**
61
+ * Get the current user ID
62
+ */
63
+ getUserId(): string | null;
64
+ /**
65
+ * Get the distinct ID
66
+ */
67
+ getDistinctId(): string;
68
+ /**
69
+ * Get the current session ID
70
+ */
71
+ getSessionId(): string;
72
+ /**
73
+ * Start a new session manually
74
+ */
75
+ startNewSession(): string;
76
+ /**
77
+ * Get session data
78
+ */
79
+ getSessionData(): SessionData | null;
80
+ /**
81
+ * Get current attribution data
82
+ */
83
+ getAttribution(): Attribution;
84
+ /**
85
+ * Get customer journey
86
+ */
87
+ getJourney(): TouchPoint[];
88
+ /**
89
+ * Set attribution manually
90
+ */
91
+ setAttribution(attribution: Partial<Attribution>): void;
92
+ /**
93
+ * Opt out of tracking
94
+ */
95
+ optOut(): void;
96
+ /**
97
+ * Opt in to tracking
98
+ */
99
+ optIn(): void;
100
+ /**
101
+ * Check if user has opted out
102
+ */
103
+ isOptedOut(): boolean;
104
+ /**
105
+ * Set consent preferences
106
+ */
107
+ setConsent(consent: ConsentConfig): void;
108
+ /**
109
+ * Manually flush the event queue
110
+ */
111
+ flush(): Promise<void>;
112
+ /**
113
+ * Set super properties
114
+ */
115
+ setSuperProperties(properties: Record<string, any>): void;
116
+ /**
117
+ * Unset a super property
118
+ */
119
+ unsetSuperProperty(propertyName: string): void;
120
+ /**
121
+ * Get super properties
122
+ */
123
+ getSuperProperties(): Record<string, any>;
124
+ /**
125
+ * Create event payload
126
+ */
127
+ private createEventPayload;
128
+ /**
129
+ * Check if we should track
130
+ */
131
+ private shouldTrack;
132
+ /**
133
+ * Setup SPA tracking
134
+ */
135
+ private setupSPATracking;
136
+ /**
137
+ * Setup page unload handler
138
+ */
139
+ private setupUnloadHandler;
140
+ /**
141
+ * Get performance metrics
142
+ */
143
+ private getPerformanceMetrics;
144
+ /**
145
+ * Track error
146
+ */
147
+ private trackError;
148
+ /**
149
+ * Get errors
150
+ */
151
+ getErrors(): ErrorInfo[];
152
+ /**
153
+ * Get network status
154
+ */
155
+ getNetworkStatus(): NetworkStatus;
156
+ /**
157
+ * Load a container script by ID
158
+ */
159
+ loadScript(scriptId: string): void;
160
+ /**
161
+ * Get loaded container scripts
162
+ */
163
+ getLoadedScripts(): string[];
164
+ /**
165
+ * Debug logging
166
+ */
167
+ private log;
168
+ /**
169
+ * Destroy the SDK instance and cleanup resources
170
+ */
171
+ destroy(): void;
172
+ }
173
+ declare const datalyr: Datalyr;
174
+ export default datalyr;
175
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EAEb,aAAa,EACb,SAAS,EAEV,MAAM,SAAS,CAAC;AAGjB,cAAc,SAAS,CAAC;AAExB,cAAM,OAAO;IACX,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO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
4
+ import type { IngestEventPayload, NetworkStatus } from './types';
5
+ export declare class EventQueue {
6
+ private queue;
7
+ private offlineQueue;
8
+ private batchTimer;
9
+ private periodicFlushInterval;
10
+ private flushPromise;
11
+ private networkStatus;
12
+ private config;
13
+ private recentEventIds;
14
+ private MAX_RECENT_EVENT_IDS;
15
+ private OFFLINE_QUEUE_KEY;
16
+ private currentEndpointIndex;
17
+ constructor(config: any);
18
+ /**
19
+ * Add event to queue
20
+ */
21
+ enqueue(event: IngestEventPayload): void;
22
+ /**
23
+ * Check if event is duplicate
24
+ */
25
+ private isDuplicateEvent;
26
+ /**
27
+ * Check if we should flush the queue
28
+ */
29
+ private shouldFlush;
30
+ /**
31
+ * Flush the queue
32
+ */
33
+ flush(): Promise<void>;
34
+ /**
35
+ * Internal flush implementation
36
+ */
37
+ private _flush;
38
+ /**
39
+ * Send batch of events
40
+ */
41
+ private sendBatch;
42
+ /**
43
+ * Setup network status listeners
44
+ */
45
+ private setupNetworkListeners;
46
+ /**
47
+ * Start periodic flush timer
48
+ */
49
+ private startPeriodicFlush;
50
+ /**
51
+ * Stop periodic flush timer
52
+ */
53
+ private stopPeriodicFlush;
54
+ /**
55
+ * Move events to offline queue
56
+ */
57
+ private moveToOfflineQueue;
58
+ /**
59
+ * Load offline queue from storage
60
+ */
61
+ private loadOfflineQueue;
62
+ /**
63
+ * Save offline queue to storage
64
+ */
65
+ private saveOfflineQueue;
66
+ /**
67
+ * Process offline queue
68
+ */
69
+ private processOfflineQueue;
70
+ /**
71
+ * Get queue size
72
+ */
73
+ getQueueSize(): number;
74
+ /**
75
+ * Get offline queue size
76
+ */
77
+ getOfflineQueueSize(): number;
78
+ /**
79
+ * Get network status
80
+ */
81
+ getNetworkStatus(): NetworkStatus;
82
+ /**
83
+ * Force flush (for page unload)
84
+ */
85
+ forceFlush(): Promise<void>;
86
+ /**
87
+ * Clear queue
88
+ */
89
+ clear(): void;
90
+ /**
91
+ * Debug logging
92
+ */
93
+ private log;
94
+ /**
95
+ * Cleanup resources
96
+ */
97
+ destroy(): void;
98
+ }
99
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAsB,aAAa,EAAE,MAAM,SAAS,CAAC;AAQrF,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,qBAAqB,CAA+C;IAC5E,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAYZ;IACF,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,oBAAoB,CAAQ;IACpC,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,oBAAoB,CAAK;gBAErB,MAAM,EAAE,GAAG;IA0BvB;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IA0BxC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAW5B;;OAEG;YACW,MAAM;IAgCpB;;OAEG;YACW,SAAS;IA4DvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAQ1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;YACW,mBAAmB;IAyBjC;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAI7B;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBjC;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,CAAC,GAAG;IAMX;;OAEG;IACH,OAAO,IAAI,IAAI;CAWhB"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Session Management Module
3
+ */
4
+ import type { SessionData, Attribution } from './types';
5
+ export declare class SessionManager {
6
+ private sessionId;
7
+ private sessionData;
8
+ private sessionTimeout;
9
+ private lastActivity;
10
+ private SESSION_KEY;
11
+ private activityCheckInterval;
12
+ private activityListeners;
13
+ constructor(timeout?: number);
14
+ /**
15
+ * Initialize or restore session
16
+ */
17
+ private initSession;
18
+ /**
19
+ * Check if session is still valid
20
+ */
21
+ private isSessionValid;
22
+ /**
23
+ * Create a new session
24
+ */
25
+ createNewSession(): string;
26
+ /**
27
+ * Get current session ID
28
+ */
29
+ getSessionId(): string;
30
+ /**
31
+ * Get session data
32
+ */
33
+ getSessionData(): SessionData | null;
34
+ /**
35
+ * Update session activity
36
+ */
37
+ updateActivity(eventType?: string): void;
38
+ /**
39
+ * Check if session is active
40
+ */
41
+ isSessionActive(): boolean;
42
+ /**
43
+ * End the current session
44
+ */
45
+ endSession(): void;
46
+ /**
47
+ * Save session to storage
48
+ */
49
+ private saveSession;
50
+ /**
51
+ * Get session timeout
52
+ */
53
+ getTimeout(): number;
54
+ /**
55
+ * Set session timeout
56
+ */
57
+ setTimeout(timeout: number): void;
58
+ /**
59
+ * Store session attribution
60
+ */
61
+ storeAttribution(attribution: Attribution): void;
62
+ /**
63
+ * Get session attribution
64
+ */
65
+ getAttribution(): Attribution | null;
66
+ /**
67
+ * Get session metrics
68
+ */
69
+ getMetrics(): Record<string, any>;
70
+ /**
71
+ * Setup activity monitor for automatic session timeout
72
+ */
73
+ private setupActivityMonitor;
74
+ /**
75
+ * Cleanup listeners and timers
76
+ */
77
+ destroy(): void;
78
+ /**
79
+ * Get session number (count of sessions)
80
+ */
81
+ getSessionNumber(): number;
82
+ /**
83
+ * Increment session count
84
+ */
85
+ private incrementSessionCount;
86
+ }
87
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExD,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,qBAAqB,CAA+C;IAC5E,OAAO,CAAC,iBAAiB,CAAwD;gBAErE,OAAO,SAAiB;IAMpC;;OAEG;IACH,OAAO,CAAC,WAAW;IAenB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAmB1B;;OAEG;IACH,YAAY,IAAI,MAAM;IAOtB;;OAEG;IACH,cAAc,IAAI,WAAW,GAAG,IAAI;IAIpC;;OAEG;IACH,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAsBxC;;OAEG;IACH,eAAe,IAAI,OAAO;IAO1B;;OAEG;IACH,UAAU,IAAI,IAAI;IASlB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAShD;;OAEG;IACH,cAAc,IAAI,WAAW,GAAG,IAAI;IAOpC;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAajC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAwB5B;;OAEG;IACH,OAAO,IAAI,IAAI;IAcf;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAK1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAI9B"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Storage Module
3
+ * Safe storage wrapper with fallbacks for Safari private mode
4
+ */
5
+ interface StorageWrapper {
6
+ get(key: string, defaultValue?: any): any;
7
+ set(key: string, value: any): boolean;
8
+ remove(key: string): boolean;
9
+ keys(): string[];
10
+ }
11
+ declare class SafeStorage implements StorageWrapper {
12
+ private storage;
13
+ private memory;
14
+ private prefix;
15
+ constructor(storage: Storage);
16
+ get(key: string, defaultValue?: any): any;
17
+ set(key: string, value: any): boolean;
18
+ remove(key: string): boolean;
19
+ keys(): string[];
20
+ }
21
+ declare class CookieStorage {
22
+ private domain;
23
+ private maxAge;
24
+ private sameSite;
25
+ private secure;
26
+ constructor(options?: {
27
+ domain?: string | 'auto';
28
+ maxAge?: number;
29
+ sameSite?: 'Strict' | 'Lax' | 'None';
30
+ secure?: boolean | 'auto';
31
+ });
32
+ get(name: string): string | null;
33
+ set(name: string, value: string, days?: number): boolean;
34
+ remove(name: string): boolean;
35
+ /**
36
+ * Auto-detect the best domain for cross-subdomain tracking
37
+ */
38
+ private getAutoDomain;
39
+ }
40
+ export declare const storage: SafeStorage;
41
+ export declare const sessionStorage: SafeStorage;
42
+ export { CookieStorage };
43
+ export declare const cookies: CookieStorage;
44
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,UAAU,cAAc;IACtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IAC1C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GA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AE,CAAC;AAGzB,eAAO,MAAM,OAAO,eAAsB,CAAC"}
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Datalyr Web SDK - Type Definitions
3
+ */
4
+ export interface DatalyrConfig {
5
+ workspaceId: string;
6
+ endpoint?: string;
7
+ debug?: boolean;
8
+ batchSize?: number;
9
+ flushInterval?: number;
10
+ flushAt?: number;
11
+ criticalEvents?: string[];
12
+ highPriorityEvents?: string[];
13
+ sessionTimeout?: number;
14
+ trackSessions?: boolean;
15
+ attributionWindow?: number;
16
+ trackedParams?: string[];
17
+ respectDoNotTrack?: boolean;
18
+ respectGlobalPrivacyControl?: boolean;
19
+ privacyMode?: 'standard' | 'strict';
20
+ cookieDomain?: string | 'auto';
21
+ cookieExpires?: number;
22
+ secureCookie?: boolean | 'auto';
23
+ sameSite?: 'Strict' | 'Lax' | 'None';
24
+ cookiePrefix?: string;
25
+ enablePerformanceTracking?: boolean;
26
+ enableFingerprinting?: boolean;
27
+ maxRetries?: number;
28
+ retryDelay?: number;
29
+ maxOfflineQueueSize?: number;
30
+ trackSPA?: boolean;
31
+ trackPageViews?: boolean;
32
+ enableContainer?: boolean;
33
+ fallbackEndpoints?: string[];
34
+ plugins?: DatalyrPlugin[];
35
+ }
36
+ export interface EventProperties {
37
+ [key: string]: any;
38
+ value?: number;
39
+ currency?: string;
40
+ product_id?: string;
41
+ product_name?: string;
42
+ category?: string;
43
+ quantity?: number;
44
+ price?: number;
45
+ utm_source?: string;
46
+ utm_medium?: string;
47
+ utm_campaign?: string;
48
+ utm_term?: string;
49
+ utm_content?: string;
50
+ fbclid?: string;
51
+ gclid?: string;
52
+ ttclid?: string;
53
+ msclkid?: string;
54
+ twclid?: string;
55
+ li_fat_id?: string;
56
+ }
57
+ export interface UserTraits {
58
+ [key: string]: any;
59
+ email?: string;
60
+ name?: string;
61
+ firstName?: string;
62
+ lastName?: string;
63
+ phone?: string;
64
+ avatar?: string;
65
+ createdAt?: string | Date;
66
+ plan?: string;
67
+ }
68
+ export interface PageProperties {
69
+ title?: string;
70
+ url?: string;
71
+ path?: string;
72
+ referrer?: string;
73
+ search?: string;
74
+ [key: string]: any;
75
+ }
76
+ export interface SessionData {
77
+ id: string;
78
+ startTime: number;
79
+ lastActivity: number;
80
+ pageViews: number;
81
+ events: number;
82
+ duration: number;
83
+ isActive: boolean;
84
+ }
85
+ export interface Attribution {
86
+ source?: string | null;
87
+ medium?: string | null;
88
+ campaign?: string | null;
89
+ term?: string | null;
90
+ content?: string | null;
91
+ clickId?: string | null;
92
+ clickIdType?: string | null;
93
+ referrer?: string | null;
94
+ referrerHost?: string | null;
95
+ landingPage?: string | null;
96
+ landingPath?: string | null;
97
+ timestamp?: number;
98
+ [key: string]: any;
99
+ }
100
+ export interface TouchPoint {
101
+ timestamp: number;
102
+ source?: string;
103
+ medium?: string;
104
+ campaign?: string;
105
+ sessionId: string;
106
+ }
107
+ export interface ConsentConfig {
108
+ analytics?: boolean;
109
+ marketing?: boolean;
110
+ preferences?: boolean;
111
+ sale?: boolean;
112
+ }
113
+ export interface DatalyrPlugin {
114
+ name: string;
115
+ initialize(datalyr: any): void;
116
+ page?(properties: PageProperties): void;
117
+ track?(eventName: string, properties: EventProperties): void;
118
+ identify?(userId: string, traits: UserTraits): void;
119
+ loaded?(): void;
120
+ }
121
+ export interface FingerprintData {
122
+ userAgent?: string | null;
123
+ userAgentData?: {
124
+ brands?: any[];
125
+ mobile?: boolean;
126
+ platform?: string | null;
127
+ };
128
+ language?: string | null;
129
+ languages?: string[] | null;
130
+ platform?: string | null;
131
+ cookieEnabled?: boolean | null;
132
+ doNotTrack?: string | null;
133
+ hardwareConcurrency?: string | number | null;
134
+ deviceMemory?: string | number | null;
135
+ maxTouchPoints?: string | null;
136
+ screenResolution?: string | null;
137
+ colorDepth?: number | null;
138
+ pixelRatio?: string | null;
139
+ timezone?: string | null;
140
+ timezoneOffset?: number | null;
141
+ canvasEnabled?: boolean;
142
+ webglVendor?: string | null;
143
+ webglRenderer?: string | null;
144
+ audioSampleRate?: number | null;
145
+ audioState?: string | null;
146
+ audioMaxChannels?: number | null;
147
+ pluginsCount?: number | null;
148
+ localStorageAvailable?: boolean;
149
+ sessionStorageAvailable?: boolean;
150
+ indexedDBAvailable?: boolean;
151
+ }
152
+ export interface IngestEventPayload {
153
+ workspaceId: string;
154
+ workspace_id?: string;
155
+ distinct_id: string;
156
+ anonymous_id: string;
157
+ user_id?: string;
158
+ visitor_id: string;
159
+ visitorId: string;
160
+ canonical_id: string;
161
+ eventId: string;
162
+ event_id?: string;
163
+ eventName: string;
164
+ event_name?: string;
165
+ eventData: Record<string, any>;
166
+ event_data?: Record<string, any>;
167
+ sessionId: string;
168
+ session_id: string;
169
+ utm_source?: string;
170
+ utm_medium?: string;
171
+ utm_campaign?: string;
172
+ utm_term?: string;
173
+ utm_content?: string;
174
+ fingerprintData?: FingerprintData;
175
+ fingerprint_data?: FingerprintData;
176
+ source: 'web';
177
+ resolution_method: 'browser_sdk';
178
+ resolution_confidence: 1.0;
179
+ timestamp?: string;
180
+ received_at?: string;
181
+ }
182
+ export interface IngestBatchPayload {
183
+ events: IngestEventPayload[];
184
+ batchId: string;
185
+ timestamp: string;
186
+ }
187
+ export interface NetworkStatus {
188
+ isOnline: boolean;
189
+ lastOfflineAt: number | null;
190
+ lastOnlineAt: number | null;
191
+ }
192
+ export interface ErrorInfo {
193
+ message: string;
194
+ stack?: string;
195
+ context?: any;
196
+ timestamp: string;
197
+ url: string;
198
+ }
199
+ export interface PerformanceMetrics {
200
+ pageLoadTime?: number;
201
+ domReadyTime?: number;
202
+ firstByteTime?: number;
203
+ dnsTime?: number;
204
+ tcpTime?: number;
205
+ requestTime?: number;
206
+ timeOnPage?: number;
207
+ scrollDepth?: number;
208
+ memoryUsed?: number;
209
+ protocol?: string;
210
+ }
211
+ //# sourceMappingURL=types.d.ts.map