flowgrid-sdk 1.2.0 → 1.3.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/README.md +224 -250
- package/dist/237.flowgrid.min.js +2 -0
- package/dist/237.flowgrid.min.js.map +1 -0
- package/dist/546.flowgrid.min.js +3 -0
- package/dist/546.flowgrid.min.js.LICENSE.txt +14 -0
- package/dist/546.flowgrid.min.js.map +1 -0
- package/dist/EXAMPLE.d.ts +1 -0
- package/dist/EXAMPLE.js +55 -0
- package/dist/EXAMPLE.js.map +1 -0
- package/dist/browser.d.ts +46 -103
- package/dist/browser.js +102 -0
- package/dist/browser.js.map +1 -0
- package/dist/flowgrid.min.js +1 -1
- package/dist/flowgrid.min.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.js +64 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/client/transport.d.ts +14 -4
- package/dist/lib/client/transport.js +432 -0
- package/dist/lib/client/transport.js.map +1 -0
- package/dist/lib/consent/index.d.ts +0 -5
- package/dist/lib/consent/index.js +32 -0
- package/dist/lib/consent/index.js.map +1 -0
- package/dist/lib/consent/manager.js +336 -0
- package/dist/lib/consent/manager.js.map +1 -0
- package/dist/lib/consent/types.d.ts +3 -20
- package/dist/lib/consent/types.js +10 -0
- package/dist/lib/consent/types.js.map +1 -0
- package/dist/lib/features/analytics/attribution.d.ts +6 -47
- package/dist/lib/features/analytics/attribution.js +181 -0
- package/dist/lib/features/analytics/attribution.js.map +1 -0
- package/dist/lib/features/analytics/events.d.ts +1 -28
- package/dist/lib/features/analytics/events.js +256 -0
- package/dist/lib/features/analytics/events.js.map +1 -0
- package/dist/lib/features/analytics/funnels.js +260 -0
- package/dist/lib/features/analytics/funnels.js.map +1 -0
- package/dist/lib/features/analytics/heatmaps.d.ts +12 -19
- package/dist/lib/features/analytics/heatmaps.js +258 -0
- package/dist/lib/features/analytics/heatmaps.js.map +1 -0
- package/dist/lib/features/analytics/identify.d.ts +1 -21
- package/dist/lib/features/analytics/identify.js +213 -0
- package/dist/lib/features/analytics/identify.js.map +1 -0
- package/dist/lib/features/analytics/index.d.ts +2 -0
- package/dist/lib/features/analytics/index.js +15 -0
- package/dist/lib/features/analytics/index.js.map +1 -0
- package/dist/lib/features/analytics/page-views.d.ts +13 -30
- package/dist/lib/features/analytics/page-views.js +268 -0
- package/dist/lib/features/analytics/page-views.js.map +1 -0
- package/dist/lib/features/analytics/performance.d.ts +18 -24
- package/dist/lib/features/analytics/performance.js +232 -0
- package/dist/lib/features/analytics/performance.js.map +1 -0
- package/dist/lib/features/analytics/replay.d.ts +170 -0
- package/dist/lib/features/analytics/replay.js +381 -0
- package/dist/lib/features/analytics/replay.js.map +1 -0
- package/dist/lib/features/analytics/retention.d.ts +1 -76
- package/dist/lib/features/analytics/retention.js +135 -0
- package/dist/lib/features/analytics/retention.js.map +1 -0
- package/dist/lib/features/analytics/sessions.d.ts +12 -37
- package/dist/lib/features/analytics/sessions.js +213 -0
- package/dist/lib/features/analytics/sessions.js.map +1 -0
- package/dist/lib/features/core/activation.d.ts +1 -24
- package/dist/lib/features/core/activation.js +175 -0
- package/dist/lib/features/core/activation.js.map +1 -0
- package/dist/lib/features/core/experiment.d.ts +53 -21
- package/dist/lib/features/core/experiment.js +554 -0
- package/dist/lib/features/core/experiment.js.map +1 -0
- package/dist/lib/features/core/index.js +9 -0
- package/dist/lib/features/core/index.js.map +1 -0
- package/dist/lib/features/core/track-feature.d.ts +1 -8
- package/dist/lib/features/core/track-feature.js +119 -0
- package/dist/lib/features/core/track-feature.js.map +1 -0
- package/dist/lib/features/core/track-prompt.d.ts +5 -8
- package/dist/lib/features/core/track-prompt.js +181 -0
- package/dist/lib/features/core/track-prompt.js.map +1 -0
- package/dist/lib/features/ecommerce/cart.d.ts +1 -24
- package/dist/lib/features/ecommerce/cart.js +244 -0
- package/dist/lib/features/ecommerce/cart.js.map +1 -0
- package/dist/lib/features/ecommerce/checkout.d.ts +1 -28
- package/dist/lib/features/ecommerce/checkout.js +254 -0
- package/dist/lib/features/ecommerce/checkout.js.map +1 -0
- package/dist/lib/features/ecommerce/index.d.ts +0 -2
- package/dist/lib/features/ecommerce/index.js +15 -0
- package/dist/lib/features/ecommerce/index.js.map +1 -0
- package/dist/lib/features/ecommerce/ltv.d.ts +1 -69
- package/dist/lib/features/ecommerce/ltv.js +114 -0
- package/dist/lib/features/ecommerce/ltv.js.map +1 -0
- package/dist/lib/features/ecommerce/products.d.ts +1 -33
- package/dist/lib/features/ecommerce/products.js +223 -0
- package/dist/lib/features/ecommerce/products.js.map +1 -0
- package/dist/lib/features/ecommerce/promotions.d.ts +1 -30
- package/dist/lib/features/ecommerce/promotions.js +197 -0
- package/dist/lib/features/ecommerce/promotions.js.map +1 -0
- package/dist/lib/features/ecommerce/purchases.d.ts +1 -48
- package/dist/lib/features/ecommerce/purchases.js +193 -0
- package/dist/lib/features/ecommerce/purchases.js.map +1 -0
- package/dist/lib/features/ecommerce/refunds.d.ts +1 -27
- package/dist/lib/features/ecommerce/refunds.js +195 -0
- package/dist/lib/features/ecommerce/refunds.js.map +1 -0
- package/dist/lib/features/ecommerce/search.d.ts +1 -24
- package/dist/lib/features/ecommerce/search.js +156 -0
- package/dist/lib/features/ecommerce/search.js.map +1 -0
- package/dist/lib/features/ecommerce/subscriptions.d.ts +1 -28
- package/dist/lib/features/ecommerce/subscriptions.js +207 -0
- package/dist/lib/features/ecommerce/subscriptions.js.map +1 -0
- package/dist/lib/features/ecommerce/wishlist.d.ts +1 -28
- package/dist/lib/features/ecommerce/wishlist.js +186 -0
- package/dist/lib/features/ecommerce/wishlist.js.map +1 -0
- package/dist/lib/features/enterprise/acquisition.d.ts +2 -57
- package/dist/lib/features/enterprise/acquisition.js +166 -0
- package/dist/lib/features/enterprise/acquisition.js.map +1 -0
- package/dist/lib/features/enterprise/alerts.d.ts +1 -37
- package/dist/lib/features/enterprise/alerts.js +246 -0
- package/dist/lib/features/enterprise/alerts.js.map +1 -0
- package/dist/lib/features/enterprise/churn.d.ts +1 -42
- package/dist/lib/features/enterprise/churn.js +175 -0
- package/dist/lib/features/enterprise/churn.js.map +1 -0
- package/dist/lib/features/enterprise/cohorts.d.ts +1 -37
- package/dist/lib/features/enterprise/cohorts.js +201 -0
- package/dist/lib/features/enterprise/cohorts.js.map +1 -0
- package/dist/lib/features/enterprise/engagement.d.ts +40 -46
- package/dist/lib/features/enterprise/engagement.js +335 -0
- package/dist/lib/features/enterprise/engagement.js.map +1 -0
- package/dist/lib/features/enterprise/forecasting.d.ts +0 -50
- package/dist/lib/features/enterprise/forecasting.js +232 -0
- package/dist/lib/features/enterprise/forecasting.js.map +1 -0
- package/dist/lib/features/enterprise/index.d.ts +1 -1
- package/dist/lib/features/enterprise/index.js +76 -0
- package/dist/lib/features/enterprise/index.js.map +1 -0
- package/dist/lib/features/enterprise/monetization.d.ts +1 -60
- package/dist/lib/features/enterprise/monetization.js +146 -0
- package/dist/lib/features/enterprise/monetization.js.map +1 -0
- package/dist/lib/features/enterprise/multi-path-funnels.d.ts +1 -17
- package/dist/lib/features/enterprise/multi-path-funnels.js +205 -0
- package/dist/lib/features/enterprise/multi-path-funnels.js.map +1 -0
- package/dist/lib/features/enterprise/paths.d.ts +1 -56
- package/dist/lib/features/enterprise/paths.js +149 -0
- package/dist/lib/features/enterprise/paths.js.map +1 -0
- package/dist/lib/features/enterprise/security.d.ts +8 -57
- package/dist/lib/features/enterprise/security.js +202 -0
- package/dist/lib/features/enterprise/security.js.map +1 -0
- package/dist/lib/features/enterprise/support.d.ts +3 -42
- package/dist/lib/features/enterprise/support.js +162 -0
- package/dist/lib/features/enterprise/support.js.map +1 -0
- package/dist/lib/flowgrid.d.ts +278 -0
- package/dist/lib/flowgrid.js +323 -0
- package/dist/lib/flowgrid.js.map +1 -0
- package/dist/lib/frameworks/index.d.ts +13 -6
- package/dist/lib/frameworks/index.js +18 -0
- package/dist/lib/frameworks/index.js.map +1 -0
- package/dist/lib/frameworks/nextjs/client.js +355 -0
- package/dist/lib/frameworks/nextjs/client.js.map +1 -0
- package/dist/lib/frameworks/nextjs/index.js +31 -0
- package/dist/lib/frameworks/nextjs/index.js.map +1 -0
- package/dist/lib/frameworks/nextjs/server.js +259 -0
- package/dist/lib/frameworks/nextjs/server.js.map +1 -0
- package/dist/lib/frameworks/node/index.js +391 -0
- package/dist/lib/frameworks/node/index.js.map +1 -0
- package/dist/lib/frameworks/nuxt/index.js +288 -0
- package/dist/lib/frameworks/nuxt/index.js.map +1 -0
- package/dist/lib/frameworks/react/CookieBanner.js +166 -0
- package/dist/lib/frameworks/react/CookieBanner.js.map +1 -0
- package/dist/lib/frameworks/react/index.d.ts +2 -2
- package/dist/lib/frameworks/react/index.js +271 -0
- package/dist/lib/frameworks/react/index.js.map +1 -0
- package/dist/lib/frameworks/vue/CookieBanner.js +165 -0
- package/dist/lib/frameworks/vue/CookieBanner.js.map +1 -0
- package/dist/lib/frameworks/vue/index.d.ts +2 -2
- package/dist/lib/frameworks/vue/index.js +390 -0
- package/dist/lib/frameworks/vue/index.js.map +1 -0
- package/dist/lib/tracking/analytics/attribution.d.ts +14 -0
- package/dist/lib/tracking/analytics/attribution.js +18 -0
- package/dist/lib/tracking/analytics/attribution.js.map +1 -0
- package/dist/lib/tracking/analytics/events.d.ts +26 -0
- package/dist/lib/tracking/analytics/events.js +30 -0
- package/dist/lib/tracking/analytics/events.js.map +1 -0
- package/dist/lib/tracking/analytics/funnels.d.ts +16 -0
- package/dist/lib/tracking/analytics/funnels.js +22 -0
- package/dist/lib/tracking/analytics/funnels.js.map +1 -0
- package/dist/lib/tracking/analytics/heatmaps.d.ts +27 -0
- package/dist/lib/tracking/analytics/heatmaps.js +22 -0
- package/dist/lib/tracking/analytics/heatmaps.js.map +1 -0
- package/dist/lib/tracking/analytics/identify.d.ts +16 -0
- package/dist/lib/tracking/analytics/identify.js +22 -0
- package/dist/lib/tracking/analytics/identify.js.map +1 -0
- package/dist/lib/tracking/analytics/index.d.ts +10 -0
- package/dist/lib/tracking/analytics/index.js +11 -0
- package/dist/lib/tracking/analytics/index.js.map +1 -0
- package/dist/lib/tracking/analytics/page-views.d.ts +29 -0
- package/dist/lib/tracking/analytics/page-views.js +50 -0
- package/dist/lib/tracking/analytics/page-views.js.map +1 -0
- package/dist/lib/tracking/analytics/performance.d.ts +22 -0
- package/dist/lib/tracking/analytics/performance.js +22 -0
- package/dist/lib/tracking/analytics/performance.js.map +1 -0
- package/dist/lib/tracking/analytics/replay.d.ts +34 -0
- package/dist/lib/tracking/analytics/replay.js +46 -0
- package/dist/lib/tracking/analytics/replay.js.map +1 -0
- package/dist/lib/tracking/analytics/retention.d.ts +10 -0
- package/dist/lib/tracking/analytics/retention.js +10 -0
- package/dist/lib/tracking/analytics/retention.js.map +1 -0
- package/dist/lib/tracking/analytics/sessions.d.ts +20 -0
- package/dist/lib/tracking/analytics/sessions.js +26 -0
- package/dist/lib/tracking/analytics/sessions.js.map +1 -0
- package/dist/lib/tracking/core/activation.d.ts +23 -0
- package/dist/lib/tracking/core/activation.js +33 -0
- package/dist/lib/tracking/core/activation.js.map +1 -0
- package/dist/lib/tracking/core/experiment.d.ts +122 -0
- package/dist/lib/tracking/core/experiment.js +150 -0
- package/dist/lib/tracking/core/experiment.js.map +1 -0
- package/dist/lib/tracking/core/feature.d.ts +13 -0
- package/dist/lib/tracking/core/feature.js +14 -0
- package/dist/lib/tracking/core/feature.js.map +1 -0
- package/dist/lib/tracking/core/index.d.ts +4 -0
- package/dist/lib/tracking/core/index.js +5 -0
- package/dist/lib/tracking/core/index.js.map +1 -0
- package/dist/lib/tracking/core/prompt.d.ts +18 -0
- package/dist/lib/tracking/core/prompt.js +26 -0
- package/dist/lib/tracking/core/prompt.js.map +1 -0
- package/dist/lib/tracking/ecommerce/cart.d.ts +17 -0
- package/dist/lib/tracking/ecommerce/cart.js +22 -0
- package/dist/lib/tracking/ecommerce/cart.js.map +1 -0
- package/dist/lib/tracking/ecommerce/checkout.d.ts +17 -0
- package/dist/lib/tracking/ecommerce/checkout.js +22 -0
- package/dist/lib/tracking/ecommerce/checkout.js.map +1 -0
- package/dist/lib/tracking/ecommerce/index.d.ts +10 -0
- package/dist/lib/tracking/ecommerce/index.js +11 -0
- package/dist/lib/tracking/ecommerce/index.js.map +1 -0
- package/dist/lib/tracking/ecommerce/ltv.d.ts +15 -0
- package/dist/lib/tracking/ecommerce/ltv.js +14 -0
- package/dist/lib/tracking/ecommerce/ltv.js.map +1 -0
- package/dist/lib/tracking/ecommerce/products.d.ts +15 -0
- package/dist/lib/tracking/ecommerce/products.js +18 -0
- package/dist/lib/tracking/ecommerce/products.js.map +1 -0
- package/dist/lib/tracking/ecommerce/promotions.d.ts +14 -0
- package/dist/lib/tracking/ecommerce/promotions.js +25 -0
- package/dist/lib/tracking/ecommerce/promotions.js.map +1 -0
- package/dist/lib/tracking/ecommerce/purchases.d.ts +11 -0
- package/dist/lib/tracking/ecommerce/purchases.js +10 -0
- package/dist/lib/tracking/ecommerce/purchases.js.map +1 -0
- package/dist/lib/tracking/ecommerce/refunds.d.ts +17 -0
- package/dist/lib/tracking/ecommerce/refunds.js +22 -0
- package/dist/lib/tracking/ecommerce/refunds.js.map +1 -0
- package/dist/lib/tracking/ecommerce/search.d.ts +24 -0
- package/dist/lib/tracking/ecommerce/search.js +22 -0
- package/dist/lib/tracking/ecommerce/search.js.map +1 -0
- package/dist/lib/tracking/ecommerce/subscriptions.d.ts +21 -0
- package/dist/lib/tracking/ecommerce/subscriptions.js +38 -0
- package/dist/lib/tracking/ecommerce/subscriptions.js.map +1 -0
- package/dist/lib/tracking/ecommerce/wishlist.d.ts +19 -0
- package/dist/lib/tracking/ecommerce/wishlist.js +26 -0
- package/dist/lib/tracking/ecommerce/wishlist.js.map +1 -0
- package/dist/lib/tracking/enterprise/acquisition.d.ts +25 -0
- package/dist/lib/tracking/enterprise/acquisition.js +22 -0
- package/dist/lib/tracking/enterprise/acquisition.js.map +1 -0
- package/dist/lib/tracking/enterprise/alerts.d.ts +32 -0
- package/dist/lib/tracking/enterprise/alerts.js +30 -0
- package/dist/lib/tracking/enterprise/alerts.js.map +1 -0
- package/dist/lib/tracking/enterprise/churn.d.ts +23 -0
- package/dist/lib/tracking/enterprise/churn.js +22 -0
- package/dist/lib/tracking/enterprise/churn.js.map +1 -0
- package/dist/lib/tracking/enterprise/cohorts.d.ts +18 -0
- package/dist/lib/tracking/enterprise/cohorts.js +18 -0
- package/dist/lib/tracking/enterprise/cohorts.js.map +1 -0
- package/dist/lib/tracking/enterprise/engagement.d.ts +31 -0
- package/dist/lib/tracking/enterprise/engagement.js +44 -0
- package/dist/lib/tracking/enterprise/engagement.js.map +1 -0
- package/dist/lib/tracking/enterprise/forecasting.d.ts +18 -0
- package/dist/lib/tracking/enterprise/forecasting.js +22 -0
- package/dist/lib/tracking/enterprise/forecasting.js.map +1 -0
- package/dist/lib/tracking/enterprise/index.d.ts +11 -0
- package/dist/lib/tracking/enterprise/index.js +12 -0
- package/dist/lib/tracking/enterprise/index.js.map +1 -0
- package/dist/lib/tracking/enterprise/monetization.d.ts +14 -0
- package/dist/lib/tracking/enterprise/monetization.js +10 -0
- package/dist/lib/tracking/enterprise/monetization.js.map +1 -0
- package/dist/lib/tracking/enterprise/multi-path-funnels.d.ts +20 -0
- package/dist/lib/tracking/enterprise/multi-path-funnels.js +18 -0
- package/dist/lib/tracking/enterprise/multi-path-funnels.js.map +1 -0
- package/dist/lib/tracking/enterprise/paths.d.ts +20 -0
- package/dist/lib/tracking/enterprise/paths.js +18 -0
- package/dist/lib/tracking/enterprise/paths.js.map +1 -0
- package/dist/lib/tracking/enterprise/security.d.ts +28 -0
- package/dist/lib/tracking/enterprise/security.js +26 -0
- package/dist/lib/tracking/enterprise/security.js.map +1 -0
- package/dist/lib/tracking/enterprise/support.d.ts +25 -0
- package/dist/lib/tracking/enterprise/support.js +22 -0
- package/dist/lib/tracking/enterprise/support.js.map +1 -0
- package/dist/lib/tracking/index.d.ts +4 -0
- package/dist/lib/tracking/index.js +5 -0
- package/dist/lib/tracking/index.js.map +1 -0
- package/dist/lib/types/analytics.d.ts +10 -2
- package/dist/lib/types/analytics.js +6 -0
- package/dist/lib/types/analytics.js.map +1 -0
- package/dist/lib/types/common.js +6 -0
- package/dist/lib/types/common.js.map +1 -0
- package/dist/lib/types/ecommerce.js +6 -0
- package/dist/lib/types/ecommerce.js.map +1 -0
- package/dist/lib/types/index.js +8 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/utils/browser.d.ts +16 -0
- package/dist/lib/utils/browser.js +32 -0
- package/dist/lib/utils/browser.js.map +1 -0
- package/dist/lib/utils/identity.js +346 -0
- package/dist/lib/utils/identity.js.map +1 -0
- package/dist/lib/utils/storage.js +105 -0
- package/dist/lib/utils/storage.js.map +1 -0
- package/dist/umd/237.index.js +2 -0
- package/dist/umd/237.index.js.map +1 -0
- package/dist/umd/546.index.js +3 -0
- package/dist/umd/546.index.js.LICENSE.txt +14 -0
- package/dist/umd/546.index.js.map +1 -0
- package/dist/umd/index.js +2 -0
- package/dist/umd/index.js.map +1 -0
- package/package.json +27 -80
- package/dist/lib/features/ecommerce/inventory.d.ts +0 -219
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Retention Analysis
|
|
3
|
+
* @module features/analytics/retention
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track and analyze user retention using cohort analysis,
|
|
7
|
+
* identify churn patterns, and measure user stickiness.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Measure week-over-week retention rates
|
|
11
|
+
* - Compare retention across user cohorts
|
|
12
|
+
* - Identify churn risk factors
|
|
13
|
+
* - Track feature adoption impact on retention
|
|
14
|
+
* - Calculate DAU/MAU ratios (stickiness)
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Day 1, 7, 30 retention rates
|
|
18
|
+
* - Cohort retention curves
|
|
19
|
+
* - Churn rate by segment
|
|
20
|
+
* - User resurrection rate
|
|
21
|
+
* - DAU/WAU/MAU ratios
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Retention curve: Line chart over time
|
|
25
|
+
* - Cohort matrix: Heatmap by cohort/period
|
|
26
|
+
* - Bar chart: Retention by segment
|
|
27
|
+
* - Trend line: Stickiness over time
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const retention = new Retention(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track user activity
|
|
34
|
+
* await retention.trackActivity({
|
|
35
|
+
* userId: 'user_123',
|
|
36
|
+
* action: 'feature_used'
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Get cohort analysis
|
|
40
|
+
* const cohorts = await retention.getCohortAnalysis({
|
|
41
|
+
* range: 'last90days',
|
|
42
|
+
* granularity: 'week'
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
import { FlowGridTransport } from "../../client/transport";
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// RETENTION CLASS
|
|
49
|
+
// ============================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Retention - Track and analyze user retention.
|
|
52
|
+
*
|
|
53
|
+
* @extends FlowGridTransport
|
|
54
|
+
*
|
|
55
|
+
* @description
|
|
56
|
+
* Provides retention analysis capabilities including:
|
|
57
|
+
* - User activity tracking
|
|
58
|
+
* - Cohort-based retention analysis
|
|
59
|
+
* - Stickiness metrics (DAU/MAU)
|
|
60
|
+
* - Churn prediction and analysis
|
|
61
|
+
* - Lifecycle stage tracking
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const retention = new Retention(webId, endpoint, apiKey);
|
|
66
|
+
*
|
|
67
|
+
* // Track daily user activity
|
|
68
|
+
* await retention.trackActivity({
|
|
69
|
+
* userId: 'user_123',
|
|
70
|
+
* action: 'daily_login'
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Analyze cohort retention
|
|
74
|
+
* const analysis = await retention.getCohortAnalysis({
|
|
75
|
+
* granularity: 'week',
|
|
76
|
+
* periods: 12
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* // Cohort heatmap data
|
|
80
|
+
* const heatmapData = analysis.matrix;
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export class Retention extends FlowGridTransport {
|
|
84
|
+
/**
|
|
85
|
+
* Tracks user activity for retention calculation.
|
|
86
|
+
*
|
|
87
|
+
* @param config - Activity configuration
|
|
88
|
+
* @returns Promise resolving to activity response
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Track on app open
|
|
93
|
+
* await retention.trackActivity({
|
|
94
|
+
* userId: 'user_123',
|
|
95
|
+
* action: 'app_opened'
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Track specific feature usage
|
|
99
|
+
* await retention.trackActivity({
|
|
100
|
+
* userId: 'user_123',
|
|
101
|
+
* action: 'used_export',
|
|
102
|
+
* properties: { format: 'pdf' }
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
async trackActivity(config) {
|
|
107
|
+
return await this.init("user_activity", {
|
|
108
|
+
type: "user_activity",
|
|
109
|
+
userId: config.userId,
|
|
110
|
+
action: config.action || "active",
|
|
111
|
+
sessionId: config.sessionId,
|
|
112
|
+
...config.properties,
|
|
113
|
+
timestamp: new Date().toISOString()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Tracks user lifecycle stage change.
|
|
118
|
+
*
|
|
119
|
+
* @param userId - User identifier
|
|
120
|
+
* @param stage - New lifecycle stage
|
|
121
|
+
* @param previousStage - Previous stage (optional)
|
|
122
|
+
* @returns Promise resolving to stage change response
|
|
123
|
+
*/
|
|
124
|
+
async trackLifecycleChange(userId, stage, previousStage) {
|
|
125
|
+
return await this.init("lifecycle_change", {
|
|
126
|
+
type: "lifecycle_change",
|
|
127
|
+
userId,
|
|
128
|
+
stage,
|
|
129
|
+
previousStage,
|
|
130
|
+
timestamp: new Date().toISOString()
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export default Retention;
|
|
135
|
+
//# sourceMappingURL=retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../../../src/lib/features/analytics/retention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA4H3D,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,SAAU,SAAQ,iBAAiB;IAC9C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,aAAa,CAAC,MAAsB;QACxC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACtC,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ;YACjC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,GAAG,MAAM,CAAC,UAAU;YACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAc,EACd,KAAyB,EACzB,aAAkC;QAElC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YACzC,IAAI,EAAE,kBAAkB;YACxB,MAAM;YACN,KAAK;YACL,aAAa;YACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CAEF;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
import { FlowGridTransport } from "../../client/transport";
|
|
47
|
-
import {
|
|
47
|
+
import { Teardown } from "../../utils/browser";
|
|
48
|
+
import { DeviceInfo, GeoLocation, UTMParams, TimeSeriesData, UserIdentity } from "../../types";
|
|
48
49
|
/**
|
|
49
50
|
* Configuration for starting a new session.
|
|
50
51
|
*/
|
|
@@ -235,43 +236,17 @@ export declare class Sessions extends FlowGridTransport {
|
|
|
235
236
|
*/
|
|
236
237
|
heartbeat(sessionId: string): Promise<SessionResponse>;
|
|
237
238
|
/**
|
|
238
|
-
*
|
|
239
|
+
* Auto-manage a browser session: starts on call, sends a heartbeat on a
|
|
240
|
+
* fixed interval, and ends the session on `pagehide`. The resolved
|
|
241
|
+
* `sessionId` is stored on `sessionStorage` so reloads within the same tab
|
|
242
|
+
* resume the same session.
|
|
239
243
|
*
|
|
240
|
-
* @param
|
|
241
|
-
* @param
|
|
242
|
-
* @returns
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```typescript
|
|
246
|
-
* const analytics = await sessions.getAnalytics({
|
|
247
|
-
* range: 'last7days'
|
|
248
|
-
* });
|
|
249
|
-
*
|
|
250
|
-
* // For pie chart - traffic sources
|
|
251
|
-
* const sourceData = analytics.bySource.map(s => ({
|
|
252
|
-
* name: s.source,
|
|
253
|
-
* value: s.sessions
|
|
254
|
-
* }));
|
|
255
|
-
*
|
|
256
|
-
* // For line chart - sessions over time
|
|
257
|
-
* const trendData = analytics.timeSeries.data;
|
|
258
|
-
* ```
|
|
259
|
-
*/
|
|
260
|
-
getAnalytics(filter?: DateRangeFilter, pagination?: PaginationParams): Promise<SessionAnalyticsData>;
|
|
261
|
-
/**
|
|
262
|
-
* Gets real-time session data for live dashboards.
|
|
263
|
-
*
|
|
264
|
-
* @returns Promise resolving to real-time session data
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* // Poll for real-time updates
|
|
269
|
-
* setInterval(async () => {
|
|
270
|
-
* const realTime = await sessions.getRealTime();
|
|
271
|
-
* updateDashboard(realTime.activeSessions);
|
|
272
|
-
* }, 10000);
|
|
273
|
-
* ```
|
|
244
|
+
* @param config Optional initial config forwarded to {@link Sessions.start}.
|
|
245
|
+
* @param options.heartbeatMs Interval between heartbeats. Default 30s.
|
|
246
|
+
* @returns A teardown function that ends the session and detaches listeners.
|
|
274
247
|
*/
|
|
275
|
-
|
|
248
|
+
autoTrack(config?: SessionStartConfig, options?: {
|
|
249
|
+
heartbeatMs?: number;
|
|
250
|
+
}): Teardown;
|
|
276
251
|
}
|
|
277
252
|
export default Sessions;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Session Tracking
|
|
3
|
+
* @module features/analytics/sessions
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Track user sessions with comprehensive context including device info,
|
|
7
|
+
* geographic location, traffic source, and engagement metrics.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Monitor active user sessions in real-time
|
|
11
|
+
* - Analyze session duration and depth
|
|
12
|
+
* - Track user journey across pages
|
|
13
|
+
* - Identify traffic sources and campaigns
|
|
14
|
+
* - Segment users by device and location
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Total sessions
|
|
18
|
+
* - Unique visitors
|
|
19
|
+
* - Average session duration
|
|
20
|
+
* - Pages per session
|
|
21
|
+
* - Bounce rate
|
|
22
|
+
* - New vs returning visitors
|
|
23
|
+
*
|
|
24
|
+
* @chartData
|
|
25
|
+
* - Line chart: Sessions over time
|
|
26
|
+
* - Pie chart: Traffic source breakdown
|
|
27
|
+
* - Bar chart: Sessions by device type
|
|
28
|
+
* - Geo map: Sessions by country
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const sessions = new Sessions(webId, endpoint, apiKey);
|
|
33
|
+
*
|
|
34
|
+
* // Start a new session
|
|
35
|
+
* const session = await sessions.start({
|
|
36
|
+
* userId: 'user_123',
|
|
37
|
+
* device: { type: 'desktop', browser: 'Chrome' },
|
|
38
|
+
* source: 'google',
|
|
39
|
+
* medium: 'organic'
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // End session
|
|
43
|
+
* await sessions.end(session.sessionId);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
import { FlowGridTransport } from "../../client/transport";
|
|
47
|
+
import { getWindow, getDocument, isBrowser, combineTeardowns } from "../../utils/browser";
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// SESSIONS CLASS
|
|
50
|
+
// ============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Sessions - Track and analyze user sessions.
|
|
53
|
+
*
|
|
54
|
+
* @extends FlowGridTransport
|
|
55
|
+
*
|
|
56
|
+
* @description
|
|
57
|
+
* Provides comprehensive session tracking including:
|
|
58
|
+
* - Session lifecycle (start, update, end)
|
|
59
|
+
* - Device and location tracking
|
|
60
|
+
* - Traffic source attribution
|
|
61
|
+
* - Real-time session monitoring
|
|
62
|
+
* - Session replay triggers
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const sessions = new Sessions(webId, endpoint, apiKey);
|
|
67
|
+
*
|
|
68
|
+
* // Start session on page load
|
|
69
|
+
* const session = await sessions.start({
|
|
70
|
+
* user: { userId: 'user_123' },
|
|
71
|
+
* device: { type: 'mobile', os: 'iOS' },
|
|
72
|
+
* source: 'email',
|
|
73
|
+
* campaign: 'summer_sale'
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Get real-time data
|
|
77
|
+
* const realTime = await sessions.getRealTime();
|
|
78
|
+
* console.log(`${realTime.activeSessions} users online`);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export class Sessions extends FlowGridTransport {
|
|
82
|
+
/**
|
|
83
|
+
* Starts a new user session.
|
|
84
|
+
*
|
|
85
|
+
* @param config - Session configuration
|
|
86
|
+
* @returns Promise resolving to session response with sessionId
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const session = await sessions.start({
|
|
91
|
+
* user: { userId: 'user_123' },
|
|
92
|
+
* source: 'google',
|
|
93
|
+
* medium: 'cpc',
|
|
94
|
+
* campaign: 'brand_terms'
|
|
95
|
+
* });
|
|
96
|
+
* localStorage.setItem('sessionId', session.response.sessionId);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
async start(config = {}) {
|
|
100
|
+
return await this.init("session_start", {
|
|
101
|
+
type: "session_start",
|
|
102
|
+
user: config.user,
|
|
103
|
+
device: config.device,
|
|
104
|
+
location: config.location,
|
|
105
|
+
source: config.source || config.utm?.utmSource,
|
|
106
|
+
medium: config.medium || config.utm?.utmMedium,
|
|
107
|
+
campaign: config.campaign || config.utm?.utmCampaign,
|
|
108
|
+
utm: config.utm,
|
|
109
|
+
landingPage: config.landingPage || (typeof window !== 'undefined' ? window.location.href : ''),
|
|
110
|
+
referrer: config.referrer || (typeof document !== 'undefined' ? document.referrer : ''),
|
|
111
|
+
...config.properties,
|
|
112
|
+
timestamp: new Date().toISOString()
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Updates an existing session with new data.
|
|
117
|
+
*
|
|
118
|
+
* @param sessionId - Session identifier
|
|
119
|
+
* @param properties - Properties to update
|
|
120
|
+
* @returns Promise resolving to update response
|
|
121
|
+
*/
|
|
122
|
+
async update(sessionId, properties) {
|
|
123
|
+
return await this.init("session_update", {
|
|
124
|
+
type: "session_update",
|
|
125
|
+
sessionId,
|
|
126
|
+
...properties,
|
|
127
|
+
timestamp: new Date().toISOString()
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Ends a user session.
|
|
132
|
+
*
|
|
133
|
+
* @param sessionId - Session identifier to end
|
|
134
|
+
* @returns Promise resolving to session end response with metrics
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* window.addEventListener('beforeunload', async () => {
|
|
139
|
+
* const sessionId = localStorage.getItem('sessionId');
|
|
140
|
+
* if (sessionId) {
|
|
141
|
+
* await sessions.end(sessionId);
|
|
142
|
+
* }
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
async end(sessionId) {
|
|
147
|
+
return await this.init("session_end", {
|
|
148
|
+
type: "session_end",
|
|
149
|
+
sessionId,
|
|
150
|
+
timestamp: new Date().toISOString()
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Tracks a heartbeat to keep session alive.
|
|
155
|
+
*
|
|
156
|
+
* @param sessionId - Session identifier
|
|
157
|
+
* @returns Promise resolving to heartbeat response
|
|
158
|
+
*/
|
|
159
|
+
async heartbeat(sessionId) {
|
|
160
|
+
return await this.init("session_heartbeat", {
|
|
161
|
+
type: "session_heartbeat",
|
|
162
|
+
sessionId,
|
|
163
|
+
timestamp: new Date().toISOString()
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Auto-manage a browser session: starts on call, sends a heartbeat on a
|
|
168
|
+
* fixed interval, and ends the session on `pagehide`. The resolved
|
|
169
|
+
* `sessionId` is stored on `sessionStorage` so reloads within the same tab
|
|
170
|
+
* resume the same session.
|
|
171
|
+
*
|
|
172
|
+
* @param config Optional initial config forwarded to {@link Sessions.start}.
|
|
173
|
+
* @param options.heartbeatMs Interval between heartbeats. Default 30s.
|
|
174
|
+
* @returns A teardown function that ends the session and detaches listeners.
|
|
175
|
+
*/
|
|
176
|
+
autoTrack(config = {}, options = {}) {
|
|
177
|
+
if (!isBrowser())
|
|
178
|
+
return () => { };
|
|
179
|
+
const win = getWindow();
|
|
180
|
+
const doc = getDocument();
|
|
181
|
+
const heartbeatMs = options.heartbeatMs ?? 30000;
|
|
182
|
+
const STORE_KEY = "flowgrid:sessionId";
|
|
183
|
+
let sessionId;
|
|
184
|
+
try {
|
|
185
|
+
sessionId = win.sessionStorage.getItem(STORE_KEY) || undefined;
|
|
186
|
+
}
|
|
187
|
+
catch { /* private mode */ }
|
|
188
|
+
const startPromise = sessionId
|
|
189
|
+
? Promise.resolve(sessionId)
|
|
190
|
+
: this.start(config).then((r) => {
|
|
191
|
+
sessionId = r.response.sessionId;
|
|
192
|
+
try {
|
|
193
|
+
win.sessionStorage.setItem(STORE_KEY, sessionId);
|
|
194
|
+
}
|
|
195
|
+
catch { /* ignore */ }
|
|
196
|
+
return sessionId;
|
|
197
|
+
}).catch(() => undefined);
|
|
198
|
+
const beat = win.setInterval(() => {
|
|
199
|
+
if (sessionId && doc.visibilityState === "visible")
|
|
200
|
+
void this.heartbeat(sessionId);
|
|
201
|
+
}, heartbeatMs);
|
|
202
|
+
const onHide = () => { if (sessionId)
|
|
203
|
+
void this.end(sessionId); };
|
|
204
|
+
win.addEventListener("pagehide", onHide);
|
|
205
|
+
return combineTeardowns(() => win.clearInterval(beat), () => win.removeEventListener("pagehide", onHide), () => { void startPromise.then(() => { if (sessionId)
|
|
206
|
+
void this.end(sessionId); }); }, () => { try {
|
|
207
|
+
win.sessionStorage.removeItem(STORE_KEY);
|
|
208
|
+
}
|
|
209
|
+
catch { /* ignore */ } });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
export default Sessions;
|
|
213
|
+
//# sourceMappingURL=sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../../src/lib/features/analytics/sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CA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S,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CACnF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
import { FlowGridTransport } from "../../client/transport";
|
|
41
|
-
import {
|
|
41
|
+
import { TimeSeriesData } from "../../types";
|
|
42
42
|
/**
|
|
43
43
|
* Base configuration for activation events.
|
|
44
44
|
*/
|
|
@@ -212,28 +212,5 @@ export declare class Activation extends FlowGridTransport {
|
|
|
212
212
|
* @returns Promise resolving to activation response
|
|
213
213
|
*/
|
|
214
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
215
|
}
|
|
239
216
|
export default Activation;
|
|
@@ -0,0 +1,175 @@
|
|
|
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 { FlowGridTransport } from "../../client/transport";
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// ACTIVATION CLASS
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Activation - Track user activation events.
|
|
46
|
+
*
|
|
47
|
+
* @extends FlowGridTransport
|
|
48
|
+
*
|
|
49
|
+
* @description
|
|
50
|
+
* Provides activation tracking including:
|
|
51
|
+
* - Generic activation events
|
|
52
|
+
* - Onboarding step tracking
|
|
53
|
+
* - First action tracking
|
|
54
|
+
* - Signup completion
|
|
55
|
+
* - Activation analytics
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const activation = new Activation(webId, endpoint, apiKey);
|
|
60
|
+
*
|
|
61
|
+
* // Track onboarding step
|
|
62
|
+
* await activation.trackOnboardingStep({
|
|
63
|
+
* userId: 'user_123',
|
|
64
|
+
* stepId: 'profile_setup',
|
|
65
|
+
* stepName: 'Set Up Profile',
|
|
66
|
+
* stepOrder: 2,
|
|
67
|
+
* totalSteps: 5
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Track first value action
|
|
71
|
+
* await activation.trackFirstAction({
|
|
72
|
+
* userId: 'user_123',
|
|
73
|
+
* actionName: 'created_first_project',
|
|
74
|
+
* timeSinceSignup: 3600000 // 1 hour
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export class Activation extends FlowGridTransport {
|
|
79
|
+
/**
|
|
80
|
+
* Creates and tracks an activation event.
|
|
81
|
+
*
|
|
82
|
+
* @param config - Activation configuration
|
|
83
|
+
* @returns Promise resolving to activation response
|
|
84
|
+
*/
|
|
85
|
+
async create(config) {
|
|
86
|
+
return await this.init(config.eventName, {
|
|
87
|
+
...config.properties,
|
|
88
|
+
type: "activation",
|
|
89
|
+
timestamp: new Date().toISOString()
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Tracks an onboarding step completion.
|
|
94
|
+
*
|
|
95
|
+
* @param config - Onboarding step configuration
|
|
96
|
+
* @returns Promise resolving to activation response
|
|
97
|
+
*/
|
|
98
|
+
async trackOnboardingStep(config) {
|
|
99
|
+
return await this.init("onboarding_step", {
|
|
100
|
+
type: "activation",
|
|
101
|
+
subtype: "onboarding_step",
|
|
102
|
+
userId: config.userId,
|
|
103
|
+
stepId: config.stepId,
|
|
104
|
+
stepName: config.stepName,
|
|
105
|
+
stepOrder: config.stepOrder,
|
|
106
|
+
totalSteps: config.totalSteps,
|
|
107
|
+
progress: Math.round((config.stepOrder / config.totalSteps) * 100),
|
|
108
|
+
timeSpent: config.timeSpent,
|
|
109
|
+
skipped: config.skipped || false,
|
|
110
|
+
...config.properties,
|
|
111
|
+
timestamp: new Date().toISOString()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Tracks onboarding completion.
|
|
116
|
+
*
|
|
117
|
+
* @param userId - User ID
|
|
118
|
+
* @param totalTimeSpent - Total time in onboarding (ms)
|
|
119
|
+
* @param stepsCompleted - Number of steps completed
|
|
120
|
+
* @param stepsSkipped - Number of steps skipped
|
|
121
|
+
* @returns Promise resolving to activation response
|
|
122
|
+
*/
|
|
123
|
+
async completeOnboarding(userId, totalTimeSpent, stepsCompleted, stepsSkipped) {
|
|
124
|
+
return await this.init("onboarding_completed", {
|
|
125
|
+
type: "activation",
|
|
126
|
+
subtype: "onboarding_complete",
|
|
127
|
+
userId,
|
|
128
|
+
totalTimeSpent,
|
|
129
|
+
stepsCompleted,
|
|
130
|
+
stepsSkipped,
|
|
131
|
+
completionRate: Math.round((stepsCompleted / (stepsCompleted + stepsSkipped)) * 100),
|
|
132
|
+
timestamp: new Date().toISOString()
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Tracks user's first meaningful action (activation moment).
|
|
137
|
+
*
|
|
138
|
+
* @param config - First action configuration
|
|
139
|
+
* @returns Promise resolving to activation response
|
|
140
|
+
*/
|
|
141
|
+
async trackFirstAction(config) {
|
|
142
|
+
return await this.init("first_action", {
|
|
143
|
+
type: "activation",
|
|
144
|
+
subtype: "first_action",
|
|
145
|
+
userId: config.userId,
|
|
146
|
+
actionName: config.actionName,
|
|
147
|
+
timeSinceSignup: config.timeSinceSignup,
|
|
148
|
+
source: config.source,
|
|
149
|
+
...config.properties,
|
|
150
|
+
timestamp: new Date().toISOString()
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Tracks signup completion.
|
|
155
|
+
*
|
|
156
|
+
* @param userId - User ID
|
|
157
|
+
* @param method - Signup method (email, google, etc.)
|
|
158
|
+
* @param source - Traffic source
|
|
159
|
+
* @param properties - Additional properties
|
|
160
|
+
* @returns Promise resolving to activation response
|
|
161
|
+
*/
|
|
162
|
+
async trackSignup(userId, method, source, properties) {
|
|
163
|
+
return await this.init("signup_completed", {
|
|
164
|
+
type: "activation",
|
|
165
|
+
subtype: "signup",
|
|
166
|
+
userId,
|
|
167
|
+
method,
|
|
168
|
+
source,
|
|
169
|
+
...properties,
|
|
170
|
+
timestamp: new Date().toISOString()
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export default Activation;
|
|
175
|
+
//# sourceMappingURL=activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.js","sourceRoot":"","sources":["../../../../src/lib/features/core/activation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA6G3D,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAC/C;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACvC,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,YAAY;YAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,mBAAmB,CAAC,MAA4B;QACpD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACxC,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM;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