@akson/cortex-analytics-react 2.0.1 → 2.1.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.
- package/package.json +3 -3
- package/dist/index.d.mts +0 -304
- package/dist/index.d.ts +0 -304
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akson/cortex-analytics-react",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Reusable React analytics components and hooks for @cortex ecosystem",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@akson/cortex-gtm": "^3.
|
|
26
|
-
"@akson/cortex-posthog": "^0.
|
|
25
|
+
"@akson/cortex-gtm": "^3.1.0",
|
|
26
|
+
"@akson/cortex-posthog": "^0.5.0",
|
|
27
27
|
"@akson/cortex-utilities": "^0.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/dist/index.d.mts
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export { ECOMMERCE_EVENTS, LEAD_GENERATION_EVENTS, LEAD_SCORES } from '@akson/cortex-utilities';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @akson/cortex-analytics-react - Type Definitions
|
|
7
|
-
* Reusable types for analytics tracking across React applications
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Analytics configuration for projects
|
|
12
|
-
*/
|
|
13
|
-
interface AnalyticsConfig {
|
|
14
|
-
platforms: {
|
|
15
|
-
gtm?: {
|
|
16
|
-
containerId: string;
|
|
17
|
-
workspaceId?: number;
|
|
18
|
-
publicId?: string;
|
|
19
|
-
};
|
|
20
|
-
posthog?: {
|
|
21
|
-
apiKey: string;
|
|
22
|
-
host?: string;
|
|
23
|
-
};
|
|
24
|
-
ga4?: {
|
|
25
|
-
measurementId: string;
|
|
26
|
-
};
|
|
27
|
-
googleAds?: {
|
|
28
|
-
accountId: string;
|
|
29
|
-
};
|
|
30
|
-
meta?: {
|
|
31
|
-
pixelId: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
conversions?: Record<string, string>;
|
|
35
|
-
funnel?: FunnelConfig;
|
|
36
|
-
debug?: boolean;
|
|
37
|
-
enableEnhancedConversions?: boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Funnel configuration
|
|
41
|
-
*/
|
|
42
|
-
interface FunnelConfig {
|
|
43
|
-
stages?: Record<string, string[]>;
|
|
44
|
-
scoring?: (stage: string) => number;
|
|
45
|
-
abandonmentTracking?: boolean;
|
|
46
|
-
sessionTimeout?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Event data for tracking
|
|
50
|
-
*/
|
|
51
|
-
interface EventData {
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
event_category?: string;
|
|
54
|
-
event_label?: string;
|
|
55
|
-
event_value?: number;
|
|
56
|
-
standardized_event?: boolean;
|
|
57
|
-
timestamp?: string;
|
|
58
|
-
sessionId?: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Lead event data
|
|
62
|
-
*/
|
|
63
|
-
interface LeadEventData extends EventData {
|
|
64
|
-
lead_score: number;
|
|
65
|
-
funnel_stage?: string;
|
|
66
|
-
contact_method?: string;
|
|
67
|
-
source?: string;
|
|
68
|
-
language?: string;
|
|
69
|
-
device?: "mobile" | "desktop" | "tablet";
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* E-commerce event data
|
|
73
|
-
*/
|
|
74
|
-
interface EcommerceEventData extends EventData {
|
|
75
|
-
value: number;
|
|
76
|
-
currency: string;
|
|
77
|
-
transaction_id?: string;
|
|
78
|
-
items?: Array<{
|
|
79
|
-
item_id?: string;
|
|
80
|
-
item_name: string;
|
|
81
|
-
price: number;
|
|
82
|
-
quantity?: number;
|
|
83
|
-
}>;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Funnel stage data
|
|
87
|
-
*/
|
|
88
|
-
interface FunnelStageData {
|
|
89
|
-
stage: string;
|
|
90
|
-
previousStage?: string;
|
|
91
|
-
timeOnStage?: number;
|
|
92
|
-
totalTimeInFunnel?: number;
|
|
93
|
-
experimentVariants?: Record<string, string>;
|
|
94
|
-
formData?: FormData;
|
|
95
|
-
scrollData?: ScrollData;
|
|
96
|
-
performanceData?: PerformanceData;
|
|
97
|
-
source?: string;
|
|
98
|
-
language?: string;
|
|
99
|
-
device?: "mobile" | "desktop" | "tablet";
|
|
100
|
-
sessionId?: string;
|
|
101
|
-
userAgent?: string;
|
|
102
|
-
viewport?: string;
|
|
103
|
-
screenResolution?: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Form tracking data
|
|
107
|
-
*/
|
|
108
|
-
interface FormData {
|
|
109
|
-
step?: number;
|
|
110
|
-
stepName?: string;
|
|
111
|
-
fieldsCompleted?: number;
|
|
112
|
-
totalFields?: number;
|
|
113
|
-
completionPercentage?: number;
|
|
114
|
-
filledFields?: string[];
|
|
115
|
-
emptyFields?: string[];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Scroll tracking data
|
|
119
|
-
*/
|
|
120
|
-
interface ScrollData {
|
|
121
|
-
maxScrollPercent?: number;
|
|
122
|
-
timeToMaxScroll?: number;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Performance tracking data
|
|
126
|
-
*/
|
|
127
|
-
interface PerformanceData {
|
|
128
|
-
pageLoadTime?: number;
|
|
129
|
-
timeToInteraction?: number;
|
|
130
|
-
dns?: number;
|
|
131
|
-
tcp?: number;
|
|
132
|
-
ttfb?: number;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* User data for enhanced conversions
|
|
136
|
-
*/
|
|
137
|
-
interface UserData {
|
|
138
|
-
email?: string;
|
|
139
|
-
phone?: string;
|
|
140
|
-
firstName?: string;
|
|
141
|
-
lastName?: string;
|
|
142
|
-
street?: string;
|
|
143
|
-
city?: string;
|
|
144
|
-
postalCode?: string;
|
|
145
|
-
country?: string;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Analytics context value
|
|
149
|
-
*/
|
|
150
|
-
interface AnalyticsContextValue {
|
|
151
|
-
config: AnalyticsConfig;
|
|
152
|
-
isReady: boolean;
|
|
153
|
-
track: (event: string, properties?: EventData) => void;
|
|
154
|
-
trackPageView: (pagePath: string, pageTitle?: string) => void;
|
|
155
|
-
trackInteraction: (category: string, action: string, label?: string, value?: number) => void;
|
|
156
|
-
trackLead: (event: string, data?: Partial<LeadEventData>) => void;
|
|
157
|
-
trackEcommerce: (event: string, data: Partial<EcommerceEventData>) => void;
|
|
158
|
-
trackFunnelStage: (stage: string, data?: Partial<FunnelStageData>) => void;
|
|
159
|
-
trackFunnelAbandonment: (lastStage: string, reason?: string, data?: Record<string, any>) => void;
|
|
160
|
-
trackFunnelConversion: (type: string, value?: number, data?: Record<string, any>) => void;
|
|
161
|
-
trackExperiment: (experimentName: string, variant: string, userId?: string) => void;
|
|
162
|
-
trackFeatureFlag: (flagName: string, value: boolean | string, userId?: string) => void;
|
|
163
|
-
identify: (userId: string, traits?: Record<string, any>) => void;
|
|
164
|
-
sendUserData: (userData: UserData) => void;
|
|
165
|
-
getSessionId: () => string;
|
|
166
|
-
getFunnelPath: () => string[];
|
|
167
|
-
getTimeInFunnel: () => number;
|
|
168
|
-
clearSession: () => void;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Storage utility functions
|
|
172
|
-
*/
|
|
173
|
-
interface StorageUtils {
|
|
174
|
-
safeGetStorage: (storageType: "localStorage" | "sessionStorage", key: string) => string | null;
|
|
175
|
-
safeSetStorage: (storageType: "localStorage" | "sessionStorage", key: string, value: string) => void;
|
|
176
|
-
safeRemoveStorage: (storageType: "localStorage" | "sessionStorage", key: string) => void;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Platform adapters interface
|
|
180
|
-
*/
|
|
181
|
-
interface PlatformAdapter {
|
|
182
|
-
isReady(): boolean;
|
|
183
|
-
track(event: string, properties?: Record<string, any>): void;
|
|
184
|
-
identify?(userId: string, traits?: Record<string, any>): void;
|
|
185
|
-
reset?(): void;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* GTM adapter interface
|
|
189
|
-
*/
|
|
190
|
-
interface GTMAdapter extends PlatformAdapter {
|
|
191
|
-
dataLayer: any[];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* PostHog adapter interface
|
|
195
|
-
*/
|
|
196
|
-
interface PostHogAdapter extends PlatformAdapter {
|
|
197
|
-
posthog: any;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
declare const AnalyticsContext: React.Context<AnalyticsContextValue | null>;
|
|
201
|
-
interface AnalyticsProviderProps {
|
|
202
|
-
config: AnalyticsConfig;
|
|
203
|
-
children: React.ReactNode;
|
|
204
|
-
}
|
|
205
|
-
declare function AnalyticsProvider({ config, children, }: AnalyticsProviderProps): react_jsx_runtime.JSX.Element;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Hook to access analytics functionality
|
|
209
|
-
* @throws Error if used outside of AnalyticsProvider
|
|
210
|
-
*/
|
|
211
|
-
declare function useAnalytics(): AnalyticsContextValue;
|
|
212
|
-
/**
|
|
213
|
-
* Hook for simplified tracking
|
|
214
|
-
*/
|
|
215
|
-
declare function useTrack(): {
|
|
216
|
-
track: (event: string, properties?: EventData) => void;
|
|
217
|
-
isReady: boolean;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Hook for funnel tracking
|
|
221
|
-
*/
|
|
222
|
-
declare function useFunnelTracking(): {
|
|
223
|
-
trackStage: (stage: string, data?: Partial<FunnelStageData>) => void;
|
|
224
|
-
trackAbandonment: (lastStage: string, reason?: string, data?: Record<string, any>) => void;
|
|
225
|
-
trackConversion: (type: string, value?: number, data?: Record<string, any>) => void;
|
|
226
|
-
getFunnelPath: () => string[];
|
|
227
|
-
getTimeInFunnel: () => number;
|
|
228
|
-
clearSession: () => void;
|
|
229
|
-
isReady: boolean;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Hook for lead tracking
|
|
233
|
-
*/
|
|
234
|
-
declare function useLeadTracking(): {
|
|
235
|
-
trackLead: (event: string, data?: Partial<LeadEventData>) => void;
|
|
236
|
-
sendUserData: (userData: UserData) => void;
|
|
237
|
-
isReady: boolean;
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Hook for e-commerce tracking
|
|
241
|
-
*/
|
|
242
|
-
declare function useEcommerceTracking(): {
|
|
243
|
-
trackEcommerce: (event: string, data: Partial<EcommerceEventData>) => void;
|
|
244
|
-
isReady: boolean;
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Hook for experiment tracking
|
|
248
|
-
*/
|
|
249
|
-
declare function useExperimentTracking(): {
|
|
250
|
-
trackExperiment: (experimentName: string, variant: string, userId?: string) => void;
|
|
251
|
-
trackFeatureFlag: (flagName: string, value: boolean | string, userId?: string) => void;
|
|
252
|
-
isReady: boolean;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Get or create session ID
|
|
257
|
-
*/
|
|
258
|
-
declare function getSessionId(): string;
|
|
259
|
-
/**
|
|
260
|
-
* Get funnel path
|
|
261
|
-
*/
|
|
262
|
-
declare function getFunnelPath(): string[];
|
|
263
|
-
/**
|
|
264
|
-
* Get time in funnel (seconds)
|
|
265
|
-
*/
|
|
266
|
-
declare function getTimeInFunnel(): number;
|
|
267
|
-
/**
|
|
268
|
-
* Clear session data
|
|
269
|
-
*/
|
|
270
|
-
declare function clearSession(): void;
|
|
271
|
-
/**
|
|
272
|
-
* Get device type based on viewport
|
|
273
|
-
*/
|
|
274
|
-
declare function getDeviceType(): 'mobile' | 'desktop' | 'tablet';
|
|
275
|
-
/**
|
|
276
|
-
* Get performance data
|
|
277
|
-
*/
|
|
278
|
-
declare function getPerformanceData(): {
|
|
279
|
-
pageLoadTime: number;
|
|
280
|
-
timeToInteraction: number;
|
|
281
|
-
dns: number;
|
|
282
|
-
tcp: number;
|
|
283
|
-
ttfb: number;
|
|
284
|
-
} | undefined;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Safe storage utilities for browser environments
|
|
288
|
-
* Handles storage access errors gracefully
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Safely get value from storage
|
|
293
|
-
*/
|
|
294
|
-
declare const safeGetStorage: StorageUtils['safeGetStorage'];
|
|
295
|
-
/**
|
|
296
|
-
* Safely set value in storage
|
|
297
|
-
*/
|
|
298
|
-
declare const safeSetStorage: StorageUtils['safeSetStorage'];
|
|
299
|
-
/**
|
|
300
|
-
* Safely remove value from storage
|
|
301
|
-
*/
|
|
302
|
-
declare const safeRemoveStorage: StorageUtils['safeRemoveStorage'];
|
|
303
|
-
|
|
304
|
-
export { type AnalyticsConfig, AnalyticsContext, type AnalyticsContextValue, AnalyticsProvider, type EcommerceEventData, type EventData, type FormData, type FunnelConfig, type FunnelStageData, type GTMAdapter, type LeadEventData, type PerformanceData, type PlatformAdapter, type PostHogAdapter, type ScrollData, type UserData, clearSession, getDeviceType, getFunnelPath, getPerformanceData, getSessionId, getTimeInFunnel, safeGetStorage, safeRemoveStorage, safeSetStorage, useAnalytics, useEcommerceTracking, useExperimentTracking, useFunnelTracking, useLeadTracking, useTrack };
|
package/dist/index.d.ts
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export { ECOMMERCE_EVENTS, LEAD_GENERATION_EVENTS, LEAD_SCORES } from '@akson/cortex-utilities';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @akson/cortex-analytics-react - Type Definitions
|
|
7
|
-
* Reusable types for analytics tracking across React applications
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Analytics configuration for projects
|
|
12
|
-
*/
|
|
13
|
-
interface AnalyticsConfig {
|
|
14
|
-
platforms: {
|
|
15
|
-
gtm?: {
|
|
16
|
-
containerId: string;
|
|
17
|
-
workspaceId?: number;
|
|
18
|
-
publicId?: string;
|
|
19
|
-
};
|
|
20
|
-
posthog?: {
|
|
21
|
-
apiKey: string;
|
|
22
|
-
host?: string;
|
|
23
|
-
};
|
|
24
|
-
ga4?: {
|
|
25
|
-
measurementId: string;
|
|
26
|
-
};
|
|
27
|
-
googleAds?: {
|
|
28
|
-
accountId: string;
|
|
29
|
-
};
|
|
30
|
-
meta?: {
|
|
31
|
-
pixelId: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
conversions?: Record<string, string>;
|
|
35
|
-
funnel?: FunnelConfig;
|
|
36
|
-
debug?: boolean;
|
|
37
|
-
enableEnhancedConversions?: boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Funnel configuration
|
|
41
|
-
*/
|
|
42
|
-
interface FunnelConfig {
|
|
43
|
-
stages?: Record<string, string[]>;
|
|
44
|
-
scoring?: (stage: string) => number;
|
|
45
|
-
abandonmentTracking?: boolean;
|
|
46
|
-
sessionTimeout?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Event data for tracking
|
|
50
|
-
*/
|
|
51
|
-
interface EventData {
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
event_category?: string;
|
|
54
|
-
event_label?: string;
|
|
55
|
-
event_value?: number;
|
|
56
|
-
standardized_event?: boolean;
|
|
57
|
-
timestamp?: string;
|
|
58
|
-
sessionId?: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Lead event data
|
|
62
|
-
*/
|
|
63
|
-
interface LeadEventData extends EventData {
|
|
64
|
-
lead_score: number;
|
|
65
|
-
funnel_stage?: string;
|
|
66
|
-
contact_method?: string;
|
|
67
|
-
source?: string;
|
|
68
|
-
language?: string;
|
|
69
|
-
device?: "mobile" | "desktop" | "tablet";
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* E-commerce event data
|
|
73
|
-
*/
|
|
74
|
-
interface EcommerceEventData extends EventData {
|
|
75
|
-
value: number;
|
|
76
|
-
currency: string;
|
|
77
|
-
transaction_id?: string;
|
|
78
|
-
items?: Array<{
|
|
79
|
-
item_id?: string;
|
|
80
|
-
item_name: string;
|
|
81
|
-
price: number;
|
|
82
|
-
quantity?: number;
|
|
83
|
-
}>;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Funnel stage data
|
|
87
|
-
*/
|
|
88
|
-
interface FunnelStageData {
|
|
89
|
-
stage: string;
|
|
90
|
-
previousStage?: string;
|
|
91
|
-
timeOnStage?: number;
|
|
92
|
-
totalTimeInFunnel?: number;
|
|
93
|
-
experimentVariants?: Record<string, string>;
|
|
94
|
-
formData?: FormData;
|
|
95
|
-
scrollData?: ScrollData;
|
|
96
|
-
performanceData?: PerformanceData;
|
|
97
|
-
source?: string;
|
|
98
|
-
language?: string;
|
|
99
|
-
device?: "mobile" | "desktop" | "tablet";
|
|
100
|
-
sessionId?: string;
|
|
101
|
-
userAgent?: string;
|
|
102
|
-
viewport?: string;
|
|
103
|
-
screenResolution?: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Form tracking data
|
|
107
|
-
*/
|
|
108
|
-
interface FormData {
|
|
109
|
-
step?: number;
|
|
110
|
-
stepName?: string;
|
|
111
|
-
fieldsCompleted?: number;
|
|
112
|
-
totalFields?: number;
|
|
113
|
-
completionPercentage?: number;
|
|
114
|
-
filledFields?: string[];
|
|
115
|
-
emptyFields?: string[];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Scroll tracking data
|
|
119
|
-
*/
|
|
120
|
-
interface ScrollData {
|
|
121
|
-
maxScrollPercent?: number;
|
|
122
|
-
timeToMaxScroll?: number;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Performance tracking data
|
|
126
|
-
*/
|
|
127
|
-
interface PerformanceData {
|
|
128
|
-
pageLoadTime?: number;
|
|
129
|
-
timeToInteraction?: number;
|
|
130
|
-
dns?: number;
|
|
131
|
-
tcp?: number;
|
|
132
|
-
ttfb?: number;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* User data for enhanced conversions
|
|
136
|
-
*/
|
|
137
|
-
interface UserData {
|
|
138
|
-
email?: string;
|
|
139
|
-
phone?: string;
|
|
140
|
-
firstName?: string;
|
|
141
|
-
lastName?: string;
|
|
142
|
-
street?: string;
|
|
143
|
-
city?: string;
|
|
144
|
-
postalCode?: string;
|
|
145
|
-
country?: string;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Analytics context value
|
|
149
|
-
*/
|
|
150
|
-
interface AnalyticsContextValue {
|
|
151
|
-
config: AnalyticsConfig;
|
|
152
|
-
isReady: boolean;
|
|
153
|
-
track: (event: string, properties?: EventData) => void;
|
|
154
|
-
trackPageView: (pagePath: string, pageTitle?: string) => void;
|
|
155
|
-
trackInteraction: (category: string, action: string, label?: string, value?: number) => void;
|
|
156
|
-
trackLead: (event: string, data?: Partial<LeadEventData>) => void;
|
|
157
|
-
trackEcommerce: (event: string, data: Partial<EcommerceEventData>) => void;
|
|
158
|
-
trackFunnelStage: (stage: string, data?: Partial<FunnelStageData>) => void;
|
|
159
|
-
trackFunnelAbandonment: (lastStage: string, reason?: string, data?: Record<string, any>) => void;
|
|
160
|
-
trackFunnelConversion: (type: string, value?: number, data?: Record<string, any>) => void;
|
|
161
|
-
trackExperiment: (experimentName: string, variant: string, userId?: string) => void;
|
|
162
|
-
trackFeatureFlag: (flagName: string, value: boolean | string, userId?: string) => void;
|
|
163
|
-
identify: (userId: string, traits?: Record<string, any>) => void;
|
|
164
|
-
sendUserData: (userData: UserData) => void;
|
|
165
|
-
getSessionId: () => string;
|
|
166
|
-
getFunnelPath: () => string[];
|
|
167
|
-
getTimeInFunnel: () => number;
|
|
168
|
-
clearSession: () => void;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Storage utility functions
|
|
172
|
-
*/
|
|
173
|
-
interface StorageUtils {
|
|
174
|
-
safeGetStorage: (storageType: "localStorage" | "sessionStorage", key: string) => string | null;
|
|
175
|
-
safeSetStorage: (storageType: "localStorage" | "sessionStorage", key: string, value: string) => void;
|
|
176
|
-
safeRemoveStorage: (storageType: "localStorage" | "sessionStorage", key: string) => void;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Platform adapters interface
|
|
180
|
-
*/
|
|
181
|
-
interface PlatformAdapter {
|
|
182
|
-
isReady(): boolean;
|
|
183
|
-
track(event: string, properties?: Record<string, any>): void;
|
|
184
|
-
identify?(userId: string, traits?: Record<string, any>): void;
|
|
185
|
-
reset?(): void;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* GTM adapter interface
|
|
189
|
-
*/
|
|
190
|
-
interface GTMAdapter extends PlatformAdapter {
|
|
191
|
-
dataLayer: any[];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* PostHog adapter interface
|
|
195
|
-
*/
|
|
196
|
-
interface PostHogAdapter extends PlatformAdapter {
|
|
197
|
-
posthog: any;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
declare const AnalyticsContext: React.Context<AnalyticsContextValue | null>;
|
|
201
|
-
interface AnalyticsProviderProps {
|
|
202
|
-
config: AnalyticsConfig;
|
|
203
|
-
children: React.ReactNode;
|
|
204
|
-
}
|
|
205
|
-
declare function AnalyticsProvider({ config, children, }: AnalyticsProviderProps): react_jsx_runtime.JSX.Element;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Hook to access analytics functionality
|
|
209
|
-
* @throws Error if used outside of AnalyticsProvider
|
|
210
|
-
*/
|
|
211
|
-
declare function useAnalytics(): AnalyticsContextValue;
|
|
212
|
-
/**
|
|
213
|
-
* Hook for simplified tracking
|
|
214
|
-
*/
|
|
215
|
-
declare function useTrack(): {
|
|
216
|
-
track: (event: string, properties?: EventData) => void;
|
|
217
|
-
isReady: boolean;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Hook for funnel tracking
|
|
221
|
-
*/
|
|
222
|
-
declare function useFunnelTracking(): {
|
|
223
|
-
trackStage: (stage: string, data?: Partial<FunnelStageData>) => void;
|
|
224
|
-
trackAbandonment: (lastStage: string, reason?: string, data?: Record<string, any>) => void;
|
|
225
|
-
trackConversion: (type: string, value?: number, data?: Record<string, any>) => void;
|
|
226
|
-
getFunnelPath: () => string[];
|
|
227
|
-
getTimeInFunnel: () => number;
|
|
228
|
-
clearSession: () => void;
|
|
229
|
-
isReady: boolean;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Hook for lead tracking
|
|
233
|
-
*/
|
|
234
|
-
declare function useLeadTracking(): {
|
|
235
|
-
trackLead: (event: string, data?: Partial<LeadEventData>) => void;
|
|
236
|
-
sendUserData: (userData: UserData) => void;
|
|
237
|
-
isReady: boolean;
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Hook for e-commerce tracking
|
|
241
|
-
*/
|
|
242
|
-
declare function useEcommerceTracking(): {
|
|
243
|
-
trackEcommerce: (event: string, data: Partial<EcommerceEventData>) => void;
|
|
244
|
-
isReady: boolean;
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Hook for experiment tracking
|
|
248
|
-
*/
|
|
249
|
-
declare function useExperimentTracking(): {
|
|
250
|
-
trackExperiment: (experimentName: string, variant: string, userId?: string) => void;
|
|
251
|
-
trackFeatureFlag: (flagName: string, value: boolean | string, userId?: string) => void;
|
|
252
|
-
isReady: boolean;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Get or create session ID
|
|
257
|
-
*/
|
|
258
|
-
declare function getSessionId(): string;
|
|
259
|
-
/**
|
|
260
|
-
* Get funnel path
|
|
261
|
-
*/
|
|
262
|
-
declare function getFunnelPath(): string[];
|
|
263
|
-
/**
|
|
264
|
-
* Get time in funnel (seconds)
|
|
265
|
-
*/
|
|
266
|
-
declare function getTimeInFunnel(): number;
|
|
267
|
-
/**
|
|
268
|
-
* Clear session data
|
|
269
|
-
*/
|
|
270
|
-
declare function clearSession(): void;
|
|
271
|
-
/**
|
|
272
|
-
* Get device type based on viewport
|
|
273
|
-
*/
|
|
274
|
-
declare function getDeviceType(): 'mobile' | 'desktop' | 'tablet';
|
|
275
|
-
/**
|
|
276
|
-
* Get performance data
|
|
277
|
-
*/
|
|
278
|
-
declare function getPerformanceData(): {
|
|
279
|
-
pageLoadTime: number;
|
|
280
|
-
timeToInteraction: number;
|
|
281
|
-
dns: number;
|
|
282
|
-
tcp: number;
|
|
283
|
-
ttfb: number;
|
|
284
|
-
} | undefined;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Safe storage utilities for browser environments
|
|
288
|
-
* Handles storage access errors gracefully
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Safely get value from storage
|
|
293
|
-
*/
|
|
294
|
-
declare const safeGetStorage: StorageUtils['safeGetStorage'];
|
|
295
|
-
/**
|
|
296
|
-
* Safely set value in storage
|
|
297
|
-
*/
|
|
298
|
-
declare const safeSetStorage: StorageUtils['safeSetStorage'];
|
|
299
|
-
/**
|
|
300
|
-
* Safely remove value from storage
|
|
301
|
-
*/
|
|
302
|
-
declare const safeRemoveStorage: StorageUtils['safeRemoveStorage'];
|
|
303
|
-
|
|
304
|
-
export { type AnalyticsConfig, AnalyticsContext, type AnalyticsContextValue, AnalyticsProvider, type EcommerceEventData, type EventData, type FormData, type FunnelConfig, type FunnelStageData, type GTMAdapter, type LeadEventData, type PerformanceData, type PlatformAdapter, type PostHogAdapter, type ScrollData, type UserData, clearSession, getDeviceType, getFunnelPath, getPerformanceData, getSessionId, getTimeInFunnel, safeGetStorage, safeRemoveStorage, safeSetStorage, useAnalytics, useEcommerceTracking, useExperimentTracking, useFunnelTracking, useLeadTracking, useTrack };
|