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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/browser.d.ts +119 -0
  3. package/dist/flowgrid.min.js +2 -0
  4. package/dist/flowgrid.min.js.map +1 -0
  5. package/dist/index.d.ts +44 -0
  6. package/dist/index.js +2 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/client/enterprise-ftrpc.d.ts +51 -0
  9. package/dist/lib/client/ftrpc.d.ts +43 -0
  10. package/dist/lib/client/modules.d.ts +104 -0
  11. package/dist/lib/features/analytics/attribution.d.ts +257 -0
  12. package/dist/lib/features/analytics/events.d.ts +304 -0
  13. package/dist/lib/features/analytics/funnels.d.ts +291 -0
  14. package/dist/lib/features/analytics/heatmaps.d.ts +247 -0
  15. package/dist/lib/features/analytics/identify.d.ts +273 -0
  16. package/dist/lib/features/analytics/index.d.ts +22 -0
  17. package/dist/lib/features/analytics/page-views.d.ts +250 -0
  18. package/dist/lib/features/analytics/performance.d.ts +281 -0
  19. package/dist/lib/features/analytics/retention.d.ts +294 -0
  20. package/dist/lib/features/analytics/sessions.d.ts +277 -0
  21. package/dist/lib/features/core/activation.d.ts +239 -0
  22. package/dist/lib/features/core/experiment.d.ts +286 -0
  23. package/dist/lib/features/core/feature-flag.d.ts +264 -0
  24. package/dist/lib/features/core/index.d.ts +14 -0
  25. package/dist/lib/features/core/track-feature.d.ts +220 -0
  26. package/dist/lib/features/core/track-prompt.d.ts +247 -0
  27. package/dist/lib/features/ecommerce/cart.d.ts +298 -0
  28. package/dist/lib/features/ecommerce/checkout.d.ts +324 -0
  29. package/dist/lib/features/ecommerce/index.d.ts +26 -0
  30. package/dist/lib/features/ecommerce/inventory.d.ts +221 -0
  31. package/dist/lib/features/ecommerce/ltv.d.ts +258 -0
  32. package/dist/lib/features/ecommerce/products.d.ts +268 -0
  33. package/dist/lib/features/ecommerce/promotions.d.ts +266 -0
  34. package/dist/lib/features/ecommerce/purchases.d.ts +287 -0
  35. package/dist/lib/features/ecommerce/refunds.d.ts +232 -0
  36. package/dist/lib/features/ecommerce/search.d.ts +225 -0
  37. package/dist/lib/features/ecommerce/subscriptions.d.ts +281 -0
  38. package/dist/lib/features/ecommerce/wishlist.d.ts +236 -0
  39. package/dist/lib/features/enterprise/acquisition.d.ts +373 -0
  40. package/dist/lib/features/enterprise/alerts.d.ts +348 -0
  41. package/dist/lib/features/enterprise/churn.d.ts +288 -0
  42. package/dist/lib/features/enterprise/cohorts.d.ts +270 -0
  43. package/dist/lib/features/enterprise/engagement.d.ts +233 -0
  44. package/dist/lib/features/enterprise/forecasting.d.ts +351 -0
  45. package/dist/lib/features/enterprise/index.d.ts +20 -0
  46. package/dist/lib/features/enterprise/monetization.d.ts +356 -0
  47. package/dist/lib/features/enterprise/multi-path-funnels.d.ts +327 -0
  48. package/dist/lib/features/enterprise/paths.d.ts +332 -0
  49. package/dist/lib/features/enterprise/security.d.ts +387 -0
  50. package/dist/lib/features/enterprise/support.d.ts +329 -0
  51. package/dist/lib/frameworks/index.d.ts +9 -0
  52. package/dist/lib/frameworks/nextjs/client.d.ts +208 -0
  53. package/dist/lib/frameworks/nextjs/index.d.ts +29 -0
  54. package/dist/lib/frameworks/nextjs/server.d.ts +201 -0
  55. package/dist/lib/frameworks/node/index.d.ts +265 -0
  56. package/dist/lib/frameworks/nuxt/index.d.ts +190 -0
  57. package/dist/lib/frameworks/react/index.d.ts +245 -0
  58. package/dist/lib/frameworks/vue/index.d.ts +275 -0
  59. package/dist/lib/types/analytics.d.ts +365 -0
  60. package/dist/lib/types/common.d.ts +230 -0
  61. package/dist/lib/types/ecommerce.d.ts +309 -0
  62. package/dist/lib/types/index.d.ts +7 -0
  63. package/dist/lib/utils/functions.d.ts +1 -0
  64. package/package.json +139 -0
@@ -0,0 +1,239 @@
1
+ /**
2
+ * @fileoverview Core - User Activation Tracking
3
+ * @module features/core/activation
4
+ *
5
+ * @description
6
+ * Track user activation events including onboarding steps,
7
+ * signup completions, and first-time actions.
8
+ *
9
+ * @useCases
10
+ * - Track onboarding step completions
11
+ * - Monitor signup funnel
12
+ * - Measure time to first value
13
+ * - Identify activation bottlenecks
14
+ * - A/B test onboarding flows
15
+ *
16
+ * @metrics
17
+ * - Activation rate
18
+ * - Onboarding completion rate
19
+ * - Time to activate
20
+ * - Drop-off by step
21
+ * - Activation by source
22
+ *
23
+ * @chartData
24
+ * - Funnel chart: Onboarding steps
25
+ * - Line chart: Activation rate over time
26
+ * - Bar chart: Activation by cohort/source
27
+ * - KPI: Time to first value
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const activation = new Activation(webId, endpoint, apiKey);
32
+ *
33
+ * // Track activation event
34
+ * await activation.create({
35
+ * eventName: 'onboarding_completed',
36
+ * properties: { userId: 'user_123', step: 'profile_setup' }
37
+ * });
38
+ * ```
39
+ */
40
+ import { FTRPC } from "../../client/ftrpc";
41
+ import { DateRangeFilter, TimeSeriesData } from "../../types";
42
+ /**
43
+ * Base configuration for activation events.
44
+ */
45
+ export interface ActivationConfig {
46
+ /** Event name */
47
+ eventName: string;
48
+ /** Event properties */
49
+ properties: Record<string, unknown>;
50
+ }
51
+ /**
52
+ * Onboarding step configuration.
53
+ */
54
+ export interface OnboardingStepConfig {
55
+ /** User ID */
56
+ userId: string;
57
+ /** Step identifier */
58
+ stepId: string;
59
+ /** Step name */
60
+ stepName: string;
61
+ /** Step order/number */
62
+ stepOrder: number;
63
+ /** Total steps in flow */
64
+ totalSteps: number;
65
+ /** Time spent on step (ms) */
66
+ timeSpent?: number;
67
+ /** Whether step was skipped */
68
+ skipped?: boolean;
69
+ /** Custom properties */
70
+ properties?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * First action configuration.
74
+ */
75
+ export interface FirstActionConfig {
76
+ /** User ID */
77
+ userId: string;
78
+ /** Action name */
79
+ actionName: string;
80
+ /** Time since signup (ms) */
81
+ timeSinceSignup: number;
82
+ /** Source/referrer */
83
+ source?: string;
84
+ /** Custom properties */
85
+ properties?: Record<string, unknown>;
86
+ }
87
+ /**
88
+ * Activation response from API.
89
+ */
90
+ export interface ActivationResponse {
91
+ eventName: string;
92
+ properties: Record<string, unknown>;
93
+ response: {
94
+ tracked: boolean;
95
+ activationId?: string;
96
+ isFirstActivation?: boolean;
97
+ };
98
+ timestamp: string;
99
+ }
100
+ /**
101
+ * Activation analytics data.
102
+ */
103
+ export interface ActivationAnalyticsData {
104
+ /** Summary metrics */
105
+ summary: {
106
+ totalSignups: number;
107
+ activatedUsers: number;
108
+ activationRate: number;
109
+ avgTimeToActivate: number;
110
+ onboardingCompletionRate: number;
111
+ };
112
+ /** Activation by step */
113
+ byStep: Array<{
114
+ stepId: string;
115
+ stepName: string;
116
+ started: number;
117
+ completed: number;
118
+ dropOff: number;
119
+ avgTimeSpent: number;
120
+ }>;
121
+ /** Activation by source */
122
+ bySource: Array<{
123
+ source: string;
124
+ signups: number;
125
+ activated: number;
126
+ activationRate: number;
127
+ }>;
128
+ /** Activation trends */
129
+ trends: TimeSeriesData;
130
+ /** Cohort activation */
131
+ byCohort: Array<{
132
+ cohort: string;
133
+ users: number;
134
+ activated: number;
135
+ activationRate: number;
136
+ avgTimeToActivate: number;
137
+ }>;
138
+ }
139
+ /**
140
+ * Activation - Track user activation events.
141
+ *
142
+ * @extends FTRPC
143
+ *
144
+ * @description
145
+ * Provides activation tracking including:
146
+ * - Generic activation events
147
+ * - Onboarding step tracking
148
+ * - First action tracking
149
+ * - Signup completion
150
+ * - Activation analytics
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const activation = new Activation(webId, endpoint, apiKey);
155
+ *
156
+ * // Track onboarding step
157
+ * await activation.trackOnboardingStep({
158
+ * userId: 'user_123',
159
+ * stepId: 'profile_setup',
160
+ * stepName: 'Set Up Profile',
161
+ * stepOrder: 2,
162
+ * totalSteps: 5
163
+ * });
164
+ *
165
+ * // Track first value action
166
+ * await activation.trackFirstAction({
167
+ * userId: 'user_123',
168
+ * actionName: 'created_first_project',
169
+ * timeSinceSignup: 3600000 // 1 hour
170
+ * });
171
+ * ```
172
+ */
173
+ export declare class Activation extends FTRPC {
174
+ /**
175
+ * Creates and tracks an activation event.
176
+ *
177
+ * @param config - Activation configuration
178
+ * @returns Promise resolving to activation response
179
+ */
180
+ create(config: ActivationConfig): Promise<ActivationResponse>;
181
+ /**
182
+ * Tracks an onboarding step completion.
183
+ *
184
+ * @param config - Onboarding step configuration
185
+ * @returns Promise resolving to activation response
186
+ */
187
+ trackOnboardingStep(config: OnboardingStepConfig): Promise<ActivationResponse>;
188
+ /**
189
+ * Tracks onboarding completion.
190
+ *
191
+ * @param userId - User ID
192
+ * @param totalTimeSpent - Total time in onboarding (ms)
193
+ * @param stepsCompleted - Number of steps completed
194
+ * @param stepsSkipped - Number of steps skipped
195
+ * @returns Promise resolving to activation response
196
+ */
197
+ completeOnboarding(userId: string, totalTimeSpent: number, stepsCompleted: number, stepsSkipped: number): Promise<ActivationResponse>;
198
+ /**
199
+ * Tracks user's first meaningful action (activation moment).
200
+ *
201
+ * @param config - First action configuration
202
+ * @returns Promise resolving to activation response
203
+ */
204
+ trackFirstAction(config: FirstActionConfig): Promise<ActivationResponse>;
205
+ /**
206
+ * Tracks signup completion.
207
+ *
208
+ * @param userId - User ID
209
+ * @param method - Signup method (email, google, etc.)
210
+ * @param source - Traffic source
211
+ * @param properties - Additional properties
212
+ * @returns Promise resolving to activation response
213
+ */
214
+ trackSignup(userId: string, method: 'email' | 'google' | 'github' | 'apple' | 'sso' | string, source?: string, properties?: Record<string, unknown>): Promise<ActivationResponse>;
215
+ /**
216
+ * Gets activation analytics for dashboards.
217
+ *
218
+ * @param filter - Date range filter
219
+ * @returns Promise resolving to activation analytics
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const analytics = await activation.getAnalytics({
224
+ * range: 'last30days'
225
+ * });
226
+ *
227
+ * // Funnel chart - onboarding steps
228
+ * const funnel = analytics.byStep.map(s => ({
229
+ * name: s.stepName,
230
+ * value: s.completed
231
+ * }));
232
+ *
233
+ * // KPI - activation rate
234
+ * const activationRate = analytics.summary.activationRate;
235
+ * ```
236
+ */
237
+ getAnalytics(filter?: DateRangeFilter): Promise<ActivationAnalyticsData>;
238
+ }
239
+ export default Activation;
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @fileoverview Core - A/B Testing & Experiments
3
+ * @module features/core/experiment
4
+ *
5
+ * @description
6
+ * Track A/B tests, experiments, and variant assignments
7
+ * to measure impact and optimize product decisions.
8
+ *
9
+ * @useCases
10
+ * - Run A/B tests on features
11
+ * - Track variant assignments
12
+ * - Measure experiment impact
13
+ * - Statistical significance analysis
14
+ * - Multi-variant testing
15
+ *
16
+ * @metrics
17
+ * - Conversion by variant
18
+ * - Statistical significance
19
+ * - Sample size per variant
20
+ * - Experiment duration
21
+ * - Impact on key metrics
22
+ *
23
+ * @chartData
24
+ * - Bar chart: Conversion by variant
25
+ * - Line chart: Metric trends by variant
26
+ * - Table: Experiment results summary
27
+ * - Confidence interval visualization
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const experiment = new Experiment(webId, endpoint, apiKey);
32
+ *
33
+ * await experiment.track({
34
+ * eventName: 'checkout_flow_test',
35
+ * variant: 'simplified_v2',
36
+ * properties: { userId: 'user_123' }
37
+ * });
38
+ * ```
39
+ */
40
+ import { FTRPC } from "../../client/ftrpc";
41
+ import { DateRangeFilter, TimeSeriesData } from "../../types";
42
+ /**
43
+ * Base experiment configuration.
44
+ */
45
+ export interface ExperimentConfig {
46
+ /** Experiment/event name */
47
+ eventName: string;
48
+ /** Assigned variant */
49
+ variant: string;
50
+ /** Event properties */
51
+ properties: Record<string, unknown>;
52
+ }
53
+ /**
54
+ * Experiment definition.
55
+ */
56
+ export interface ExperimentDefinition {
57
+ /** Experiment ID */
58
+ experimentId: string;
59
+ /** Experiment name */
60
+ name: string;
61
+ /** Description */
62
+ description?: string;
63
+ /** Variants */
64
+ variants: Array<{
65
+ variantId: string;
66
+ name: string;
67
+ weight: number;
68
+ }>;
69
+ /** Target audience (optional) */
70
+ audience?: {
71
+ percentage: number;
72
+ filters?: Record<string, unknown>;
73
+ };
74
+ /** Primary metric */
75
+ primaryMetric: string;
76
+ /** Secondary metrics */
77
+ secondaryMetrics?: string[];
78
+ /** Start date */
79
+ startDate?: string;
80
+ /** End date */
81
+ endDate?: string;
82
+ }
83
+ /**
84
+ * Experiment assignment configuration.
85
+ */
86
+ export interface ExperimentAssignmentConfig {
87
+ /** Experiment ID */
88
+ experimentId: string;
89
+ /** User ID */
90
+ userId: string;
91
+ /** Assigned variant ID */
92
+ variantId: string;
93
+ /** Assignment source */
94
+ source?: 'random' | 'targeted' | 'override';
95
+ }
96
+ /**
97
+ * Experiment conversion configuration.
98
+ */
99
+ export interface ExperimentConversionConfig {
100
+ /** Experiment ID */
101
+ experimentId: string;
102
+ /** User ID */
103
+ userId: string;
104
+ /** Variant ID */
105
+ variantId: string;
106
+ /** Metric name */
107
+ metricName: string;
108
+ /** Metric value */
109
+ value: number;
110
+ }
111
+ /**
112
+ * Experiment tracking response.
113
+ */
114
+ export interface ExperimentResponse {
115
+ eventName: string;
116
+ properties: Record<string, unknown>;
117
+ response: {
118
+ tracked: boolean;
119
+ experimentId?: string;
120
+ variantId?: string;
121
+ };
122
+ timestamp: string;
123
+ }
124
+ /**
125
+ * Experiment results data.
126
+ */
127
+ export interface ExperimentResultsData {
128
+ /** Experiment info */
129
+ experiment: {
130
+ experimentId: string;
131
+ name: string;
132
+ status: 'running' | 'paused' | 'completed';
133
+ startDate: string;
134
+ duration: number;
135
+ };
136
+ /** Results by variant */
137
+ variants: Array<{
138
+ variantId: string;
139
+ name: string;
140
+ participants: number;
141
+ conversions: number;
142
+ conversionRate: number;
143
+ improvement: number;
144
+ confidence: number;
145
+ isWinner: boolean;
146
+ isStatisticallySignificant: boolean;
147
+ }>;
148
+ /** Metric trends */
149
+ trends: Record<string, TimeSeriesData>;
150
+ /** Recommendation */
151
+ recommendation: {
152
+ action: 'ship_winner' | 'continue' | 'stop' | 'needs_more_data';
153
+ winningVariant?: string;
154
+ confidence: number;
155
+ reason: string;
156
+ };
157
+ }
158
+ /**
159
+ * All experiments analytics.
160
+ */
161
+ export interface ExperimentAnalyticsData {
162
+ /** Summary */
163
+ summary: {
164
+ totalExperiments: number;
165
+ activeExperiments: number;
166
+ completedExperiments: number;
167
+ avgExperimentDuration: number;
168
+ winRate: number;
169
+ };
170
+ /** Active experiments */
171
+ active: Array<{
172
+ experimentId: string;
173
+ name: string;
174
+ participants: number;
175
+ daysSinceStart: number;
176
+ leadingVariant: string;
177
+ confidence: number;
178
+ }>;
179
+ /** Recent results */
180
+ recentResults: Array<{
181
+ experimentId: string;
182
+ name: string;
183
+ winner: string;
184
+ improvement: number;
185
+ completedDate: string;
186
+ }>;
187
+ }
188
+ /**
189
+ * Experiment - Track A/B tests and experiments.
190
+ *
191
+ * @extends FTRPC
192
+ *
193
+ * @description
194
+ * Provides experiment tracking including:
195
+ * - Experiment definition
196
+ * - Variant assignment
197
+ * - Conversion tracking
198
+ * - Results analysis
199
+ * - Statistical significance
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const experiment = new Experiment(webId, endpoint, apiKey);
204
+ *
205
+ * // Define experiment
206
+ * await experiment.define({
207
+ * experimentId: 'checkout_v2',
208
+ * name: 'Simplified Checkout',
209
+ * variants: [
210
+ * { variantId: 'control', name: 'Current', weight: 50 },
211
+ * { variantId: 'treatment', name: 'Simplified', weight: 50 }
212
+ * ],
213
+ * primaryMetric: 'checkout_completed'
214
+ * });
215
+ *
216
+ * // Assign user to variant
217
+ * await experiment.assign({
218
+ * experimentId: 'checkout_v2',
219
+ * userId: 'user_123',
220
+ * variantId: 'treatment'
221
+ * });
222
+ *
223
+ * // Track conversion
224
+ * await experiment.trackConversion({
225
+ * experimentId: 'checkout_v2',
226
+ * userId: 'user_123',
227
+ * variantId: 'treatment',
228
+ * metricName: 'checkout_completed',
229
+ * value: 1
230
+ * });
231
+ * ```
232
+ */
233
+ export declare class Experiment extends FTRPC {
234
+ /**
235
+ * Tracks an experiment event.
236
+ *
237
+ * @param config - Experiment configuration
238
+ * @returns Promise resolving to experiment response
239
+ */
240
+ track(config: ExperimentConfig): Promise<ExperimentResponse>;
241
+ /**
242
+ * Defines a new experiment.
243
+ *
244
+ * @param definition - Experiment definition
245
+ * @returns Promise resolving to experiment response
246
+ */
247
+ define(definition: ExperimentDefinition): Promise<ExperimentResponse>;
248
+ /**
249
+ * Assigns a user to an experiment variant.
250
+ *
251
+ * @param config - Assignment configuration
252
+ * @returns Promise resolving to experiment response
253
+ */
254
+ assign(config: ExperimentAssignmentConfig): Promise<ExperimentResponse>;
255
+ /**
256
+ * Tracks a conversion for an experiment.
257
+ *
258
+ * @param config - Conversion configuration
259
+ * @returns Promise resolving to experiment response
260
+ */
261
+ trackConversion(config: ExperimentConversionConfig): Promise<ExperimentResponse>;
262
+ /**
263
+ * Tracks user exposure to an experiment.
264
+ *
265
+ * @param experimentId - Experiment ID
266
+ * @param userId - User ID
267
+ * @param variantId - Variant ID
268
+ * @returns Promise resolving to experiment response
269
+ */
270
+ trackExposure(experimentId: string, userId: string, variantId: string): Promise<ExperimentResponse>;
271
+ /**
272
+ * Gets results for a specific experiment.
273
+ *
274
+ * @param experimentId - Experiment ID
275
+ * @returns Promise resolving to experiment results
276
+ */
277
+ getResults(experimentId: string): Promise<ExperimentResultsData>;
278
+ /**
279
+ * Gets experiment analytics overview.
280
+ *
281
+ * @param filter - Date range filter
282
+ * @returns Promise resolving to experiment analytics
283
+ */
284
+ getAnalytics(filter?: DateRangeFilter): Promise<ExperimentAnalyticsData>;
285
+ }
286
+ export default Experiment;