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,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Heatmaps & Click Tracking
|
|
3
|
+
* @module features/analytics/heatmaps
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track user interactions for heatmap visualization including
|
|
7
|
+
* clicks, mouse movements, and scroll behavior.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Visualize click patterns on pages
|
|
11
|
+
* - Identify dead zones and ignored elements
|
|
12
|
+
* - Analyze scroll depth and attention
|
|
13
|
+
* - Optimize CTA placement
|
|
14
|
+
* - Improve page layout based on behavior
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Click coordinates and density
|
|
18
|
+
* - Scroll depth distribution
|
|
19
|
+
* - Attention time by viewport
|
|
20
|
+
* - Element interaction rates
|
|
21
|
+
* - Rage clicks detection
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Heatmap: Click density overlay
|
|
25
|
+
* - Scroll map: Attention by page section
|
|
26
|
+
* - Element report: Interaction by element
|
|
27
|
+
* - Rage click detection
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const heatmaps = new Heatmaps(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track click
|
|
34
|
+
* await heatmaps.trackClick({
|
|
35
|
+
* pageUrl: '/pricing',
|
|
36
|
+
* x: 450,
|
|
37
|
+
* y: 320,
|
|
38
|
+
* viewportWidth: 1920,
|
|
39
|
+
* viewportHeight: 1080
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
44
|
+
import { DateRangeFilter } from "../../types";
|
|
45
|
+
/**
|
|
46
|
+
* Click interaction data.
|
|
47
|
+
*/
|
|
48
|
+
export interface ClickData {
|
|
49
|
+
/** Page URL */
|
|
50
|
+
pageUrl: string;
|
|
51
|
+
/** X coordinate (from left) */
|
|
52
|
+
x: number;
|
|
53
|
+
/** Y coordinate (from top) */
|
|
54
|
+
y: number;
|
|
55
|
+
/** Viewport width */
|
|
56
|
+
viewportWidth: number;
|
|
57
|
+
/** Viewport height */
|
|
58
|
+
viewportHeight: number;
|
|
59
|
+
/** Element selector clicked */
|
|
60
|
+
elementSelector?: string;
|
|
61
|
+
/** Element text (truncated) */
|
|
62
|
+
elementText?: string;
|
|
63
|
+
/** User ID */
|
|
64
|
+
userId?: string;
|
|
65
|
+
/** Session ID */
|
|
66
|
+
sessionId?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Movement/hover data.
|
|
70
|
+
*/
|
|
71
|
+
export interface MovementData {
|
|
72
|
+
/** Page URL */
|
|
73
|
+
pageUrl: string;
|
|
74
|
+
/** Movement path (array of x,y coordinates) */
|
|
75
|
+
path: Array<{
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
t: number;
|
|
79
|
+
}>;
|
|
80
|
+
/** Viewport dimensions */
|
|
81
|
+
viewport: {
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
};
|
|
85
|
+
/** Session ID */
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Scroll data.
|
|
90
|
+
*/
|
|
91
|
+
export interface ScrollData {
|
|
92
|
+
/** Page URL */
|
|
93
|
+
pageUrl: string;
|
|
94
|
+
/** Maximum scroll depth reached (percentage) */
|
|
95
|
+
maxScrollDepth: number;
|
|
96
|
+
/** Page height */
|
|
97
|
+
pageHeight: number;
|
|
98
|
+
/** Viewport height */
|
|
99
|
+
viewportHeight: number;
|
|
100
|
+
/** Time at various scroll depths */
|
|
101
|
+
timeAtDepths?: Record<number, number>;
|
|
102
|
+
/** Session ID */
|
|
103
|
+
sessionId?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Heatmap response from API.
|
|
107
|
+
*/
|
|
108
|
+
export interface HeatmapResponse {
|
|
109
|
+
eventName: string;
|
|
110
|
+
properties: Record<string, unknown>;
|
|
111
|
+
response: {
|
|
112
|
+
recorded: boolean;
|
|
113
|
+
interactionId: string;
|
|
114
|
+
};
|
|
115
|
+
timestamp: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Heatmap data for visualization.
|
|
119
|
+
*/
|
|
120
|
+
export interface HeatmapData {
|
|
121
|
+
/** Page URL */
|
|
122
|
+
pageUrl: string;
|
|
123
|
+
/** Click points for heatmap */
|
|
124
|
+
clicks: Array<{
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
count: number;
|
|
128
|
+
normalizedX: number;
|
|
129
|
+
normalizedY: number;
|
|
130
|
+
}>;
|
|
131
|
+
/** Scroll depth data */
|
|
132
|
+
scrollDepth: Array<{
|
|
133
|
+
depth: number;
|
|
134
|
+
usersReached: number;
|
|
135
|
+
percentageReached: number;
|
|
136
|
+
avgTimeAtDepth: number;
|
|
137
|
+
}>;
|
|
138
|
+
/** Element interaction data */
|
|
139
|
+
elements: Array<{
|
|
140
|
+
selector: string;
|
|
141
|
+
clicks: number;
|
|
142
|
+
hovers: number;
|
|
143
|
+
avgTimeHovered: number;
|
|
144
|
+
}>;
|
|
145
|
+
/** Rage click zones */
|
|
146
|
+
rageClicks: Array<{
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
count: number;
|
|
150
|
+
element: string;
|
|
151
|
+
}>;
|
|
152
|
+
/** Summary */
|
|
153
|
+
summary: {
|
|
154
|
+
totalClicks: number;
|
|
155
|
+
uniqueSessions: number;
|
|
156
|
+
avgScrollDepth: number;
|
|
157
|
+
rageClickRate: number;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Heatmaps - Track user interactions for heatmap visualization.
|
|
162
|
+
*
|
|
163
|
+
* @extends FTRPC
|
|
164
|
+
*
|
|
165
|
+
* @description
|
|
166
|
+
* Provides heatmap data collection including:
|
|
167
|
+
* - Click tracking with coordinates
|
|
168
|
+
* - Mouse movement tracking
|
|
169
|
+
* - Scroll depth tracking
|
|
170
|
+
* - Element interaction tracking
|
|
171
|
+
* - Rage click detection
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const heatmaps = new Heatmaps(webId, endpoint, apiKey);
|
|
176
|
+
*
|
|
177
|
+
* // Track clicks
|
|
178
|
+
* document.addEventListener('click', (e) => {
|
|
179
|
+
* heatmaps.trackClick({
|
|
180
|
+
* pageUrl: window.location.pathname,
|
|
181
|
+
* x: e.clientX,
|
|
182
|
+
* y: e.clientY + window.scrollY,
|
|
183
|
+
* viewportWidth: window.innerWidth,
|
|
184
|
+
* viewportHeight: window.innerHeight,
|
|
185
|
+
* elementSelector: getSelector(e.target)
|
|
186
|
+
* });
|
|
187
|
+
* });
|
|
188
|
+
*
|
|
189
|
+
* // Get heatmap data for visualization
|
|
190
|
+
* const data = await heatmaps.getData('/pricing', { range: 'last7days' });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export declare class Heatmaps extends FTRPC {
|
|
194
|
+
/**
|
|
195
|
+
* Tracks a click interaction.
|
|
196
|
+
*
|
|
197
|
+
* @param data - Click data
|
|
198
|
+
* @returns Promise resolving to heatmap response
|
|
199
|
+
*/
|
|
200
|
+
trackClick(data: ClickData): Promise<HeatmapResponse>;
|
|
201
|
+
/**
|
|
202
|
+
* Tracks mouse movement path.
|
|
203
|
+
*
|
|
204
|
+
* @param data - Movement data
|
|
205
|
+
* @returns Promise resolving to heatmap response
|
|
206
|
+
*/
|
|
207
|
+
trackMovement(data: MovementData): Promise<HeatmapResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Tracks scroll behavior.
|
|
210
|
+
*
|
|
211
|
+
* @param data - Scroll data
|
|
212
|
+
* @returns Promise resolving to heatmap response
|
|
213
|
+
*/
|
|
214
|
+
trackScroll(data: ScrollData): Promise<HeatmapResponse>;
|
|
215
|
+
/**
|
|
216
|
+
* Tracks rage clicks (repeated clicks in frustration).
|
|
217
|
+
*
|
|
218
|
+
* @param pageUrl - Page URL
|
|
219
|
+
* @param x - X coordinate
|
|
220
|
+
* @param y - Y coordinate
|
|
221
|
+
* @param clickCount - Number of rapid clicks
|
|
222
|
+
* @returns Promise resolving to heatmap response
|
|
223
|
+
*/
|
|
224
|
+
trackRageClick(pageUrl: string, x: number, y: number, clickCount: number): Promise<HeatmapResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Gets heatmap data for visualization.
|
|
227
|
+
*
|
|
228
|
+
* @param pageUrl - Page URL to get data for
|
|
229
|
+
* @param filter - Date range filter
|
|
230
|
+
* @returns Promise resolving to heatmap data
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const data = await heatmaps.getData('/pricing', {
|
|
235
|
+
* range: 'last7days'
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* // Render click heatmap
|
|
239
|
+
* renderHeatmap(data.clicks);
|
|
240
|
+
*
|
|
241
|
+
* // Render scroll map
|
|
242
|
+
* renderScrollMap(data.scrollDepth);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
getData(pageUrl: string, filter?: DateRangeFilter): Promise<HeatmapData>;
|
|
246
|
+
}
|
|
247
|
+
export default Heatmaps;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - User Identification & Traits
|
|
3
|
+
* @module features/analytics/identify
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Identify users and track their traits for personalization,
|
|
7
|
+
* segmentation, and cohort analysis.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Link anonymous sessions to authenticated users
|
|
11
|
+
* - Store user profile data for segmentation
|
|
12
|
+
* - Track user lifecycle changes (signup, upgrade, churn)
|
|
13
|
+
* - Enable personalized experiences
|
|
14
|
+
* - Build user cohorts for analysis
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Total identified users
|
|
18
|
+
* - Anonymous to identified conversion rate
|
|
19
|
+
* - Users by plan/segment
|
|
20
|
+
* - User lifetime value distribution
|
|
21
|
+
* - Trait distribution
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Pie chart: Users by plan
|
|
25
|
+
* - Bar chart: Users by trait value
|
|
26
|
+
* - Line chart: New identifications over time
|
|
27
|
+
* - Table: User segments
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const identify = new Identify(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Identify user on login
|
|
34
|
+
* await identify.user({
|
|
35
|
+
* userId: 'user_123',
|
|
36
|
+
* traits: {
|
|
37
|
+
* email: 'user@example.com',
|
|
38
|
+
* name: 'John Doe',
|
|
39
|
+
* plan: 'premium',
|
|
40
|
+
* createdAt: '2025-01-15'
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
46
|
+
import { UserTraits, MoneyValue, DateRangeFilter, TimeSeriesData } from "../../types";
|
|
47
|
+
/**
|
|
48
|
+
* Configuration for identifying a user.
|
|
49
|
+
*/
|
|
50
|
+
export interface IdentifyConfig {
|
|
51
|
+
/** Unique user identifier */
|
|
52
|
+
userId: string;
|
|
53
|
+
/** Anonymous ID to link (optional) */
|
|
54
|
+
anonymousId?: string;
|
|
55
|
+
/** User traits/properties */
|
|
56
|
+
traits?: UserTraits;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for aliasing user IDs.
|
|
60
|
+
*/
|
|
61
|
+
export interface AliasConfig {
|
|
62
|
+
/** Previous user ID */
|
|
63
|
+
previousId: string;
|
|
64
|
+
/** New user ID */
|
|
65
|
+
userId: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configuration for grouping users.
|
|
69
|
+
*/
|
|
70
|
+
export interface GroupConfig {
|
|
71
|
+
/** User ID */
|
|
72
|
+
userId: string;
|
|
73
|
+
/** Group/company ID */
|
|
74
|
+
groupId: string;
|
|
75
|
+
/** Group traits */
|
|
76
|
+
traits?: {
|
|
77
|
+
name?: string;
|
|
78
|
+
industry?: string;
|
|
79
|
+
employees?: number;
|
|
80
|
+
plan?: string;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Identify response from API.
|
|
86
|
+
*/
|
|
87
|
+
export interface IdentifyResponse {
|
|
88
|
+
eventName: string;
|
|
89
|
+
properties: Record<string, unknown>;
|
|
90
|
+
response: {
|
|
91
|
+
userId: string;
|
|
92
|
+
identified: boolean;
|
|
93
|
+
isNewUser: boolean;
|
|
94
|
+
linkedAnonymousId?: string;
|
|
95
|
+
};
|
|
96
|
+
timestamp: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* User analytics data for charts.
|
|
100
|
+
*/
|
|
101
|
+
export interface UserAnalyticsData {
|
|
102
|
+
/** Summary metrics */
|
|
103
|
+
summary: {
|
|
104
|
+
totalUsers: number;
|
|
105
|
+
identifiedUsers: number;
|
|
106
|
+
anonymousUsers: number;
|
|
107
|
+
newUsersThisPeriod: number;
|
|
108
|
+
identificationRate: number;
|
|
109
|
+
};
|
|
110
|
+
/** Users by plan/segment */
|
|
111
|
+
byPlan: Array<{
|
|
112
|
+
plan: string;
|
|
113
|
+
count: number;
|
|
114
|
+
percentage: number;
|
|
115
|
+
mrr?: MoneyValue;
|
|
116
|
+
}>;
|
|
117
|
+
/** New users time series */
|
|
118
|
+
newUsersTimeSeries: TimeSeriesData;
|
|
119
|
+
/** User lifecycle distribution */
|
|
120
|
+
byLifecycleStage: Array<{
|
|
121
|
+
stage: string;
|
|
122
|
+
count: number;
|
|
123
|
+
percentage: number;
|
|
124
|
+
}>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Identify - User identification and trait management.
|
|
128
|
+
*
|
|
129
|
+
* @extends FTRPC
|
|
130
|
+
*
|
|
131
|
+
* @description
|
|
132
|
+
* Provides user identification capabilities including:
|
|
133
|
+
* - User identification on login/signup
|
|
134
|
+
* - Anonymous to identified user linking
|
|
135
|
+
* - User trait/property storage
|
|
136
|
+
* - User aliasing for ID changes
|
|
137
|
+
* - Group/company association
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const identify = new Identify(webId, endpoint, apiKey);
|
|
142
|
+
*
|
|
143
|
+
* // On user signup
|
|
144
|
+
* await identify.user({
|
|
145
|
+
* userId: 'user_123',
|
|
146
|
+
* anonymousId: getAnonymousId(),
|
|
147
|
+
* traits: {
|
|
148
|
+
* email: 'user@example.com',
|
|
149
|
+
* name: 'Jane Smith',
|
|
150
|
+
* plan: 'starter',
|
|
151
|
+
* createdAt: new Date().toISOString()
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* // Associate user with company
|
|
156
|
+
* await identify.group({
|
|
157
|
+
* userId: 'user_123',
|
|
158
|
+
* groupId: 'company_456',
|
|
159
|
+
* traits: { name: 'Acme Inc', employees: 50 }
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare class Identify extends FTRPC {
|
|
164
|
+
/**
|
|
165
|
+
* Identifies a user with traits.
|
|
166
|
+
*
|
|
167
|
+
* @param config - Identification configuration
|
|
168
|
+
* @returns Promise resolving to identify response
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* // Basic identification
|
|
173
|
+
* await identify.user({
|
|
174
|
+
* userId: 'user_123',
|
|
175
|
+
* traits: { email: 'user@example.com' }
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // With anonymous ID linking
|
|
179
|
+
* await identify.user({
|
|
180
|
+
* userId: 'user_123',
|
|
181
|
+
* anonymousId: localStorage.getItem('anonId'),
|
|
182
|
+
* traits: {
|
|
183
|
+
* name: 'John Doe',
|
|
184
|
+
* plan: 'premium',
|
|
185
|
+
* ltv: { amount: 29900, currency: 'USD' }
|
|
186
|
+
* }
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
user(config: IdentifyConfig): Promise<IdentifyResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* Updates traits for an existing user.
|
|
193
|
+
*
|
|
194
|
+
* @param userId - User identifier
|
|
195
|
+
* @param traits - Traits to update/add
|
|
196
|
+
* @returns Promise resolving to identify response
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Update user plan after upgrade
|
|
201
|
+
* await identify.updateTraits('user_123', {
|
|
202
|
+
* plan: 'enterprise',
|
|
203
|
+
* ltv: { amount: 99900, currency: 'USD' }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
updateTraits(userId: string, traits: UserTraits): Promise<IdentifyResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Creates an alias between two user IDs.
|
|
210
|
+
*
|
|
211
|
+
* @param config - Alias configuration
|
|
212
|
+
* @returns Promise resolving to alias response
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* // When user ID changes (e.g., after migration)
|
|
217
|
+
* await identify.alias({
|
|
218
|
+
* previousId: 'old_user_id',
|
|
219
|
+
* userId: 'new_user_id'
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
alias(config: AliasConfig): Promise<IdentifyResponse>;
|
|
224
|
+
/**
|
|
225
|
+
* Associates a user with a group/company.
|
|
226
|
+
*
|
|
227
|
+
* @param config - Group configuration
|
|
228
|
+
* @returns Promise resolving to group response
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* await identify.group({
|
|
233
|
+
* userId: 'user_123',
|
|
234
|
+
* groupId: 'company_456',
|
|
235
|
+
* traits: {
|
|
236
|
+
* name: 'Acme Corporation',
|
|
237
|
+
* industry: 'Technology',
|
|
238
|
+
* employees: 500,
|
|
239
|
+
* plan: 'enterprise'
|
|
240
|
+
* }
|
|
241
|
+
* });
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
group(config: GroupConfig): Promise<IdentifyResponse>;
|
|
245
|
+
/**
|
|
246
|
+
* Resets user identity (logout).
|
|
247
|
+
*
|
|
248
|
+
* @param userId - User ID to reset
|
|
249
|
+
* @returns Promise resolving to reset response
|
|
250
|
+
*/
|
|
251
|
+
reset(userId: string): Promise<IdentifyResponse>;
|
|
252
|
+
/**
|
|
253
|
+
* Retrieves user analytics data for dashboards and charts.
|
|
254
|
+
*
|
|
255
|
+
* @param filter - Date range filter
|
|
256
|
+
* @returns Promise resolving to user analytics
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const analytics = await identify.getAnalytics({
|
|
261
|
+
* range: 'last30days'
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* // Pie chart - users by plan
|
|
265
|
+
* const planData = analytics.byPlan.map(p => ({
|
|
266
|
+
* name: p.plan,
|
|
267
|
+
* value: p.count
|
|
268
|
+
* }));
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
getAnalytics(filter?: DateRangeFilter): Promise<UserAnalyticsData>;
|
|
272
|
+
}
|
|
273
|
+
export default Identify;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Analytics features barrel export
|
|
3
|
+
* @module features/analytics
|
|
4
|
+
*/
|
|
5
|
+
export { PageViews } from './page-views';
|
|
6
|
+
export { Sessions } from './sessions';
|
|
7
|
+
export { Events } from './events';
|
|
8
|
+
export { Identify } from './identify';
|
|
9
|
+
export { Funnels } from './funnels';
|
|
10
|
+
export { Retention } from './retention';
|
|
11
|
+
export { Attribution } from './attribution';
|
|
12
|
+
export { Heatmaps } from './heatmaps';
|
|
13
|
+
export { PerformanceTracking, PerformanceTracking as Performance } from './performance';
|
|
14
|
+
export type { PageViewConfig, ScrollDepthConfig, TimeOnPageConfig, PageViewResponse, PageAnalyticsData } from './page-views';
|
|
15
|
+
export type { SessionStartConfig, SessionResponse, SessionEndResponse, SessionAnalyticsData, RealTimeSessionData } from './sessions';
|
|
16
|
+
export type { EventTrackConfig, BatchEventConfig, EventResponse, BatchEventResponse, EventAnalyticsData } from './events';
|
|
17
|
+
export type { IdentifyConfig, AliasConfig, GroupConfig, IdentifyResponse, UserAnalyticsData } from './identify';
|
|
18
|
+
export type { FunnelDefinition, FunnelStepConfig, FunnelStepResponse, FunnelAnalyticsData, FunnelComparisonData } from './funnels';
|
|
19
|
+
export type { ActivityConfig, CohortAnalysisConfig, ActivityResponse, CohortAnalysisData, StickinessData, ChurnAnalysisData } from './retention';
|
|
20
|
+
export type { AttributionModel, TouchpointConfig, ConversionEvent, TouchpointResponse, AttributionReportData } from './attribution';
|
|
21
|
+
export type { ClickData, MovementData, ScrollData, HeatmapResponse, HeatmapData } from './heatmaps';
|
|
22
|
+
export type { WebVitalsData, PageLoadData, ResourceData, PerformanceResponse, PerformanceAnalyticsData } from './performance';
|