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,356 @@
1
+ /**
2
+ * @fileoverview Enterprise - Revenue & Monetization Analytics
3
+ * @module features/enterprise/monetization
4
+ *
5
+ * @description
6
+ * Track detailed revenue and monetization KPIs including ARPU,
7
+ * cohort-based revenue, and pricing plan impact analysis.
8
+ *
9
+ * @useCases
10
+ * - Calculate ARPU/ARPA per segment
11
+ * - Track cohort-based revenue
12
+ * - Analyze pricing plan impact
13
+ * - Revenue forecasting
14
+ * - Expansion revenue tracking
15
+ *
16
+ * @metrics
17
+ * - ARPU (Average Revenue Per User)
18
+ * - ARPA (Average Revenue Per Account)
19
+ * - Revenue by cohort
20
+ * - Revenue by plan
21
+ * - Expansion revenue
22
+ * - Net Revenue Retention
23
+ *
24
+ * @chartData
25
+ * - Line chart: Revenue over time
26
+ * - Bar chart: Revenue by segment
27
+ * - Waterfall: Revenue movement
28
+ * - Cohort: Revenue retention
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const monetization = new Monetization(webId, endpoint, apiKey);
33
+ *
34
+ * // Get ARPU by segment
35
+ * const arpu = await monetization.getARPU({ segment: 'enterprise' });
36
+ *
37
+ * // Track revenue event
38
+ * await monetization.trackRevenue({
39
+ * userId: 'user_123',
40
+ * amount: 99.00,
41
+ * currency: 'USD',
42
+ * type: 'subscription'
43
+ * });
44
+ * ```
45
+ */
46
+ import { EnterpriseFTRPC } from "../../client/enterprise-ftrpc";
47
+ import { DateRangeFilter, TimeSeriesData, TimeGranularity, MoneyValue, CurrencyCode } from "../../types";
48
+ /**
49
+ * Revenue event types.
50
+ */
51
+ export type RevenueType = 'subscription' | 'one_time' | 'expansion' | 'renewal' | 'downgrade' | 'refund' | 'credit';
52
+ /**
53
+ * Revenue tracking configuration.
54
+ */
55
+ export interface RevenueTrackConfig {
56
+ /** User ID */
57
+ userId: string;
58
+ /** Account/company ID (for B2B) */
59
+ accountId?: string;
60
+ /** Revenue amount */
61
+ amount: number;
62
+ /** Currency code */
63
+ currency: CurrencyCode;
64
+ /** Revenue type */
65
+ type: RevenueType;
66
+ /** Associated plan/product */
67
+ planId?: string;
68
+ /** Transaction ID */
69
+ transactionId?: string;
70
+ /** Billing period */
71
+ billingPeriod?: 'monthly' | 'quarterly' | 'annual';
72
+ /** Custom properties */
73
+ properties?: Record<string, unknown>;
74
+ }
75
+ /**
76
+ * ARPU calculation configuration.
77
+ */
78
+ export interface ARPUConfig {
79
+ /** Date range */
80
+ filter?: DateRangeFilter;
81
+ /** Segment by attribute */
82
+ segment?: string;
83
+ /** User type filter */
84
+ userType?: 'all' | 'paid' | 'free';
85
+ /** Calculation period */
86
+ period?: 'daily' | 'monthly' | 'annual';
87
+ }
88
+ /**
89
+ * ARPU result.
90
+ */
91
+ export interface ARPUResult {
92
+ /** ARPU value */
93
+ arpu: MoneyValue;
94
+ /** Number of users in calculation */
95
+ userCount: number;
96
+ /** Total revenue in period */
97
+ totalRevenue: MoneyValue;
98
+ /** Period of calculation */
99
+ period: string;
100
+ /** Comparison with previous period */
101
+ change?: {
102
+ absolute: MoneyValue;
103
+ percentage: number;
104
+ };
105
+ }
106
+ /**
107
+ * Cohort revenue configuration.
108
+ */
109
+ export interface CohortRevenueConfig {
110
+ /** Cohort identifier or definition */
111
+ cohortId?: string;
112
+ /** Cohort start date */
113
+ cohortDate?: string;
114
+ /** Periods to track */
115
+ periods: number;
116
+ /** Granularity */
117
+ granularity: 'week' | 'month' | 'quarter';
118
+ }
119
+ /**
120
+ * Cohort revenue result.
121
+ */
122
+ export interface CohortRevenueResult {
123
+ cohortId: string;
124
+ cohortDate: string;
125
+ cohortSize: number;
126
+ periods: Array<{
127
+ period: number;
128
+ revenue: MoneyValue;
129
+ arpu: MoneyValue;
130
+ retainedUsers: number;
131
+ retentionRate: number;
132
+ cumulativeRevenue: MoneyValue;
133
+ }>;
134
+ ltvProjection: MoneyValue;
135
+ }
136
+ /**
137
+ * Plan analysis configuration.
138
+ */
139
+ export interface PlanAnalysisConfig {
140
+ /** Date range */
141
+ filter?: DateRangeFilter;
142
+ /** Specific plans to analyze */
143
+ planIds?: string[];
144
+ }
145
+ /**
146
+ * Plan analysis result.
147
+ */
148
+ export interface PlanAnalysis {
149
+ planId: string;
150
+ planName: string;
151
+ activeUsers: number;
152
+ revenue: MoneyValue;
153
+ arpu: MoneyValue;
154
+ churnRate: number;
155
+ upgrades: number;
156
+ downgrades: number;
157
+ growthRate: number;
158
+ }
159
+ /**
160
+ * Revenue breakdown configuration.
161
+ */
162
+ export interface RevenueBreakdownConfig {
163
+ /** Date range */
164
+ filter?: DateRangeFilter;
165
+ /** Breakdown dimension */
166
+ dimension: 'type' | 'plan' | 'segment' | 'country' | 'source';
167
+ }
168
+ /**
169
+ * Revenue breakdown result.
170
+ */
171
+ export interface RevenueBreakdown {
172
+ dimension: string;
173
+ breakdown: Array<{
174
+ value: string;
175
+ revenue: MoneyValue;
176
+ percentage: number;
177
+ userCount: number;
178
+ }>;
179
+ total: MoneyValue;
180
+ }
181
+ /**
182
+ * Net revenue retention configuration.
183
+ */
184
+ export interface NRRConfig {
185
+ /** Date range */
186
+ filter?: DateRangeFilter;
187
+ /** Calculation period */
188
+ period?: 'monthly' | 'quarterly' | 'annual';
189
+ }
190
+ /**
191
+ * Net revenue retention result.
192
+ */
193
+ export interface NRRResult {
194
+ /** Net Revenue Retention rate */
195
+ nrr: number;
196
+ /** Gross Revenue Retention */
197
+ grr: number;
198
+ /** Starting MRR */
199
+ startingMRR: MoneyValue;
200
+ /** Expansion revenue */
201
+ expansion: MoneyValue;
202
+ /** Contraction revenue */
203
+ contraction: MoneyValue;
204
+ /** Churned revenue */
205
+ churned: MoneyValue;
206
+ /** Ending MRR */
207
+ endingMRR: MoneyValue;
208
+ /** Period */
209
+ period: string;
210
+ }
211
+ /**
212
+ * Revenue forecast configuration.
213
+ */
214
+ export interface RevenueForecastConfig {
215
+ /** Periods to forecast */
216
+ periods: number;
217
+ /** Granularity */
218
+ granularity: 'month' | 'quarter';
219
+ /** Include confidence intervals */
220
+ includeConfidence?: boolean;
221
+ }
222
+ /**
223
+ * Revenue forecast result.
224
+ */
225
+ export interface RevenueForecast {
226
+ forecasts: Array<{
227
+ period: string;
228
+ predicted: MoneyValue;
229
+ confidence?: {
230
+ low: MoneyValue;
231
+ high: MoneyValue;
232
+ };
233
+ }>;
234
+ model: string;
235
+ accuracy: number;
236
+ }
237
+ /**
238
+ * Monetization analytics result.
239
+ */
240
+ export interface MonetizationAnalytics {
241
+ totalRevenue: MoneyValue;
242
+ mrr: MoneyValue;
243
+ arr: MoneyValue;
244
+ arpu: MoneyValue;
245
+ nrr: number;
246
+ grr: number;
247
+ expansionRate: number;
248
+ revenueGrowthRate: number;
249
+ paidUserCount: number;
250
+ conversionRate: number;
251
+ revenueByType: RevenueBreakdown;
252
+ trend: TimeSeriesData;
253
+ }
254
+ /**
255
+ * Calculate ARPU from total revenue and user count.
256
+ */
257
+ export declare function calculateARPU(totalRevenue: number, userCount: number, currency: CurrencyCode): MoneyValue;
258
+ /**
259
+ * Calculate Net Revenue Retention.
260
+ */
261
+ export declare function calculateNRR(startingMRR: number, expansion: number, contraction: number, churned: number): number;
262
+ /**
263
+ * Calculate Gross Revenue Retention.
264
+ */
265
+ export declare function calculateGRR(startingMRR: number, contraction: number, churned: number): number;
266
+ /**
267
+ * Convert monthly to annual revenue.
268
+ */
269
+ export declare function monthlyToAnnual(mrr: MoneyValue): MoneyValue;
270
+ /**
271
+ * Calculate LTV from ARPU and churn rate.
272
+ */
273
+ export declare function calculateLTV(arpu: number, monthlyChurnRate: number, currency: CurrencyCode): MoneyValue;
274
+ /**
275
+ * Revenue and monetization analytics class.
276
+ */
277
+ export declare class Monetization extends EnterpriseFTRPC {
278
+ /**
279
+ * Track revenue event.
280
+ */
281
+ trackRevenue(config: RevenueTrackConfig): Promise<{
282
+ tracked: boolean;
283
+ revenueId: string;
284
+ }>;
285
+ /**
286
+ * Track expansion revenue.
287
+ */
288
+ trackExpansion(userId: string, fromPlan: string, toPlan: string, additionalRevenue: MoneyValue): Promise<{
289
+ tracked: boolean;
290
+ }>;
291
+ /**
292
+ * Track contraction/downgrade.
293
+ */
294
+ trackContraction(userId: string, fromPlan: string, toPlan: string, reducedRevenue: MoneyValue): Promise<{
295
+ tracked: boolean;
296
+ }>;
297
+ /**
298
+ * Get ARPU.
299
+ */
300
+ getARPU(config?: ARPUConfig): Promise<ARPUResult>;
301
+ /**
302
+ * Get ARPU by segment.
303
+ */
304
+ getARPUBySegment(segmentAttribute: string, filter?: DateRangeFilter): Promise<Array<{
305
+ segment: string;
306
+ arpu: MoneyValue;
307
+ userCount: number;
308
+ }>>;
309
+ /**
310
+ * Get cohort revenue analysis.
311
+ */
312
+ getCohortRevenue(config: CohortRevenueConfig): Promise<CohortRevenueResult>;
313
+ /**
314
+ * Get plan analysis.
315
+ */
316
+ getPlanAnalysis(config?: PlanAnalysisConfig): Promise<PlanAnalysis[]>;
317
+ /**
318
+ * Get revenue breakdown.
319
+ */
320
+ getRevenueBreakdown(config: RevenueBreakdownConfig): Promise<RevenueBreakdown>;
321
+ /**
322
+ * Get Net Revenue Retention.
323
+ */
324
+ getNRR(config?: NRRConfig): Promise<NRRResult>;
325
+ /**
326
+ * Get MRR.
327
+ */
328
+ getMRR(filter?: DateRangeFilter): Promise<MoneyValue>;
329
+ /**
330
+ * Get ARR.
331
+ */
332
+ getARR(filter?: DateRangeFilter): Promise<MoneyValue>;
333
+ /**
334
+ * Get revenue forecast.
335
+ */
336
+ getRevenueForecast(config: RevenueForecastConfig): Promise<RevenueForecast>;
337
+ /**
338
+ * Get monetization analytics.
339
+ */
340
+ getAnalytics(filter?: DateRangeFilter): Promise<MonetizationAnalytics>;
341
+ /**
342
+ * Get revenue trend.
343
+ */
344
+ getRevenueTrend(filter?: DateRangeFilter, granularity?: TimeGranularity): Promise<TimeSeriesData>;
345
+ /**
346
+ * Get MRR movement (waterfall).
347
+ */
348
+ getMRRMovement(filter?: DateRangeFilter): Promise<{
349
+ starting: MoneyValue;
350
+ newBusiness: MoneyValue;
351
+ expansion: MoneyValue;
352
+ contraction: MoneyValue;
353
+ churn: MoneyValue;
354
+ ending: MoneyValue;
355
+ }>;
356
+ }
@@ -0,0 +1,327 @@
1
+ /**
2
+ * @fileoverview Enterprise - Multi-Path Funnels & Micro-Conversions
3
+ * @module features/enterprise/multi-path-funnels
4
+ *
5
+ * @description
6
+ * Track complex user journeys and micro-conversions with support
7
+ * for non-linear funnel analysis and segment-based drop-off.
8
+ *
9
+ * @useCases
10
+ * - Define multi-path funnels
11
+ * - Track micro-conversions
12
+ * - Analyze drop-off by segment
13
+ * - Non-linear journey tracking
14
+ * - Onboarding step analysis
15
+ *
16
+ * @metrics
17
+ * - Path completion rates
18
+ * - Micro-conversion rates
19
+ * - Drop-off by segment
20
+ * - Time between steps
21
+ * - Alternative path analysis
22
+ *
23
+ * @chartData
24
+ * - Sankey diagram: User flow paths
25
+ * - Funnel chart: Multi-path visualization
26
+ * - Heatmap: Drop-off by segment
27
+ * - Timeline: Step progression
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const funnels = new MultiPathFunnels(webId, endpoint, apiKey);
32
+ *
33
+ * // Define a multi-path funnel
34
+ * await funnels.defineFunnel({
35
+ * name: 'Onboarding',
36
+ * paths: [
37
+ * { steps: ['signup', 'profile', 'first_action'] },
38
+ * { steps: ['signup', 'skip_profile', 'first_action'] }
39
+ * ]
40
+ * });
41
+ * ```
42
+ */
43
+ import { EnterpriseFTRPC } from "../../client/enterprise-ftrpc";
44
+ import { DateRangeFilter, TimeSeriesData, TimeGranularity } from "../../types";
45
+ /**
46
+ * Funnel path definition.
47
+ */
48
+ export interface FunnelPath {
49
+ /** Path identifier */
50
+ pathId?: string;
51
+ /** Path name */
52
+ name?: string;
53
+ /** Ordered list of step events */
54
+ steps: string[];
55
+ /** Whether steps must be in order */
56
+ ordered?: boolean;
57
+ /** Maximum time window between first and last step */
58
+ timeWindowMs?: number;
59
+ }
60
+ /**
61
+ * Multi-path funnel definition.
62
+ */
63
+ export interface MultiPathFunnelDefinition {
64
+ /** Funnel identifier */
65
+ funnelId?: string;
66
+ /** Funnel name */
67
+ name: string;
68
+ /** Funnel description */
69
+ description?: string;
70
+ /** Alternative paths to conversion */
71
+ paths: FunnelPath[];
72
+ /** Micro-conversion definitions */
73
+ microConversions?: MicroConversionDefinition[];
74
+ /** Goal event (final conversion) */
75
+ goalEvent: string;
76
+ }
77
+ /**
78
+ * Micro-conversion definition.
79
+ */
80
+ export interface MicroConversionDefinition {
81
+ /** Micro-conversion identifier */
82
+ id: string;
83
+ /** Display name */
84
+ name: string;
85
+ /** Event that triggers this micro-conversion */
86
+ event: string;
87
+ /** Weight/importance (0-1) */
88
+ weight?: number;
89
+ /** Prerequisite micro-conversions */
90
+ prerequisites?: string[];
91
+ }
92
+ /**
93
+ * Funnel step tracking configuration.
94
+ */
95
+ export interface MultiPathStepConfig {
96
+ /** Funnel ID */
97
+ funnelId: string;
98
+ /** Step/event name */
99
+ step: string;
100
+ /** User ID */
101
+ userId: string;
102
+ /** Session ID */
103
+ sessionId?: string;
104
+ /** Path ID (if known) */
105
+ pathId?: string;
106
+ /** Custom properties */
107
+ properties?: Record<string, unknown>;
108
+ }
109
+ /**
110
+ * Micro-conversion tracking configuration.
111
+ */
112
+ export interface MicroConversionConfig {
113
+ /** Micro-conversion ID */
114
+ conversionId: string;
115
+ /** User ID */
116
+ userId: string;
117
+ /** Session ID */
118
+ sessionId?: string;
119
+ /** Value associated with conversion */
120
+ value?: number;
121
+ /** Custom properties */
122
+ properties?: Record<string, unknown>;
123
+ }
124
+ /**
125
+ * Funnel analysis configuration.
126
+ */
127
+ export interface FunnelAnalysisConfig {
128
+ /** Funnel ID */
129
+ funnelId: string;
130
+ /** Date range */
131
+ filter?: DateRangeFilter;
132
+ /** Segment by attribute */
133
+ segmentBy?: string;
134
+ /** Include path breakdown */
135
+ includePaths?: boolean;
136
+ /** Include micro-conversions */
137
+ includeMicroConversions?: boolean;
138
+ }
139
+ /**
140
+ * Path analysis result.
141
+ */
142
+ export interface PathAnalysis {
143
+ pathId: string;
144
+ pathName: string;
145
+ steps: string[];
146
+ userCount: number;
147
+ completionRate: number;
148
+ avgTimeToComplete: number;
149
+ stepAnalysis: Array<{
150
+ step: string;
151
+ entered: number;
152
+ completed: number;
153
+ dropOffRate: number;
154
+ avgTimeSpent: number;
155
+ }>;
156
+ }
157
+ /**
158
+ * Micro-conversion analysis.
159
+ */
160
+ export interface MicroConversionAnalysis {
161
+ id: string;
162
+ name: string;
163
+ completions: number;
164
+ completionRate: number;
165
+ avgValue: number;
166
+ correlation: number;
167
+ }
168
+ /**
169
+ * Multi-path funnel analysis result.
170
+ */
171
+ export interface MultiPathFunnelAnalysis {
172
+ funnelId: string;
173
+ funnelName: string;
174
+ totalUsers: number;
175
+ goalCompletions: number;
176
+ overallConversionRate: number;
177
+ paths: PathAnalysis[];
178
+ microConversions?: MicroConversionAnalysis[];
179
+ topDropOffPoints: Array<{
180
+ step: string;
181
+ dropOffRate: number;
182
+ userCount: number;
183
+ }>;
184
+ avgTimeToConversion: number;
185
+ }
186
+ /**
187
+ * Segment drop-off analysis.
188
+ */
189
+ export interface SegmentDropOffAnalysis {
190
+ funnelId: string;
191
+ segmentAttribute: string;
192
+ segments: Array<{
193
+ segment: string;
194
+ conversionRate: number;
195
+ dropOffByStep: Array<{
196
+ step: string;
197
+ dropOffRate: number;
198
+ }>;
199
+ }>;
200
+ bestPerformingSegment: string;
201
+ worstPerformingSegment: string;
202
+ }
203
+ /**
204
+ * User journey configuration.
205
+ */
206
+ export interface UserJourneyConfig {
207
+ /** User ID */
208
+ userId: string;
209
+ /** Funnel ID */
210
+ funnelId: string;
211
+ /** Date range */
212
+ filter?: DateRangeFilter;
213
+ }
214
+ /**
215
+ * User journey result.
216
+ */
217
+ export interface UserJourney {
218
+ userId: string;
219
+ funnelId: string;
220
+ currentPath: string;
221
+ stepsCompleted: Array<{
222
+ step: string;
223
+ timestamp: string;
224
+ properties?: Record<string, unknown>;
225
+ }>;
226
+ microConversions: Array<{
227
+ id: string;
228
+ timestamp: string;
229
+ }>;
230
+ goalReached: boolean;
231
+ goalReachedAt?: string;
232
+ timeInFunnel: number;
233
+ }
234
+ /**
235
+ * Calculate funnel conversion rate.
236
+ */
237
+ export declare function calculateConversionRate(entered: number, completed: number): number;
238
+ /**
239
+ * Calculate drop-off rate between steps.
240
+ */
241
+ export declare function calculateDropOffRate(previousStep: number, currentStep: number): number;
242
+ /**
243
+ * Find the best performing path.
244
+ */
245
+ export declare function findBestPath(paths: PathAnalysis[]): PathAnalysis | null;
246
+ /**
247
+ * Calculate weighted micro-conversion score.
248
+ */
249
+ export declare function calculateMicroConversionScore(completedConversions: MicroConversionAnalysis[], definitions: MicroConversionDefinition[]): number;
250
+ /**
251
+ * Generate path ID from steps.
252
+ */
253
+ export declare function generatePathId(steps: string[]): string;
254
+ /**
255
+ * Multi-path funnels and micro-conversions class.
256
+ */
257
+ export declare class MultiPathFunnels extends EnterpriseFTRPC {
258
+ /**
259
+ * Define a multi-path funnel.
260
+ */
261
+ defineFunnel(definition: MultiPathFunnelDefinition): Promise<{
262
+ funnelId: string;
263
+ }>;
264
+ /**
265
+ * Update funnel definition.
266
+ */
267
+ updateFunnel(funnelId: string, updates: Partial<MultiPathFunnelDefinition>): Promise<{
268
+ updated: boolean;
269
+ }>;
270
+ /**
271
+ * Delete funnel.
272
+ */
273
+ deleteFunnel(funnelId: string): Promise<{
274
+ deleted: boolean;
275
+ }>;
276
+ /**
277
+ * Track funnel step.
278
+ */
279
+ trackStep(config: MultiPathStepConfig): Promise<{
280
+ tracked: boolean;
281
+ }>;
282
+ /**
283
+ * Track micro-conversion.
284
+ */
285
+ trackMicroConversion(config: MicroConversionConfig): Promise<{
286
+ tracked: boolean;
287
+ }>;
288
+ /**
289
+ * Track goal completion.
290
+ */
291
+ trackGoal(funnelId: string, userId: string, properties?: Record<string, unknown>): Promise<{
292
+ tracked: boolean;
293
+ }>;
294
+ /**
295
+ * Get funnel analysis.
296
+ */
297
+ analyzeFunnel(config: FunnelAnalysisConfig): Promise<MultiPathFunnelAnalysis>;
298
+ /**
299
+ * Get path comparison.
300
+ */
301
+ comparePaths(funnelId: string, filter?: DateRangeFilter): Promise<PathAnalysis[]>;
302
+ /**
303
+ * Get segment drop-off analysis.
304
+ */
305
+ getSegmentDropOff(funnelId: string, segmentAttribute: string, filter?: DateRangeFilter): Promise<SegmentDropOffAnalysis>;
306
+ /**
307
+ * Get user journey.
308
+ */
309
+ getUserJourney(config: UserJourneyConfig): Promise<UserJourney>;
310
+ /**
311
+ * Get micro-conversion analysis.
312
+ */
313
+ getMicroConversionAnalysis(funnelId: string, filter?: DateRangeFilter): Promise<MicroConversionAnalysis[]>;
314
+ /**
315
+ * Get funnel trend.
316
+ */
317
+ getFunnelTrend(funnelId: string, filter?: DateRangeFilter, granularity?: TimeGranularity): Promise<TimeSeriesData>;
318
+ /**
319
+ * List all funnels.
320
+ */
321
+ listFunnels(): Promise<Array<{
322
+ funnelId: string;
323
+ name: string;
324
+ pathCount: number;
325
+ createdAt: string;
326
+ }>>;
327
+ }