flowgrid-sdk 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.
- package/LICENSE +21 -0
- package/dist/browser.d.ts +119 -0
- package/dist/flowgrid.min.js +2 -0
- package/dist/flowgrid.min.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client/enterprise-ftrpc.d.ts +51 -0
- package/dist/lib/client/ftrpc.d.ts +43 -0
- package/dist/lib/client/modules.d.ts +104 -0
- package/dist/lib/features/analytics/attribution.d.ts +257 -0
- package/dist/lib/features/analytics/events.d.ts +304 -0
- package/dist/lib/features/analytics/funnels.d.ts +291 -0
- package/dist/lib/features/analytics/heatmaps.d.ts +247 -0
- package/dist/lib/features/analytics/identify.d.ts +273 -0
- package/dist/lib/features/analytics/index.d.ts +22 -0
- package/dist/lib/features/analytics/page-views.d.ts +250 -0
- package/dist/lib/features/analytics/performance.d.ts +281 -0
- package/dist/lib/features/analytics/retention.d.ts +294 -0
- package/dist/lib/features/analytics/sessions.d.ts +277 -0
- package/dist/lib/features/core/activation.d.ts +239 -0
- package/dist/lib/features/core/experiment.d.ts +286 -0
- package/dist/lib/features/core/feature-flag.d.ts +264 -0
- package/dist/lib/features/core/index.d.ts +14 -0
- package/dist/lib/features/core/track-feature.d.ts +220 -0
- package/dist/lib/features/core/track-prompt.d.ts +247 -0
- package/dist/lib/features/ecommerce/cart.d.ts +298 -0
- package/dist/lib/features/ecommerce/checkout.d.ts +324 -0
- package/dist/lib/features/ecommerce/index.d.ts +26 -0
- package/dist/lib/features/ecommerce/inventory.d.ts +221 -0
- package/dist/lib/features/ecommerce/ltv.d.ts +258 -0
- package/dist/lib/features/ecommerce/products.d.ts +268 -0
- package/dist/lib/features/ecommerce/promotions.d.ts +266 -0
- package/dist/lib/features/ecommerce/purchases.d.ts +287 -0
- package/dist/lib/features/ecommerce/refunds.d.ts +232 -0
- package/dist/lib/features/ecommerce/search.d.ts +225 -0
- package/dist/lib/features/ecommerce/subscriptions.d.ts +281 -0
- package/dist/lib/features/ecommerce/wishlist.d.ts +236 -0
- package/dist/lib/features/enterprise/acquisition.d.ts +373 -0
- package/dist/lib/features/enterprise/alerts.d.ts +348 -0
- package/dist/lib/features/enterprise/churn.d.ts +288 -0
- package/dist/lib/features/enterprise/cohorts.d.ts +270 -0
- package/dist/lib/features/enterprise/engagement.d.ts +233 -0
- package/dist/lib/features/enterprise/forecasting.d.ts +351 -0
- package/dist/lib/features/enterprise/index.d.ts +20 -0
- package/dist/lib/features/enterprise/monetization.d.ts +356 -0
- package/dist/lib/features/enterprise/multi-path-funnels.d.ts +327 -0
- package/dist/lib/features/enterprise/paths.d.ts +332 -0
- package/dist/lib/features/enterprise/security.d.ts +387 -0
- package/dist/lib/features/enterprise/support.d.ts +329 -0
- package/dist/lib/frameworks/index.d.ts +9 -0
- package/dist/lib/frameworks/nextjs/client.d.ts +208 -0
- package/dist/lib/frameworks/nextjs/index.d.ts +29 -0
- package/dist/lib/frameworks/nextjs/server.d.ts +201 -0
- package/dist/lib/frameworks/node/index.d.ts +265 -0
- package/dist/lib/frameworks/nuxt/index.d.ts +190 -0
- package/dist/lib/frameworks/react/index.d.ts +245 -0
- package/dist/lib/frameworks/vue/index.d.ts +275 -0
- package/dist/lib/types/analytics.d.ts +365 -0
- package/dist/lib/types/common.d.ts +230 -0
- package/dist/lib/types/ecommerce.d.ts +309 -0
- package/dist/lib/types/index.d.ts +7 -0
- package/dist/lib/utils/functions.d.ts +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for product analytics tracking.
|
|
3
|
+
* @module types/analytics
|
|
4
|
+
*/
|
|
5
|
+
import { UserIdentity, DeviceInfo, GeoLocation, TimeSeriesData } from './common';
|
|
6
|
+
/**
|
|
7
|
+
* Page view information.
|
|
8
|
+
*/
|
|
9
|
+
export interface PageView {
|
|
10
|
+
/** Page URL */
|
|
11
|
+
url: string;
|
|
12
|
+
/** Page path (without domain) */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Page title */
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Referrer URL */
|
|
17
|
+
referrer?: string;
|
|
18
|
+
/** Time spent on page (seconds) */
|
|
19
|
+
timeOnPage?: number;
|
|
20
|
+
/** Scroll depth (0-100) */
|
|
21
|
+
scrollDepth?: number;
|
|
22
|
+
/** Whether user exited from this page */
|
|
23
|
+
isExit?: boolean;
|
|
24
|
+
/** Whether this was the landing page */
|
|
25
|
+
isLanding?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Session information.
|
|
29
|
+
*/
|
|
30
|
+
export interface Session {
|
|
31
|
+
/** Session identifier */
|
|
32
|
+
sessionId: string;
|
|
33
|
+
/** User identity */
|
|
34
|
+
user?: UserIdentity;
|
|
35
|
+
/** Session start time */
|
|
36
|
+
startedAt: string;
|
|
37
|
+
/** Session end time (if ended) */
|
|
38
|
+
endedAt?: string;
|
|
39
|
+
/** Session duration in seconds */
|
|
40
|
+
duration?: number;
|
|
41
|
+
/** Number of pages viewed */
|
|
42
|
+
pageViews: number;
|
|
43
|
+
/** Number of events triggered */
|
|
44
|
+
eventCount: number;
|
|
45
|
+
/** Landing page URL */
|
|
46
|
+
landingPage?: string;
|
|
47
|
+
/** Exit page URL */
|
|
48
|
+
exitPage?: string;
|
|
49
|
+
/** Traffic source */
|
|
50
|
+
source?: string;
|
|
51
|
+
/** Traffic medium */
|
|
52
|
+
medium?: string;
|
|
53
|
+
/** Campaign */
|
|
54
|
+
campaign?: string;
|
|
55
|
+
/** Device info */
|
|
56
|
+
device?: DeviceInfo;
|
|
57
|
+
/** Location */
|
|
58
|
+
location?: GeoLocation;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Custom event tracking.
|
|
62
|
+
*/
|
|
63
|
+
export interface CustomEvent {
|
|
64
|
+
/** Event name */
|
|
65
|
+
eventName: string;
|
|
66
|
+
/** Event category */
|
|
67
|
+
category?: string;
|
|
68
|
+
/** Event action */
|
|
69
|
+
action?: string;
|
|
70
|
+
/** Event label */
|
|
71
|
+
label?: string;
|
|
72
|
+
/** Event value (numeric) */
|
|
73
|
+
value?: number;
|
|
74
|
+
/** Whether this event is non-interactive */
|
|
75
|
+
nonInteraction?: boolean;
|
|
76
|
+
/** Custom properties */
|
|
77
|
+
properties?: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Click/tap event.
|
|
81
|
+
*/
|
|
82
|
+
export interface ClickEvent {
|
|
83
|
+
/** Element ID that was clicked */
|
|
84
|
+
elementId?: string;
|
|
85
|
+
/** Element class */
|
|
86
|
+
elementClass?: string;
|
|
87
|
+
/** Element text content */
|
|
88
|
+
elementText?: string;
|
|
89
|
+
/** Element tag name */
|
|
90
|
+
elementTag?: string;
|
|
91
|
+
/** Target URL (for links) */
|
|
92
|
+
targetUrl?: string;
|
|
93
|
+
/** Click coordinates */
|
|
94
|
+
coordinates?: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Form submission event.
|
|
101
|
+
*/
|
|
102
|
+
export interface FormEvent {
|
|
103
|
+
/** Form ID */
|
|
104
|
+
formId?: string;
|
|
105
|
+
/** Form name */
|
|
106
|
+
formName?: string;
|
|
107
|
+
/** Form action URL */
|
|
108
|
+
formAction?: string;
|
|
109
|
+
/** Whether submission was successful */
|
|
110
|
+
success: boolean;
|
|
111
|
+
/** Field names submitted (without values for privacy) */
|
|
112
|
+
fields?: string[];
|
|
113
|
+
/** Validation errors (field names only) */
|
|
114
|
+
validationErrors?: string[];
|
|
115
|
+
/** Time to complete form (seconds) */
|
|
116
|
+
completionTime?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Search event.
|
|
120
|
+
*/
|
|
121
|
+
export interface SearchEvent {
|
|
122
|
+
/** Search query */
|
|
123
|
+
query: string;
|
|
124
|
+
/** Search category/scope */
|
|
125
|
+
category?: string;
|
|
126
|
+
/** Number of results */
|
|
127
|
+
resultsCount?: number;
|
|
128
|
+
/** Whether any results were clicked */
|
|
129
|
+
resultClicked?: boolean;
|
|
130
|
+
/** Position of clicked result */
|
|
131
|
+
clickedPosition?: number;
|
|
132
|
+
/** Search filters applied */
|
|
133
|
+
filters?: Record<string, string | string[]>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Error/exception event.
|
|
137
|
+
*/
|
|
138
|
+
export interface ErrorEvent {
|
|
139
|
+
/** Error message */
|
|
140
|
+
message: string;
|
|
141
|
+
/** Error stack trace */
|
|
142
|
+
stack?: string;
|
|
143
|
+
/** Error type/name */
|
|
144
|
+
type?: string;
|
|
145
|
+
/** Whether it was fatal */
|
|
146
|
+
fatal?: boolean;
|
|
147
|
+
/** Page/component where error occurred */
|
|
148
|
+
context?: string;
|
|
149
|
+
/** User action that triggered error */
|
|
150
|
+
userAction?: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Feature usage tracking.
|
|
154
|
+
*/
|
|
155
|
+
export interface FeatureUsage {
|
|
156
|
+
/** Feature name */
|
|
157
|
+
featureName: string;
|
|
158
|
+
/** Feature category */
|
|
159
|
+
category?: string;
|
|
160
|
+
/** Action performed */
|
|
161
|
+
action: string;
|
|
162
|
+
/** Usage count */
|
|
163
|
+
usageCount?: number;
|
|
164
|
+
/** Time spent using feature (seconds) */
|
|
165
|
+
timeSpent?: number;
|
|
166
|
+
/** Whether feature was successfully used */
|
|
167
|
+
success?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* User engagement score factors.
|
|
171
|
+
*/
|
|
172
|
+
export interface EngagementFactors {
|
|
173
|
+
/** Days active in period */
|
|
174
|
+
daysActive: number;
|
|
175
|
+
/** Total sessions */
|
|
176
|
+
totalSessions: number;
|
|
177
|
+
/** Average session duration (seconds) */
|
|
178
|
+
avgSessionDuration: number;
|
|
179
|
+
/** Features used */
|
|
180
|
+
featuresUsed: number;
|
|
181
|
+
/** Actions taken */
|
|
182
|
+
actionsCount: number;
|
|
183
|
+
/** Content created/generated */
|
|
184
|
+
contentCreated: number;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Retention cohort data.
|
|
188
|
+
*/
|
|
189
|
+
export interface RetentionCohort {
|
|
190
|
+
/** Cohort identifier (e.g., "2026-01-W1") */
|
|
191
|
+
cohortId: string;
|
|
192
|
+
/** Cohort start date */
|
|
193
|
+
cohortDate: string;
|
|
194
|
+
/** Users in cohort */
|
|
195
|
+
cohortSize: number;
|
|
196
|
+
/** Retention by period (day/week/month index -> retained count) */
|
|
197
|
+
retention: Record<number, number>;
|
|
198
|
+
/** Retention percentages */
|
|
199
|
+
retentionPercent: Record<number, number>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Funnel step definition.
|
|
203
|
+
*/
|
|
204
|
+
export interface FunnelStep {
|
|
205
|
+
/** Step name */
|
|
206
|
+
name: string;
|
|
207
|
+
/** Step description */
|
|
208
|
+
description?: string;
|
|
209
|
+
/** Event(s) that trigger this step */
|
|
210
|
+
events: string[];
|
|
211
|
+
/** Users who reached this step */
|
|
212
|
+
users: number;
|
|
213
|
+
/** Conversion rate from previous step */
|
|
214
|
+
conversionRate: number;
|
|
215
|
+
/** Drop-off rate from previous step */
|
|
216
|
+
dropOffRate: number;
|
|
217
|
+
/** Average time to complete (seconds) */
|
|
218
|
+
avgTimeToComplete?: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Funnel analysis results.
|
|
222
|
+
*/
|
|
223
|
+
export interface FunnelAnalysis {
|
|
224
|
+
/** Funnel name */
|
|
225
|
+
name: string;
|
|
226
|
+
/** Funnel steps */
|
|
227
|
+
steps: FunnelStep[];
|
|
228
|
+
/** Overall conversion rate (first to last step) */
|
|
229
|
+
overallConversionRate: number;
|
|
230
|
+
/** Total users who entered funnel */
|
|
231
|
+
totalUsers: number;
|
|
232
|
+
/** Total users who completed funnel */
|
|
233
|
+
completedUsers: number;
|
|
234
|
+
/** Analysis period */
|
|
235
|
+
period: {
|
|
236
|
+
start: string;
|
|
237
|
+
end: string;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Traffic metrics.
|
|
242
|
+
*/
|
|
243
|
+
export interface TrafficMetrics {
|
|
244
|
+
/** Total visits/sessions */
|
|
245
|
+
totalVisits: number;
|
|
246
|
+
/** Unique visitors */
|
|
247
|
+
uniqueVisitors: number;
|
|
248
|
+
/** Page views */
|
|
249
|
+
pageViews: number;
|
|
250
|
+
/** Pages per session */
|
|
251
|
+
pagesPerSession: number;
|
|
252
|
+
/** Average session duration (seconds) */
|
|
253
|
+
avgSessionDuration: number;
|
|
254
|
+
/** Bounce rate (0-1) */
|
|
255
|
+
bounceRate: number;
|
|
256
|
+
/** New visitor rate (0-1) */
|
|
257
|
+
newVisitorRate: number;
|
|
258
|
+
/** Traffic over time */
|
|
259
|
+
trafficTimeSeries: TimeSeriesData;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Acquisition/source metrics.
|
|
263
|
+
*/
|
|
264
|
+
export interface AcquisitionMetrics {
|
|
265
|
+
/** Traffic by source */
|
|
266
|
+
bySource: Array<{
|
|
267
|
+
source: string;
|
|
268
|
+
visits: number;
|
|
269
|
+
uniqueVisitors: number;
|
|
270
|
+
bounceRate: number;
|
|
271
|
+
conversionRate: number;
|
|
272
|
+
}>;
|
|
273
|
+
/** Traffic by medium */
|
|
274
|
+
byMedium: Array<{
|
|
275
|
+
medium: string;
|
|
276
|
+
visits: number;
|
|
277
|
+
uniqueVisitors: number;
|
|
278
|
+
}>;
|
|
279
|
+
/** Traffic by campaign */
|
|
280
|
+
byCampaign: Array<{
|
|
281
|
+
campaign: string;
|
|
282
|
+
visits: number;
|
|
283
|
+
conversions: number;
|
|
284
|
+
revenue?: number;
|
|
285
|
+
}>;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* User behavior metrics.
|
|
289
|
+
*/
|
|
290
|
+
export interface BehaviorMetrics {
|
|
291
|
+
/** Top pages by views */
|
|
292
|
+
topPages: Array<{
|
|
293
|
+
path: string;
|
|
294
|
+
title: string;
|
|
295
|
+
views: number;
|
|
296
|
+
avgTimeOnPage: number;
|
|
297
|
+
bounceRate: number;
|
|
298
|
+
}>;
|
|
299
|
+
/** Top events */
|
|
300
|
+
topEvents: Array<{
|
|
301
|
+
eventName: string;
|
|
302
|
+
count: number;
|
|
303
|
+
uniqueUsers: number;
|
|
304
|
+
}>;
|
|
305
|
+
/** Top exit pages */
|
|
306
|
+
exitPages: Array<{
|
|
307
|
+
path: string;
|
|
308
|
+
exitRate: number;
|
|
309
|
+
exits: number;
|
|
310
|
+
}>;
|
|
311
|
+
/** Average scroll depth */
|
|
312
|
+
avgScrollDepth: number;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Real-time analytics.
|
|
316
|
+
*/
|
|
317
|
+
export interface RealTimeMetrics {
|
|
318
|
+
/** Current active users */
|
|
319
|
+
activeUsers: number;
|
|
320
|
+
/** Active users by page */
|
|
321
|
+
usersByPage: Array<{
|
|
322
|
+
path: string;
|
|
323
|
+
users: number;
|
|
324
|
+
}>;
|
|
325
|
+
/** Active users by location */
|
|
326
|
+
usersByCountry: Array<{
|
|
327
|
+
country: string;
|
|
328
|
+
users: number;
|
|
329
|
+
}>;
|
|
330
|
+
/** Active users by device */
|
|
331
|
+
usersByDevice: Array<{
|
|
332
|
+
device: string;
|
|
333
|
+
users: number;
|
|
334
|
+
}>;
|
|
335
|
+
/** Events in last minute */
|
|
336
|
+
eventsPerMinute: number;
|
|
337
|
+
/** Top events right now */
|
|
338
|
+
topEventsNow: Array<{
|
|
339
|
+
event: string;
|
|
340
|
+
count: number;
|
|
341
|
+
}>;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* User lifecycle stage.
|
|
345
|
+
*/
|
|
346
|
+
export type UserLifecycleStage = 'new' | 'activated' | 'engaged' | 'retained' | 'churned' | 'resurrected';
|
|
347
|
+
/**
|
|
348
|
+
* User lifecycle metrics.
|
|
349
|
+
*/
|
|
350
|
+
export interface LifecycleMetrics {
|
|
351
|
+
/** Users by lifecycle stage */
|
|
352
|
+
byStage: Record<UserLifecycleStage, number>;
|
|
353
|
+
/** Stage transitions this period */
|
|
354
|
+
transitions: Array<{
|
|
355
|
+
from: UserLifecycleStage;
|
|
356
|
+
to: UserLifecycleStage;
|
|
357
|
+
count: number;
|
|
358
|
+
}>;
|
|
359
|
+
/** Activation rate */
|
|
360
|
+
activationRate: number;
|
|
361
|
+
/** Churn rate */
|
|
362
|
+
churnRate: number;
|
|
363
|
+
/** Resurrection rate */
|
|
364
|
+
resurrectionRate: number;
|
|
365
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Common types shared across all FlowGrid SDK modules.
|
|
3
|
+
* @module types/common
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base configuration for all SDK events.
|
|
7
|
+
*/
|
|
8
|
+
export interface BaseConfig {
|
|
9
|
+
/** The name of the event to track */
|
|
10
|
+
eventName: string;
|
|
11
|
+
/** Additional properties to send with the event */
|
|
12
|
+
properties?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Standard API response from FlowGrid.
|
|
16
|
+
*/
|
|
17
|
+
export interface BaseResponse<T = unknown> {
|
|
18
|
+
/** The event name that was tracked */
|
|
19
|
+
eventName: string;
|
|
20
|
+
/** Properties that were sent */
|
|
21
|
+
properties: Record<string, unknown>;
|
|
22
|
+
/** API response data */
|
|
23
|
+
response: T;
|
|
24
|
+
/** Timestamp of the response */
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Pagination parameters for list queries.
|
|
29
|
+
*/
|
|
30
|
+
export interface PaginationParams {
|
|
31
|
+
/** Page number (1-indexed) */
|
|
32
|
+
page?: number;
|
|
33
|
+
/** Number of items per page */
|
|
34
|
+
limit?: number;
|
|
35
|
+
/** Sort field */
|
|
36
|
+
sortBy?: string;
|
|
37
|
+
/** Sort direction */
|
|
38
|
+
sortOrder?: 'asc' | 'desc';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Date range filter for queries.
|
|
42
|
+
*/
|
|
43
|
+
export interface DateRangeFilter {
|
|
44
|
+
/** Start date (ISO string or Date object) */
|
|
45
|
+
startDate?: string | Date;
|
|
46
|
+
/** End date (ISO string or Date object) */
|
|
47
|
+
endDate?: string | Date;
|
|
48
|
+
/** Predefined time range */
|
|
49
|
+
range?: 'today' | 'yesterday' | 'last7days' | 'last30days' | 'last90days' | 'thisMonth' | 'lastMonth' | 'thisYear';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Supported currency codes (ISO 4217).
|
|
53
|
+
*/
|
|
54
|
+
export type CurrencyCode = 'USD' | 'EUR' | 'GBP' | 'JPY' | 'CAD' | 'AUD' | 'CHF' | 'CNY' | 'INR' | 'MXN' | 'BRL' | 'KRW' | 'SGD' | 'HKD' | 'NOK' | 'SEK' | 'DKK' | 'NZD' | 'ZAR' | 'RUB' | 'TRY' | 'PLN' | 'THB' | 'IDR' | 'MYR' | 'PHP' | 'CZK' | 'ILS' | 'CLP' | 'PKR' | 'EGP' | 'KWD' | 'AED' | 'SAR' | 'TWD' | 'VND';
|
|
55
|
+
/**
|
|
56
|
+
* Money value with currency.
|
|
57
|
+
*/
|
|
58
|
+
export interface MoneyValue {
|
|
59
|
+
/** Amount in the smallest currency unit (e.g., cents for USD) */
|
|
60
|
+
amount: number;
|
|
61
|
+
/** Currency code (ISO 4217) */
|
|
62
|
+
currency: CurrencyCode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* User identification for analytics tracking.
|
|
66
|
+
*/
|
|
67
|
+
export interface UserIdentity {
|
|
68
|
+
/** Unique user identifier */
|
|
69
|
+
userId?: string;
|
|
70
|
+
/** Anonymous/session identifier */
|
|
71
|
+
anonymousId?: string;
|
|
72
|
+
/** User email (hashed recommended) */
|
|
73
|
+
email?: string;
|
|
74
|
+
/** User display name */
|
|
75
|
+
name?: string;
|
|
76
|
+
/** User phone (hashed recommended) */
|
|
77
|
+
phone?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* User traits for segmentation.
|
|
81
|
+
*/
|
|
82
|
+
export interface UserTraits {
|
|
83
|
+
/** Creation date of the user account */
|
|
84
|
+
createdAt?: string | Date;
|
|
85
|
+
/** User's plan or tier */
|
|
86
|
+
plan?: string;
|
|
87
|
+
/** Whether the user is a paying customer */
|
|
88
|
+
isPaying?: boolean;
|
|
89
|
+
/** User's lifetime value */
|
|
90
|
+
ltv?: MoneyValue;
|
|
91
|
+
/** User's company/organization */
|
|
92
|
+
company?: string;
|
|
93
|
+
/** User's role */
|
|
94
|
+
role?: string;
|
|
95
|
+
/** Custom traits */
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Device information for analytics.
|
|
100
|
+
*/
|
|
101
|
+
export interface DeviceInfo {
|
|
102
|
+
/** Device type */
|
|
103
|
+
type?: 'desktop' | 'mobile' | 'tablet' | 'tv' | 'wearable' | 'unknown';
|
|
104
|
+
/** Operating system */
|
|
105
|
+
os?: string;
|
|
106
|
+
/** OS version */
|
|
107
|
+
osVersion?: string;
|
|
108
|
+
/** Browser name */
|
|
109
|
+
browser?: string;
|
|
110
|
+
/** Browser version */
|
|
111
|
+
browserVersion?: string;
|
|
112
|
+
/** Device manufacturer */
|
|
113
|
+
manufacturer?: string;
|
|
114
|
+
/** Device model */
|
|
115
|
+
model?: string;
|
|
116
|
+
/** Screen width in pixels */
|
|
117
|
+
screenWidth?: number;
|
|
118
|
+
/** Screen height in pixels */
|
|
119
|
+
screenHeight?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Geographic location information.
|
|
123
|
+
*/
|
|
124
|
+
export interface GeoLocation {
|
|
125
|
+
/** Country code (ISO 3166-1 alpha-2) */
|
|
126
|
+
country?: string;
|
|
127
|
+
/** Region/State */
|
|
128
|
+
region?: string;
|
|
129
|
+
/** City name */
|
|
130
|
+
city?: string;
|
|
131
|
+
/** Postal/ZIP code */
|
|
132
|
+
postalCode?: string;
|
|
133
|
+
/** Timezone (IANA format) */
|
|
134
|
+
timezone?: string;
|
|
135
|
+
/** Latitude */
|
|
136
|
+
latitude?: number;
|
|
137
|
+
/** Longitude */
|
|
138
|
+
longitude?: number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* UTM campaign parameters.
|
|
142
|
+
*/
|
|
143
|
+
export interface UTMParams {
|
|
144
|
+
/** Campaign source (e.g., google, newsletter) */
|
|
145
|
+
utmSource?: string;
|
|
146
|
+
/** Campaign medium (e.g., cpc, email) */
|
|
147
|
+
utmMedium?: string;
|
|
148
|
+
/** Campaign name */
|
|
149
|
+
utmCampaign?: string;
|
|
150
|
+
/** Campaign term (for paid search) */
|
|
151
|
+
utmTerm?: string;
|
|
152
|
+
/** Campaign content (for A/B testing) */
|
|
153
|
+
utmContent?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Full context for event tracking.
|
|
157
|
+
*/
|
|
158
|
+
export interface TrackingContext {
|
|
159
|
+
/** User identity */
|
|
160
|
+
user?: UserIdentity;
|
|
161
|
+
/** Device information */
|
|
162
|
+
device?: DeviceInfo;
|
|
163
|
+
/** Geographic location */
|
|
164
|
+
location?: GeoLocation;
|
|
165
|
+
/** UTM parameters */
|
|
166
|
+
utm?: UTMParams;
|
|
167
|
+
/** Page URL */
|
|
168
|
+
pageUrl?: string;
|
|
169
|
+
/** Referrer URL */
|
|
170
|
+
referrer?: string;
|
|
171
|
+
/** Session ID */
|
|
172
|
+
sessionId?: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Aggregation types for metrics.
|
|
176
|
+
*/
|
|
177
|
+
export type AggregationType = 'sum' | 'avg' | 'min' | 'max' | 'count' | 'countDistinct' | 'median' | 'percentile';
|
|
178
|
+
/**
|
|
179
|
+
* Time granularity for charts and reports.
|
|
180
|
+
*/
|
|
181
|
+
export type TimeGranularity = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
182
|
+
/**
|
|
183
|
+
* Chart-ready data point.
|
|
184
|
+
*/
|
|
185
|
+
export interface ChartDataPoint {
|
|
186
|
+
/** Label for the data point (e.g., date, category) */
|
|
187
|
+
label: string;
|
|
188
|
+
/** Primary value */
|
|
189
|
+
value: number;
|
|
190
|
+
/** Secondary value (for comparison) */
|
|
191
|
+
previousValue?: number;
|
|
192
|
+
/** Percentage change from previous period */
|
|
193
|
+
changePercent?: number;
|
|
194
|
+
/** Additional metadata */
|
|
195
|
+
metadata?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Chart-ready time series data.
|
|
199
|
+
*/
|
|
200
|
+
export interface TimeSeriesData {
|
|
201
|
+
/** Time granularity */
|
|
202
|
+
granularity: TimeGranularity;
|
|
203
|
+
/** Data points */
|
|
204
|
+
data: ChartDataPoint[];
|
|
205
|
+
/** Total/summary value */
|
|
206
|
+
total?: number;
|
|
207
|
+
/** Comparison period total */
|
|
208
|
+
previousTotal?: number;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Metric summary for dashboards.
|
|
212
|
+
*/
|
|
213
|
+
export interface MetricSummary {
|
|
214
|
+
/** Metric name */
|
|
215
|
+
name: string;
|
|
216
|
+
/** Current value */
|
|
217
|
+
value: number;
|
|
218
|
+
/** Previous period value */
|
|
219
|
+
previousValue?: number;
|
|
220
|
+
/** Percentage change */
|
|
221
|
+
changePercent?: number;
|
|
222
|
+
/** Trend direction */
|
|
223
|
+
trend?: 'up' | 'down' | 'flat';
|
|
224
|
+
/** Whether higher is better */
|
|
225
|
+
higherIsBetter?: boolean;
|
|
226
|
+
/** Display format */
|
|
227
|
+
format?: 'number' | 'currency' | 'percent' | 'duration';
|
|
228
|
+
/** Currency code (if format is currency) */
|
|
229
|
+
currency?: CurrencyCode;
|
|
230
|
+
}
|