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 Core - Prompt & AI Interaction Tracking
|
|
3
|
+
* @module features/core/track-prompt
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track AI prompt interactions, completions, and user feedback
|
|
7
|
+
* for AI-powered features.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Track AI prompt submissions
|
|
11
|
+
* - Monitor response quality
|
|
12
|
+
* - Measure user satisfaction
|
|
13
|
+
* - Analyze prompt patterns
|
|
14
|
+
* - Optimize AI features
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Prompts per user
|
|
18
|
+
* - Response acceptance rate
|
|
19
|
+
* - Average response time
|
|
20
|
+
* - User satisfaction score
|
|
21
|
+
* - Token usage
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Line chart: Prompts over time
|
|
25
|
+
* - Bar chart: Prompts by category
|
|
26
|
+
* - Histogram: Response time distribution
|
|
27
|
+
* - Gauge: Satisfaction score
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const trackPrompt = new TrackPrompt(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* await trackPrompt.create({
|
|
34
|
+
* eventName: 'ai_completion',
|
|
35
|
+
* properties: {
|
|
36
|
+
* promptType: 'code_suggestion',
|
|
37
|
+
* accepted: true
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
43
|
+
import { DateRangeFilter, TimeSeriesData } from "../../types";
|
|
44
|
+
/**
|
|
45
|
+
* Base configuration for prompt events.
|
|
46
|
+
*/
|
|
47
|
+
export interface PromptConfig {
|
|
48
|
+
/** Event name */
|
|
49
|
+
eventName: string;
|
|
50
|
+
/** Event properties */
|
|
51
|
+
properties: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* AI prompt submission configuration.
|
|
55
|
+
*/
|
|
56
|
+
export interface PromptSubmissionConfig {
|
|
57
|
+
/** Prompt ID */
|
|
58
|
+
promptId: string;
|
|
59
|
+
/** User ID */
|
|
60
|
+
userId?: string;
|
|
61
|
+
/** Prompt text (may be truncated/hashed for privacy) */
|
|
62
|
+
promptText?: string;
|
|
63
|
+
/** Prompt category/type */
|
|
64
|
+
promptType: string;
|
|
65
|
+
/** Model used */
|
|
66
|
+
model?: string;
|
|
67
|
+
/** Input token count */
|
|
68
|
+
inputTokens?: number;
|
|
69
|
+
/** Session/conversation ID */
|
|
70
|
+
conversationId?: string;
|
|
71
|
+
/** Custom properties */
|
|
72
|
+
properties?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* AI response configuration.
|
|
76
|
+
*/
|
|
77
|
+
export interface PromptResponseConfig {
|
|
78
|
+
/** Prompt ID */
|
|
79
|
+
promptId: string;
|
|
80
|
+
/** Response time (ms) */
|
|
81
|
+
responseTime: number;
|
|
82
|
+
/** Output token count */
|
|
83
|
+
outputTokens?: number;
|
|
84
|
+
/** Whether response completed */
|
|
85
|
+
completed: boolean;
|
|
86
|
+
/** Error if any */
|
|
87
|
+
error?: string;
|
|
88
|
+
/** Response quality (if auto-detected) */
|
|
89
|
+
qualityScore?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* User feedback on AI response.
|
|
93
|
+
*/
|
|
94
|
+
export interface PromptFeedbackConfig {
|
|
95
|
+
/** Prompt ID */
|
|
96
|
+
promptId: string;
|
|
97
|
+
/** User ID */
|
|
98
|
+
userId?: string;
|
|
99
|
+
/** Feedback type */
|
|
100
|
+
feedbackType: 'accepted' | 'rejected' | 'edited' | 'thumbs_up' | 'thumbs_down';
|
|
101
|
+
/** Rating (1-5) */
|
|
102
|
+
rating?: number;
|
|
103
|
+
/** User comment */
|
|
104
|
+
comment?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Prompt tracking response.
|
|
108
|
+
*/
|
|
109
|
+
export interface PromptResponse {
|
|
110
|
+
eventName: string;
|
|
111
|
+
properties: Record<string, unknown>;
|
|
112
|
+
response: {
|
|
113
|
+
tracked: boolean;
|
|
114
|
+
promptId?: string;
|
|
115
|
+
};
|
|
116
|
+
timestamp: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Prompt analytics data.
|
|
120
|
+
*/
|
|
121
|
+
export interface PromptAnalyticsData {
|
|
122
|
+
/** Summary metrics */
|
|
123
|
+
summary: {
|
|
124
|
+
totalPrompts: number;
|
|
125
|
+
uniqueUsers: number;
|
|
126
|
+
avgResponseTime: number;
|
|
127
|
+
acceptanceRate: number;
|
|
128
|
+
avgSatisfactionScore: number;
|
|
129
|
+
totalTokensUsed: number;
|
|
130
|
+
errorRate: number;
|
|
131
|
+
};
|
|
132
|
+
/** Usage by prompt type */
|
|
133
|
+
byType: Array<{
|
|
134
|
+
promptType: string;
|
|
135
|
+
count: number;
|
|
136
|
+
acceptanceRate: number;
|
|
137
|
+
avgResponseTime: number;
|
|
138
|
+
avgTokens: number;
|
|
139
|
+
}>;
|
|
140
|
+
/** Usage by model */
|
|
141
|
+
byModel: Array<{
|
|
142
|
+
model: string;
|
|
143
|
+
count: number;
|
|
144
|
+
avgResponseTime: number;
|
|
145
|
+
errorRate: number;
|
|
146
|
+
}>;
|
|
147
|
+
/** Feedback breakdown */
|
|
148
|
+
feedback: {
|
|
149
|
+
accepted: number;
|
|
150
|
+
rejected: number;
|
|
151
|
+
edited: number;
|
|
152
|
+
thumbsUp: number;
|
|
153
|
+
thumbsDown: number;
|
|
154
|
+
};
|
|
155
|
+
/** Trends */
|
|
156
|
+
trends: TimeSeriesData;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* TrackPrompt - Track AI prompt interactions.
|
|
160
|
+
*
|
|
161
|
+
* @extends FTRPC
|
|
162
|
+
*
|
|
163
|
+
* @description
|
|
164
|
+
* Provides prompt tracking including:
|
|
165
|
+
* - Prompt submissions
|
|
166
|
+
* - Response tracking
|
|
167
|
+
* - User feedback
|
|
168
|
+
* - Quality metrics
|
|
169
|
+
* - Usage analytics
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* const trackPrompt = new TrackPrompt(webId, endpoint, apiKey);
|
|
174
|
+
*
|
|
175
|
+
* // Track prompt submission
|
|
176
|
+
* await trackPrompt.trackSubmission({
|
|
177
|
+
* promptId: 'prompt_123',
|
|
178
|
+
* userId: 'user_456',
|
|
179
|
+
* promptType: 'code_completion',
|
|
180
|
+
* model: 'gpt-4',
|
|
181
|
+
* inputTokens: 150
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* // Track response
|
|
185
|
+
* await trackPrompt.trackResponse({
|
|
186
|
+
* promptId: 'prompt_123',
|
|
187
|
+
* responseTime: 1200,
|
|
188
|
+
* outputTokens: 300,
|
|
189
|
+
* completed: true
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* // Track user feedback
|
|
193
|
+
* await trackPrompt.trackFeedback({
|
|
194
|
+
* promptId: 'prompt_123',
|
|
195
|
+
* feedbackType: 'accepted',
|
|
196
|
+
* rating: 5
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare class TrackPrompt extends FTRPC {
|
|
201
|
+
/**
|
|
202
|
+
* Creates and tracks a prompt event.
|
|
203
|
+
*
|
|
204
|
+
* @param config - Prompt configuration
|
|
205
|
+
* @returns Promise resolving to prompt response
|
|
206
|
+
*/
|
|
207
|
+
create(config: PromptConfig): Promise<PromptResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* Tracks a prompt submission.
|
|
210
|
+
*
|
|
211
|
+
* @param config - Prompt submission configuration
|
|
212
|
+
* @returns Promise resolving to prompt response
|
|
213
|
+
*/
|
|
214
|
+
trackSubmission(config: PromptSubmissionConfig): Promise<PromptResponse>;
|
|
215
|
+
/**
|
|
216
|
+
* Tracks a prompt response.
|
|
217
|
+
*
|
|
218
|
+
* @param config - Prompt response configuration
|
|
219
|
+
* @returns Promise resolving to prompt response
|
|
220
|
+
*/
|
|
221
|
+
trackResponse(config: PromptResponseConfig): Promise<PromptResponse>;
|
|
222
|
+
/**
|
|
223
|
+
* Tracks user feedback on a prompt response.
|
|
224
|
+
*
|
|
225
|
+
* @param config - Prompt feedback configuration
|
|
226
|
+
* @returns Promise resolving to prompt response
|
|
227
|
+
*/
|
|
228
|
+
trackFeedback(config: PromptFeedbackConfig): Promise<PromptResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Tracks a conversation/multi-turn prompt session.
|
|
231
|
+
*
|
|
232
|
+
* @param conversationId - Conversation ID
|
|
233
|
+
* @param userId - User ID
|
|
234
|
+
* @param turnCount - Number of turns
|
|
235
|
+
* @param totalDuration - Total conversation duration (ms)
|
|
236
|
+
* @returns Promise resolving to prompt response
|
|
237
|
+
*/
|
|
238
|
+
trackConversation(conversationId: string, userId: string, turnCount: number, totalDuration: number): Promise<PromptResponse>;
|
|
239
|
+
/**
|
|
240
|
+
* Gets prompt analytics for dashboards.
|
|
241
|
+
*
|
|
242
|
+
* @param filter - Date range filter
|
|
243
|
+
* @returns Promise resolving to prompt analytics
|
|
244
|
+
*/
|
|
245
|
+
getAnalytics(filter?: DateRangeFilter): Promise<PromptAnalyticsData>;
|
|
246
|
+
}
|
|
247
|
+
export default TrackPrompt;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Ecommerce - Cart Tracking
|
|
3
|
+
* @module features/ecommerce/cart
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track shopping cart interactions including add/remove items,
|
|
7
|
+
* cart views, and cart abandonment.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Track add to cart events
|
|
11
|
+
* - Monitor cart modifications
|
|
12
|
+
* - Detect cart abandonment
|
|
13
|
+
* - Analyze popular cart items
|
|
14
|
+
* - Measure cart value trends
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Add to cart rate
|
|
18
|
+
* - Average cart value
|
|
19
|
+
* - Cart abandonment rate
|
|
20
|
+
* - Items per cart
|
|
21
|
+
* - Cart-to-checkout rate
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Line chart: Cart value over time
|
|
25
|
+
* - Bar chart: Top added products
|
|
26
|
+
* - Pie chart: Abandonment reasons
|
|
27
|
+
* - Funnel: Cart to checkout flow
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const cart = new CartTracking(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track add to cart
|
|
34
|
+
* await cart.addItem({
|
|
35
|
+
* product: { productId: 'SKU-123', name: 'Widget', price: 29.99, currency: 'USD' },
|
|
36
|
+
* quantity: 2,
|
|
37
|
+
* cartId: 'cart_abc'
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
42
|
+
import { Product, Cart, DateRangeFilter, TimeSeriesData } from "../../types";
|
|
43
|
+
/**
|
|
44
|
+
* Configuration for adding item to cart.
|
|
45
|
+
*/
|
|
46
|
+
export interface AddToCartConfig {
|
|
47
|
+
/** Product being added */
|
|
48
|
+
product: Product;
|
|
49
|
+
/** Quantity to add */
|
|
50
|
+
quantity: number;
|
|
51
|
+
/** Cart identifier */
|
|
52
|
+
cartId?: string;
|
|
53
|
+
/** User ID */
|
|
54
|
+
userId?: string;
|
|
55
|
+
/** Source of add (product page, quick add, etc.) */
|
|
56
|
+
source?: 'product_page' | 'quick_add' | 'wishlist' | 'recommendation' | 'reorder';
|
|
57
|
+
/** Custom properties */
|
|
58
|
+
properties?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Configuration for removing item from cart.
|
|
62
|
+
*/
|
|
63
|
+
export interface RemoveFromCartConfig {
|
|
64
|
+
/** Product being removed */
|
|
65
|
+
product: Product;
|
|
66
|
+
/** Quantity to remove */
|
|
67
|
+
quantity: number;
|
|
68
|
+
/** Cart identifier */
|
|
69
|
+
cartId?: string;
|
|
70
|
+
/** User ID */
|
|
71
|
+
userId?: string;
|
|
72
|
+
/** Reason for removal */
|
|
73
|
+
reason?: 'user_action' | 'out_of_stock' | 'price_change' | 'auto_expired';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Configuration for updating cart item.
|
|
77
|
+
*/
|
|
78
|
+
export interface UpdateCartItemConfig {
|
|
79
|
+
/** Product being updated */
|
|
80
|
+
product: Product;
|
|
81
|
+
/** Previous quantity */
|
|
82
|
+
previousQuantity: number;
|
|
83
|
+
/** New quantity */
|
|
84
|
+
newQuantity: number;
|
|
85
|
+
/** Cart identifier */
|
|
86
|
+
cartId?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Configuration for cart view.
|
|
90
|
+
*/
|
|
91
|
+
export interface ViewCartConfig {
|
|
92
|
+
/** Current cart state */
|
|
93
|
+
cart: Cart;
|
|
94
|
+
/** User ID */
|
|
95
|
+
userId?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Cart event response from API.
|
|
99
|
+
*/
|
|
100
|
+
export interface CartResponse {
|
|
101
|
+
eventName: string;
|
|
102
|
+
properties: Record<string, unknown>;
|
|
103
|
+
response: {
|
|
104
|
+
cartId: string;
|
|
105
|
+
tracked: boolean;
|
|
106
|
+
cartValue: number;
|
|
107
|
+
itemCount: number;
|
|
108
|
+
};
|
|
109
|
+
timestamp: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Cart analytics data for charts.
|
|
113
|
+
*/
|
|
114
|
+
export interface CartAnalyticsData {
|
|
115
|
+
/** Cart metrics summary */
|
|
116
|
+
summary: {
|
|
117
|
+
totalAddToCarts: number;
|
|
118
|
+
totalRemoveFromCarts: number;
|
|
119
|
+
averageCartValue: number;
|
|
120
|
+
averageItemsPerCart: number;
|
|
121
|
+
abandonmentRate: number;
|
|
122
|
+
cartToCheckoutRate: number;
|
|
123
|
+
};
|
|
124
|
+
/** Add to cart trends */
|
|
125
|
+
addToCartTimeSeries: TimeSeriesData;
|
|
126
|
+
/** Top products added to cart */
|
|
127
|
+
topAddedProducts: Array<{
|
|
128
|
+
product: Pick<Product, 'productId' | 'name' | 'category'>;
|
|
129
|
+
addCount: number;
|
|
130
|
+
removeCount: number;
|
|
131
|
+
netAdds: number;
|
|
132
|
+
}>;
|
|
133
|
+
/** Abandonment analysis */
|
|
134
|
+
abandonment: {
|
|
135
|
+
rate: number;
|
|
136
|
+
avgAbandonedValue: number;
|
|
137
|
+
topAbandonedProducts: Array<{
|
|
138
|
+
product: Pick<Product, 'productId' | 'name'>;
|
|
139
|
+
abandonCount: number;
|
|
140
|
+
}>;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* CartTracking - Track shopping cart interactions.
|
|
145
|
+
*
|
|
146
|
+
* @extends FTRPC
|
|
147
|
+
*
|
|
148
|
+
* @description
|
|
149
|
+
* Provides cart tracking capabilities including:
|
|
150
|
+
* - Add to cart events
|
|
151
|
+
* - Remove from cart events
|
|
152
|
+
* - Cart quantity updates
|
|
153
|
+
* - Cart view tracking
|
|
154
|
+
* - Cart abandonment detection
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const cart = new CartTracking(webId, endpoint, apiKey);
|
|
159
|
+
*
|
|
160
|
+
* // Track add to cart
|
|
161
|
+
* await cart.addItem({
|
|
162
|
+
* product: {
|
|
163
|
+
* productId: 'PROD-001',
|
|
164
|
+
* name: 'Widget Pro',
|
|
165
|
+
* price: 99.99,
|
|
166
|
+
* currency: 'USD'
|
|
167
|
+
* },
|
|
168
|
+
* quantity: 1,
|
|
169
|
+
* source: 'product_page'
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* // Track cart view
|
|
173
|
+
* await cart.view({
|
|
174
|
+
* cart: currentCart
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export declare class CartTracking extends FTRPC {
|
|
179
|
+
/**
|
|
180
|
+
* Tracks adding an item to cart.
|
|
181
|
+
*
|
|
182
|
+
* @param config - Add to cart configuration
|
|
183
|
+
* @returns Promise resolving to cart response
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* await cart.addItem({
|
|
188
|
+
* product: {
|
|
189
|
+
* productId: 'SKU-123',
|
|
190
|
+
* name: 'Premium Widget',
|
|
191
|
+
* price: 49.99,
|
|
192
|
+
* currency: 'USD',
|
|
193
|
+
* category: 'Widgets'
|
|
194
|
+
* },
|
|
195
|
+
* quantity: 2,
|
|
196
|
+
* source: 'product_page'
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
addItem(config: AddToCartConfig): Promise<CartResponse>;
|
|
201
|
+
/**
|
|
202
|
+
* Tracks removing an item from cart.
|
|
203
|
+
*
|
|
204
|
+
* @param config - Remove from cart configuration
|
|
205
|
+
* @returns Promise resolving to cart response
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* await cart.removeItem({
|
|
210
|
+
* product: productToRemove,
|
|
211
|
+
* quantity: 1,
|
|
212
|
+
* cartId: 'cart_123',
|
|
213
|
+
* reason: 'user_action'
|
|
214
|
+
* });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
removeItem(config: RemoveFromCartConfig): Promise<CartResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Tracks cart item quantity update.
|
|
220
|
+
*
|
|
221
|
+
* @param config - Update configuration
|
|
222
|
+
* @returns Promise resolving to cart response
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* await cart.updateItem({
|
|
227
|
+
* product: item.product,
|
|
228
|
+
* previousQuantity: 1,
|
|
229
|
+
* newQuantity: 3,
|
|
230
|
+
* cartId: 'cart_123'
|
|
231
|
+
* });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
updateItem(config: UpdateCartItemConfig): Promise<CartResponse>;
|
|
235
|
+
/**
|
|
236
|
+
* Tracks a cart view event.
|
|
237
|
+
*
|
|
238
|
+
* @param config - View cart configuration
|
|
239
|
+
* @returns Promise resolving to cart response
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* await cart.view({
|
|
244
|
+
* cart: {
|
|
245
|
+
* cartId: 'cart_123',
|
|
246
|
+
* items: cartItems,
|
|
247
|
+
* subtotal: 149.97,
|
|
248
|
+
* total: 164.97,
|
|
249
|
+
* currency: 'USD',
|
|
250
|
+
* itemCount: 3
|
|
251
|
+
* }
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
view(config: ViewCartConfig): Promise<CartResponse>;
|
|
256
|
+
/**
|
|
257
|
+
* Tracks cart abandonment.
|
|
258
|
+
*
|
|
259
|
+
* @param cart - Abandoned cart state
|
|
260
|
+
* @param reason - Abandonment reason (if known)
|
|
261
|
+
* @returns Promise resolving to cart response
|
|
262
|
+
*/
|
|
263
|
+
abandon(cart: Cart, reason?: 'exit' | 'timeout' | 'price_too_high' | 'shipping_cost' | 'other'): Promise<CartResponse>;
|
|
264
|
+
/**
|
|
265
|
+
* Applies a coupon to the cart.
|
|
266
|
+
*
|
|
267
|
+
* @param cartId - Cart identifier
|
|
268
|
+
* @param couponCode - Coupon code applied
|
|
269
|
+
* @param success - Whether coupon was valid
|
|
270
|
+
* @param discount - Discount amount (if successful)
|
|
271
|
+
* @returns Promise resolving to cart response
|
|
272
|
+
*/
|
|
273
|
+
applyCoupon(cartId: string, couponCode: string, success: boolean, discount?: number): Promise<CartResponse>;
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves cart analytics data for dashboards and charts.
|
|
276
|
+
*
|
|
277
|
+
* @param filter - Date range filter
|
|
278
|
+
* @returns Promise resolving to cart analytics
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const analytics = await cart.getAnalytics({
|
|
283
|
+
* range: 'last30days'
|
|
284
|
+
* });
|
|
285
|
+
*
|
|
286
|
+
* // Line chart - add to cart over time
|
|
287
|
+
* const trendData = analytics.addToCartTimeSeries.data;
|
|
288
|
+
*
|
|
289
|
+
* // Bar chart - top products added
|
|
290
|
+
* const topProducts = analytics.topAddedProducts.map(p => ({
|
|
291
|
+
* name: p.product.name,
|
|
292
|
+
* value: p.addCount
|
|
293
|
+
* }));
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
getAnalytics(filter?: DateRangeFilter): Promise<CartAnalyticsData>;
|
|
297
|
+
}
|
|
298
|
+
export default CartTracking;
|