flowgrid-sdk 1.4.2 → 1.6.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/dist/browser.js +12 -9
- package/dist/browser.js.map +1 -1
- package/dist/flowgrid-enterprise.flowgrid.chunk.js +2 -0
- package/dist/flowgrid-enterprise.flowgrid.chunk.js.map +1 -0
- package/dist/flowgrid-replay.flowgrid.chunk.js +3 -0
- package/dist/flowgrid-replay.flowgrid.chunk.js.LICENSE.txt +14 -0
- package/dist/flowgrid-replay.flowgrid.chunk.js.map +1 -0
- package/dist/flowgrid-vitals.flowgrid.chunk.js +2 -0
- package/dist/flowgrid-vitals.flowgrid.chunk.js.map +1 -0
- package/dist/flowgrid.min.js +1 -1
- package/dist/flowgrid.min.js.LICENSE.txt +14 -0
- package/dist/flowgrid.min.js.map +1 -1
- package/dist/index.js +63 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/client/transport.js +12 -3
- package/dist/lib/client/transport.js.map +1 -1
- package/dist/lib/consent/index.js +5 -1
- package/dist/lib/consent/index.js.map +1 -1
- package/dist/lib/consent/manager.js +5 -1
- package/dist/lib/consent/manager.js.map +1 -1
- package/dist/lib/consent/types.js +2 -1
- package/dist/lib/consent/types.js.map +1 -1
- package/dist/lib/features/analytics/attribution.js +11 -7
- package/dist/lib/features/analytics/attribution.js.map +1 -1
- package/dist/lib/features/analytics/events.js +7 -3
- package/dist/lib/features/analytics/events.js.map +1 -1
- package/dist/lib/features/analytics/funnels.js +7 -3
- package/dist/lib/features/analytics/funnels.js.map +1 -1
- package/dist/lib/features/analytics/heatmaps.js +27 -14
- package/dist/lib/features/analytics/heatmaps.js.map +1 -1
- package/dist/lib/features/analytics/identify.js +7 -3
- package/dist/lib/features/analytics/identify.js.map +1 -1
- package/dist/lib/features/analytics/index.js +24 -10
- package/dist/lib/features/analytics/index.js.map +1 -1
- package/dist/lib/features/analytics/page-views.js +12 -8
- package/dist/lib/features/analytics/page-views.js.map +1 -1
- package/dist/lib/features/analytics/performance.js +46 -9
- package/dist/lib/features/analytics/performance.js.map +1 -1
- package/dist/lib/features/analytics/replay.js +55 -9
- package/dist/lib/features/analytics/replay.js.map +1 -1
- package/dist/lib/features/analytics/retention.js +7 -3
- package/dist/lib/features/analytics/retention.js.map +1 -1
- package/dist/lib/features/analytics/sessions.js +12 -8
- package/dist/lib/features/analytics/sessions.js.map +1 -1
- package/dist/lib/features/core/activation.js +7 -3
- package/dist/lib/features/core/activation.js.map +1 -1
- package/dist/lib/features/core/experiment.js +9 -5
- package/dist/lib/features/core/experiment.js.map +1 -1
- package/dist/lib/features/core/index.js +11 -4
- package/dist/lib/features/core/index.js.map +1 -1
- package/dist/lib/features/core/track-feature.js +7 -3
- package/dist/lib/features/core/track-feature.js.map +1 -1
- package/dist/lib/features/core/track-prompt.js +7 -3
- package/dist/lib/features/core/track-prompt.js.map +1 -1
- package/dist/lib/features/ecommerce/cart.js +7 -3
- package/dist/lib/features/ecommerce/cart.js.map +1 -1
- package/dist/lib/features/ecommerce/checkout.js +7 -3
- package/dist/lib/features/ecommerce/checkout.js.map +1 -1
- package/dist/lib/features/ecommerce/index.js +23 -10
- package/dist/lib/features/ecommerce/index.js.map +1 -1
- package/dist/lib/features/ecommerce/ltv.js +7 -3
- package/dist/lib/features/ecommerce/ltv.js.map +1 -1
- package/dist/lib/features/ecommerce/products.js +7 -3
- package/dist/lib/features/ecommerce/products.js.map +1 -1
- package/dist/lib/features/ecommerce/promotions.js +7 -3
- package/dist/lib/features/ecommerce/promotions.js.map +1 -1
- package/dist/lib/features/ecommerce/purchases.js +7 -3
- package/dist/lib/features/ecommerce/purchases.js.map +1 -1
- package/dist/lib/features/ecommerce/refunds.js +7 -3
- package/dist/lib/features/ecommerce/refunds.js.map +1 -1
- package/dist/lib/features/ecommerce/search.js +7 -3
- package/dist/lib/features/ecommerce/search.js.map +1 -1
- package/dist/lib/features/ecommerce/subscriptions.js +7 -3
- package/dist/lib/features/ecommerce/subscriptions.js.map +1 -1
- package/dist/lib/features/ecommerce/wishlist.js +7 -3
- package/dist/lib/features/ecommerce/wishlist.js.map +1 -1
- package/dist/lib/features/enterprise/acquisition.js +16 -7
- package/dist/lib/features/enterprise/acquisition.js.map +1 -1
- package/dist/lib/features/enterprise/alerts.js +18 -8
- package/dist/lib/features/enterprise/alerts.js.map +1 -1
- package/dist/lib/features/enterprise/churn.js +12 -5
- package/dist/lib/features/enterprise/churn.js.map +1 -1
- package/dist/lib/features/enterprise/cohorts.js +10 -4
- package/dist/lib/features/enterprise/cohorts.js.map +1 -1
- package/dist/lib/features/enterprise/engagement.js +19 -12
- package/dist/lib/features/enterprise/engagement.js.map +1 -1
- package/dist/lib/features/enterprise/forecasting.js +18 -8
- package/dist/lib/features/enterprise/forecasting.js.map +1 -1
- package/dist/lib/features/enterprise/index.js +75 -22
- package/dist/lib/features/enterprise/index.js.map +1 -1
- package/dist/lib/features/enterprise/monetization.js +16 -7
- package/dist/lib/features/enterprise/monetization.js.map +1 -1
- package/dist/lib/features/enterprise/multi-path-funnels.js +16 -7
- package/dist/lib/features/enterprise/multi-path-funnels.js.map +1 -1
- package/dist/lib/features/enterprise/paths.js +18 -8
- package/dist/lib/features/enterprise/paths.js.map +1 -1
- package/dist/lib/features/enterprise/security.js +14 -6
- package/dist/lib/features/enterprise/security.js.map +1 -1
- package/dist/lib/features/enterprise/support.js +14 -6
- package/dist/lib/features/enterprise/support.js.map +1 -1
- package/dist/lib/flowgrid.d.ts +27 -15
- package/dist/lib/flowgrid.js +162 -64
- package/dist/lib/flowgrid.js.map +1 -1
- package/dist/lib/tracking/analytics/attribution.d.ts +3 -3
- package/dist/lib/tracking/analytics/attribution.js +5 -1
- package/dist/lib/tracking/analytics/attribution.js.map +1 -1
- package/dist/lib/tracking/analytics/events.d.ts +6 -6
- package/dist/lib/tracking/analytics/events.js +5 -1
- package/dist/lib/tracking/analytics/events.js.map +1 -1
- package/dist/lib/tracking/analytics/funnels.d.ts +4 -4
- package/dist/lib/tracking/analytics/funnels.js +5 -1
- package/dist/lib/tracking/analytics/funnels.js.map +1 -1
- package/dist/lib/tracking/analytics/heatmaps.d.ts +3 -3
- package/dist/lib/tracking/analytics/heatmaps.js +5 -1
- package/dist/lib/tracking/analytics/heatmaps.js.map +1 -1
- package/dist/lib/tracking/analytics/identify.d.ts +4 -4
- package/dist/lib/tracking/analytics/identify.js +5 -1
- package/dist/lib/tracking/analytics/identify.js.map +1 -1
- package/dist/lib/tracking/analytics/index.js +23 -10
- package/dist/lib/tracking/analytics/index.js.map +1 -1
- package/dist/lib/tracking/analytics/page-views.d.ts +4 -4
- package/dist/lib/tracking/analytics/page-views.js +5 -1
- package/dist/lib/tracking/analytics/page-views.js.map +1 -1
- package/dist/lib/tracking/analytics/performance.d.ts +3 -3
- package/dist/lib/tracking/analytics/performance.js +5 -1
- package/dist/lib/tracking/analytics/performance.js.map +1 -1
- package/dist/lib/tracking/analytics/replay.js +5 -1
- package/dist/lib/tracking/analytics/replay.js.map +1 -1
- package/dist/lib/tracking/analytics/retention.d.ts +1 -1
- package/dist/lib/tracking/analytics/retention.js +5 -1
- package/dist/lib/tracking/analytics/retention.js.map +1 -1
- package/dist/lib/tracking/analytics/sessions.d.ts +4 -4
- package/dist/lib/tracking/analytics/sessions.js +5 -1
- package/dist/lib/tracking/analytics/sessions.js.map +1 -1
- package/dist/lib/tracking/core/activation.d.ts +5 -5
- package/dist/lib/tracking/core/activation.js +5 -1
- package/dist/lib/tracking/core/activation.js.map +1 -1
- package/dist/lib/tracking/core/experiment.d.ts +4 -4
- package/dist/lib/tracking/core/experiment.js +5 -1
- package/dist/lib/tracking/core/experiment.js.map +1 -1
- package/dist/lib/tracking/core/feature.d.ts +2 -2
- package/dist/lib/tracking/core/feature.js +5 -1
- package/dist/lib/tracking/core/feature.js.map +1 -1
- package/dist/lib/tracking/core/index.js +11 -4
- package/dist/lib/tracking/core/index.js.map +1 -1
- package/dist/lib/tracking/core/prompt.d.ts +5 -5
- package/dist/lib/tracking/core/prompt.js +5 -1
- package/dist/lib/tracking/core/prompt.js.map +1 -1
- package/dist/lib/tracking/ecommerce/cart.d.ts +4 -4
- package/dist/lib/tracking/ecommerce/cart.js +5 -1
- package/dist/lib/tracking/ecommerce/cart.js.map +1 -1
- package/dist/lib/tracking/ecommerce/checkout.d.ts +4 -4
- package/dist/lib/tracking/ecommerce/checkout.js +5 -1
- package/dist/lib/tracking/ecommerce/checkout.js.map +1 -1
- package/dist/lib/tracking/ecommerce/index.js +23 -10
- package/dist/lib/tracking/ecommerce/index.js.map +1 -1
- package/dist/lib/tracking/ecommerce/ltv.d.ts +2 -2
- package/dist/lib/tracking/ecommerce/ltv.js +5 -1
- package/dist/lib/tracking/ecommerce/ltv.js.map +1 -1
- package/dist/lib/tracking/ecommerce/products.d.ts +3 -3
- package/dist/lib/tracking/ecommerce/products.js +5 -1
- package/dist/lib/tracking/ecommerce/products.js.map +1 -1
- package/dist/lib/tracking/ecommerce/promotions.d.ts +3 -3
- package/dist/lib/tracking/ecommerce/promotions.js +5 -1
- package/dist/lib/tracking/ecommerce/promotions.js.map +1 -1
- package/dist/lib/tracking/ecommerce/purchases.d.ts +1 -1
- package/dist/lib/tracking/ecommerce/purchases.js +5 -1
- package/dist/lib/tracking/ecommerce/purchases.js.map +1 -1
- package/dist/lib/tracking/ecommerce/refunds.d.ts +4 -4
- package/dist/lib/tracking/ecommerce/refunds.js +5 -1
- package/dist/lib/tracking/ecommerce/refunds.js.map +1 -1
- package/dist/lib/tracking/ecommerce/search.d.ts +4 -4
- package/dist/lib/tracking/ecommerce/search.js +5 -1
- package/dist/lib/tracking/ecommerce/search.js.map +1 -1
- package/dist/lib/tracking/ecommerce/subscriptions.d.ts +6 -6
- package/dist/lib/tracking/ecommerce/subscriptions.js +5 -1
- package/dist/lib/tracking/ecommerce/subscriptions.js.map +1 -1
- package/dist/lib/tracking/ecommerce/wishlist.d.ts +5 -5
- package/dist/lib/tracking/ecommerce/wishlist.js +5 -1
- package/dist/lib/tracking/ecommerce/wishlist.js.map +1 -1
- package/dist/lib/tracking/enterprise/acquisition.js +5 -1
- package/dist/lib/tracking/enterprise/acquisition.js.map +1 -1
- package/dist/lib/tracking/enterprise/alerts.js +5 -1
- package/dist/lib/tracking/enterprise/alerts.js.map +1 -1
- package/dist/lib/tracking/enterprise/churn.d.ts +1 -1
- package/dist/lib/tracking/enterprise/churn.js +5 -1
- package/dist/lib/tracking/enterprise/churn.js.map +1 -1
- package/dist/lib/tracking/enterprise/cohorts.d.ts +1 -1
- package/dist/lib/tracking/enterprise/cohorts.js +5 -1
- package/dist/lib/tracking/enterprise/cohorts.js.map +1 -1
- package/dist/lib/tracking/enterprise/engagement.d.ts +4 -4
- package/dist/lib/tracking/enterprise/engagement.js +5 -1
- package/dist/lib/tracking/enterprise/engagement.js.map +1 -1
- package/dist/lib/tracking/enterprise/forecasting.d.ts +4 -4
- package/dist/lib/tracking/enterprise/forecasting.js +5 -1
- package/dist/lib/tracking/enterprise/forecasting.js.map +1 -1
- package/dist/lib/tracking/enterprise/index.js +25 -11
- package/dist/lib/tracking/enterprise/index.js.map +1 -1
- package/dist/lib/tracking/enterprise/monetization.js +5 -1
- package/dist/lib/tracking/enterprise/monetization.js.map +1 -1
- package/dist/lib/tracking/enterprise/multi-path-funnels.js +5 -1
- package/dist/lib/tracking/enterprise/multi-path-funnels.js.map +1 -1
- package/dist/lib/tracking/enterprise/paths.js +5 -1
- package/dist/lib/tracking/enterprise/paths.js.map +1 -1
- package/dist/lib/tracking/enterprise/security.js +5 -1
- package/dist/lib/tracking/enterprise/security.js.map +1 -1
- package/dist/lib/tracking/enterprise/support.js +5 -1
- package/dist/lib/tracking/enterprise/support.js.map +1 -1
- package/dist/lib/tracking/index.js +20 -4
- package/dist/lib/tracking/index.js.map +1 -1
- package/dist/lib/types/analytics.js +2 -1
- package/dist/lib/types/analytics.js.map +1 -1
- package/dist/lib/types/common.js +2 -1
- package/dist/lib/types/common.js.map +1 -1
- package/dist/lib/types/ecommerce.js +2 -1
- package/dist/lib/types/ecommerce.js.map +1 -1
- package/dist/lib/types/index.js +19 -3
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/utils/browser.js +10 -4
- package/dist/lib/utils/browser.js.map +1 -1
- package/dist/lib/utils/identity.js +8 -4
- package/dist/lib/utils/identity.js.map +1 -1
- package/dist/lib/utils/storage.js +14 -6
- package/dist/lib/utils/storage.js.map +1 -1
- package/dist/umd/index.js +2 -1
- package/dist/umd/index.js.LICENSE.txt +14 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Enterprise - Security & Compliance Analytics
|
|
3
4
|
* @module features/enterprise/security
|
|
@@ -38,14 +39,20 @@
|
|
|
38
39
|
* });
|
|
39
40
|
* ```
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.SecurityAnalytics = void 0;
|
|
44
|
+
exports.classifyRiskLevel = classifyRiskLevel;
|
|
45
|
+
exports.calculateFailedLoginRate = calculateFailedLoginRate;
|
|
46
|
+
exports.isSuspiciousLoginPattern = isSuspiciousLoginPattern;
|
|
47
|
+
exports.determineEventSeverity = determineEventSeverity;
|
|
48
|
+
const transport_1 = require("../../client/transport");
|
|
42
49
|
// ============================================================================
|
|
43
50
|
// HELPER FUNCTIONS
|
|
44
51
|
// ============================================================================
|
|
45
52
|
/**
|
|
46
53
|
* Classify risk level from score.
|
|
47
54
|
*/
|
|
48
|
-
|
|
55
|
+
function classifyRiskLevel(score) {
|
|
49
56
|
if (score < 25)
|
|
50
57
|
return 'low';
|
|
51
58
|
if (score < 50)
|
|
@@ -57,7 +64,7 @@ export function classifyRiskLevel(score) {
|
|
|
57
64
|
/**
|
|
58
65
|
* Calculate failed login rate.
|
|
59
66
|
*/
|
|
60
|
-
|
|
67
|
+
function calculateFailedLoginRate(failed, total) {
|
|
61
68
|
if (total === 0)
|
|
62
69
|
return 0;
|
|
63
70
|
return Math.round((failed / total) * 10000) / 100;
|
|
@@ -65,13 +72,13 @@ export function calculateFailedLoginRate(failed, total) {
|
|
|
65
72
|
/**
|
|
66
73
|
* Check if login pattern is suspicious.
|
|
67
74
|
*/
|
|
68
|
-
|
|
75
|
+
function isSuspiciousLoginPattern(failedAttempts, timeWindowMinutes, threshold = 5) {
|
|
69
76
|
return failedAttempts >= threshold && timeWindowMinutes <= 15;
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
72
79
|
* Determine event severity.
|
|
73
80
|
*/
|
|
74
|
-
|
|
81
|
+
function determineEventSeverity(eventType, success) {
|
|
75
82
|
const criticalEvents = ['suspicious_activity'];
|
|
76
83
|
const highEvents = ['role_change', 'permission_change', 'data_deletion', 'api_key_revoked'];
|
|
77
84
|
const mediumEvents = ['login_failure', 'password_reset', 'data_export'];
|
|
@@ -89,7 +96,7 @@ export function determineEventSeverity(eventType, success) {
|
|
|
89
96
|
/**
|
|
90
97
|
* Security and compliance analytics class.
|
|
91
98
|
*/
|
|
92
|
-
|
|
99
|
+
class SecurityAnalytics extends transport_1.FlowGridTransport {
|
|
93
100
|
/**
|
|
94
101
|
* Track login attempt.
|
|
95
102
|
*/
|
|
@@ -199,4 +206,5 @@ export class SecurityAnalytics extends FlowGridTransport {
|
|
|
199
206
|
});
|
|
200
207
|
}
|
|
201
208
|
}
|
|
209
|
+
exports.SecurityAnalytics = SecurityAnalytics;
|
|
202
210
|
//# sourceMappingURL=security.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/lib/features/enterprise/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/lib/features/enterprise/security.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;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AY;YACZ,OAAO;YACP,SAAS,EAAE,qBAA0C;YACrD,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAA6B;QACtD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,2BAA2B,EAAE;YACzD,IAAI,EAAE,UAAU;YAChB,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CAEF;AA/HD,8CA+HC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Enterprise - Customer Support & Experience Analytics
|
|
3
4
|
* @module features/enterprise/support
|
|
@@ -39,14 +40,20 @@
|
|
|
39
40
|
* });
|
|
40
41
|
* ```
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.SupportAnalytics = void 0;
|
|
45
|
+
exports.calculateFCRRate = calculateFCRRate;
|
|
46
|
+
exports.calculateAvgResponseTime = calculateAvgResponseTime;
|
|
47
|
+
exports.classifyCSAT = classifyCSAT;
|
|
48
|
+
exports.formatDuration = formatDuration;
|
|
49
|
+
const transport_1 = require("../../client/transport");
|
|
43
50
|
// ============================================================================
|
|
44
51
|
// HELPER FUNCTIONS
|
|
45
52
|
// ============================================================================
|
|
46
53
|
/**
|
|
47
54
|
* Calculate first contact resolution rate.
|
|
48
55
|
*/
|
|
49
|
-
|
|
56
|
+
function calculateFCRRate(resolvedFirstContact, totalResolved) {
|
|
50
57
|
if (totalResolved === 0)
|
|
51
58
|
return 0;
|
|
52
59
|
return Math.round((resolvedFirstContact / totalResolved) * 10000) / 100;
|
|
@@ -54,7 +61,7 @@ export function calculateFCRRate(resolvedFirstContact, totalResolved) {
|
|
|
54
61
|
/**
|
|
55
62
|
* Calculate average response time.
|
|
56
63
|
*/
|
|
57
|
-
|
|
64
|
+
function calculateAvgResponseTime(responseTimes) {
|
|
58
65
|
if (responseTimes.length === 0)
|
|
59
66
|
return 0;
|
|
60
67
|
const sum = responseTimes.reduce((a, b) => a + b, 0);
|
|
@@ -63,7 +70,7 @@ export function calculateAvgResponseTime(responseTimes) {
|
|
|
63
70
|
/**
|
|
64
71
|
* Classify CSAT score.
|
|
65
72
|
*/
|
|
66
|
-
|
|
73
|
+
function classifyCSAT(score) {
|
|
67
74
|
if (score < 2)
|
|
68
75
|
return 'poor';
|
|
69
76
|
if (score < 3)
|
|
@@ -75,7 +82,7 @@ export function classifyCSAT(score) {
|
|
|
75
82
|
/**
|
|
76
83
|
* Format duration in human-readable format.
|
|
77
84
|
*/
|
|
78
|
-
|
|
85
|
+
function formatDuration(ms) {
|
|
79
86
|
if (ms < 60000)
|
|
80
87
|
return `${Math.round(ms / 1000)}s`;
|
|
81
88
|
if (ms < 3600000)
|
|
@@ -90,7 +97,7 @@ export function formatDuration(ms) {
|
|
|
90
97
|
/**
|
|
91
98
|
* Customer support and experience analytics class.
|
|
92
99
|
*/
|
|
93
|
-
|
|
100
|
+
class SupportAnalytics extends transport_1.FlowGridTransport {
|
|
94
101
|
/**
|
|
95
102
|
* Track new support ticket.
|
|
96
103
|
*/
|
|
@@ -159,4 +166,5 @@ export class SupportAnalytics extends FlowGridTransport {
|
|
|
159
166
|
});
|
|
160
167
|
}
|
|
161
168
|
}
|
|
169
|
+
exports.SupportAnalytics = SupportAnalytics;
|
|
162
170
|
//# sourceMappingURL=support.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../../../src/lib/features/enterprise/support.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../../../src/l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B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,yBAAyB,EAAE;YACvD,IAAI,EAAE,SAAS;YACf,QAAQ;YACR,gBAAgB;YAChB,gBAAgB;YAChB,sBAAsB,EAAE,gBAAgB,KAAK,CAAC;YAC9C,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,MAAkB;QAChC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YAC5C,IAAI,EAAE,SAAS;YACf,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB,CAAC,MAA8B;QACxD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,2BAA2B,EAAE;YACzD,IAAI,EAAE,SAAS;YACf,GAAG,MAAM;YACT,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CAEF;AAlFD,4CAkFC"}
|
package/dist/lib/flowgrid.d.ts
CHANGED
|
@@ -31,7 +31,10 @@
|
|
|
31
31
|
*/
|
|
32
32
|
import { FlowGridTransport, FlowGridTransportConfig } from "./client/transport";
|
|
33
33
|
import { IdentityManager } from "./utils/identity";
|
|
34
|
-
import {
|
|
34
|
+
import type { EngagementTracker, CohortTracker, ChurnTracker, MonetizationTracker, MultiPathFunnelTracker, SupportTracker, AcquisitionTracker, PathTracker, AlertTracker, SecurityTracker, ForecastingTracker } from "./tracking/enterprise";
|
|
35
|
+
import { ActivationTracker, ExperimentTracker, FeatureTracker, PromptTracker } from "./tracking/core";
|
|
36
|
+
import { EventTracker, PageViewTracker, SessionTracker, IdentifyTracker, FunnelTracker, RetentionTracker, AttributionTracker, HeatmapTracker, PerformanceTracker, ReplayTracker } from "./tracking/analytics";
|
|
37
|
+
import { ProductTracker, CartTracker, CheckoutTracker, PurchaseTracker, RefundTracker, PromotionTracker, WishlistTracker, SubscriptionTracker, LTVTracker, SearchTracker } from "./tracking/ecommerce";
|
|
35
38
|
export type FlowGridTrackDomain = "event" | "activation" | "feature" | "prompt" | "experiment" | "ecommerce" | "analytics" | "retention" | "attribution" | "funnel" | "engagement" | "churn" | "monetization" | "support" | "acquisition" | "paths" | "security" | "multiPathFunnels";
|
|
36
39
|
export interface FlowGridTrackOptions {
|
|
37
40
|
userId?: string;
|
|
@@ -774,9 +777,10 @@ export interface FlowGridInitConfig {
|
|
|
774
777
|
traits?: Record<string, unknown>;
|
|
775
778
|
};
|
|
776
779
|
/**
|
|
777
|
-
* Browser auto-instrumentation. `true` (default) turns on
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
+
* Browser auto-instrumentation. `true` (default) turns on engagement and
|
|
781
|
+
* session replay. Pageviews, sessions, heatmaps, performance, and attribution
|
|
782
|
+
* are handled by the flowgrid.js core script and are off by default here.
|
|
783
|
+
* Pass an object to control individual features, or `false` to opt out completely.
|
|
780
784
|
*/
|
|
781
785
|
autoTrack?: boolean | AutoTrackOptions;
|
|
782
786
|
/**
|
|
@@ -840,6 +844,13 @@ export declare class FlowGrid {
|
|
|
840
844
|
static init(config: FlowGridInitConfig): FlowGrid;
|
|
841
845
|
/** Returns the singleton created by {@link FlowGrid.init}, if any. */
|
|
842
846
|
static instance(): FlowGrid | null;
|
|
847
|
+
/**
|
|
848
|
+
* Await the enterprise feature chunk. Call this before accessing any
|
|
849
|
+
* enterprise namespace (`fg.engagement`, `fg.churn`, etc.) if you need
|
|
850
|
+
* guaranteed availability rather than relying on the background pre-fetch
|
|
851
|
+
* started by `init()`.
|
|
852
|
+
*/
|
|
853
|
+
static loadEnterprise(): Promise<void>;
|
|
843
854
|
/**
|
|
844
855
|
* Reset the singleton — primarily for tests / hot-reload. Tears down any
|
|
845
856
|
* active auto-instrumentation.
|
|
@@ -876,6 +887,7 @@ export declare class FlowGrid {
|
|
|
876
887
|
get ltv(): LTVTracker;
|
|
877
888
|
get search(): SearchTracker;
|
|
878
889
|
get subscriptions(): SubscriptionTracker;
|
|
890
|
+
private _requireEnterprise;
|
|
879
891
|
get engagement(): EngagementTracker;
|
|
880
892
|
get cohorts(): CohortTracker;
|
|
881
893
|
get churn(): ChurnTracker;
|
|
@@ -924,7 +936,7 @@ export declare class FlowGrid {
|
|
|
924
936
|
experiment(experimentId: string, options: {
|
|
925
937
|
variant: string;
|
|
926
938
|
userId: string;
|
|
927
|
-
}): Promise<import("
|
|
939
|
+
}): Promise<import("..").ExperimentResponse>;
|
|
928
940
|
/**
|
|
929
941
|
* Identify a user.
|
|
930
942
|
*
|
|
@@ -933,7 +945,7 @@ export declare class FlowGrid {
|
|
|
933
945
|
* fg.identifyUser("u_1", { plan: "pro", email: "alice@example.com" });
|
|
934
946
|
* ```
|
|
935
947
|
*/
|
|
936
|
-
identifyUser(userId: string, traits?: Record<string, unknown>, anonymousId?: string): Promise<import("
|
|
948
|
+
identifyUser(userId: string, traits?: Record<string, unknown>, anonymousId?: string): Promise<import("..").IdentifyResponse>;
|
|
937
949
|
/**
|
|
938
950
|
* Track a page view. Auto-detects URL/path/title/referrer in the browser.
|
|
939
951
|
*
|
|
@@ -948,19 +960,19 @@ export declare class FlowGrid {
|
|
|
948
960
|
referrer?: string;
|
|
949
961
|
userId?: string;
|
|
950
962
|
sessionId?: string;
|
|
951
|
-
}): Promise<import("
|
|
963
|
+
}): Promise<import("..").PageViewResponse>;
|
|
952
964
|
/**
|
|
953
|
-
* Enable browser-side auto-instrumentation in a single call.
|
|
965
|
+
* Enable browser-side auto-instrumentation in a single call.
|
|
954
966
|
*
|
|
955
|
-
*
|
|
956
|
-
* - **Page views** — initial view + SPA `pushState`/`popstate` + scroll-depth + time-on-page
|
|
957
|
-
* - **Performance** — Core Web Vitals via `web-vitals` + navigation timing
|
|
958
|
-
* - **Heatmaps** — click + scroll listeners
|
|
967
|
+
* On by default (opt-out with `false`):
|
|
959
968
|
* - **Engagement** — session depth, action count, and active/passive/idle transitions
|
|
960
|
-
* - **
|
|
969
|
+
* - **Replay** — DOM session recording via rrweb
|
|
970
|
+
*
|
|
971
|
+
* Off by default (these are handled by the flowgrid.js core script):
|
|
972
|
+
* - **Sessions**, **Page views**, **Performance**, **Heatmaps**, **Attribution**
|
|
961
973
|
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
974
|
+
* Pass `false` for any feature to disable it. Returns a single teardown
|
|
975
|
+
* function that detaches every listener; safe no-op on the server.
|
|
964
976
|
*
|
|
965
977
|
* @example
|
|
966
978
|
* ```ts
|
package/dist/lib/flowgrid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Unified FlowGrid SDK facade.
|
|
3
4
|
* @module flowgrid
|
|
@@ -29,13 +30,66 @@
|
|
|
29
30
|
* fg.events.client.track({ eventName: "x", sessionId: "...", category: "..." });
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
36
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
37
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
38
|
+
}
|
|
39
|
+
Object.defineProperty(o, k2, desc);
|
|
40
|
+
}) : (function(o, m, k, k2) {
|
|
41
|
+
if (k2 === undefined) k2 = k;
|
|
42
|
+
o[k2] = m[k];
|
|
43
|
+
}));
|
|
44
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
45
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
46
|
+
}) : function(o, v) {
|
|
47
|
+
o["default"] = v;
|
|
48
|
+
});
|
|
49
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
50
|
+
var ownKeys = function(o) {
|
|
51
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
52
|
+
var ar = [];
|
|
53
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
54
|
+
return ar;
|
|
55
|
+
};
|
|
56
|
+
return ownKeys(o);
|
|
57
|
+
};
|
|
58
|
+
return function (mod) {
|
|
59
|
+
if (mod && mod.__esModule) return mod;
|
|
60
|
+
var result = {};
|
|
61
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
62
|
+
__setModuleDefault(result, mod);
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
})();
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.FlowGrid = void 0;
|
|
68
|
+
const transport_1 = require("./client/transport");
|
|
69
|
+
const identity_1 = require("./utils/identity");
|
|
70
|
+
const core_1 = require("./features/core");
|
|
71
|
+
const analytics_1 = require("./features/analytics");
|
|
72
|
+
const ecommerce_1 = require("./features/ecommerce");
|
|
73
|
+
// Import directly from sub-barrels (not the top-level ./tracking barrel) so
|
|
74
|
+
// the static module graph never reaches ./tracking/enterprise and its
|
|
75
|
+
// dependencies can be tree-shaken / placed only in the async chunk.
|
|
76
|
+
const core_2 = require("./tracking/core");
|
|
77
|
+
const analytics_2 = require("./tracking/analytics");
|
|
78
|
+
const ecommerce_2 = require("./tracking/ecommerce");
|
|
79
|
+
// ---- Enterprise lazy-load state (module-level singleton) ----
|
|
80
|
+
let _enterpriseFeatures = null;
|
|
81
|
+
let _enterpriseTracking = null;
|
|
82
|
+
function loadEnterpriseModules() {
|
|
83
|
+
if (_enterpriseFeatures && _enterpriseTracking)
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
return Promise.all([
|
|
86
|
+
Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "flowgrid-enterprise" */ "./features/enterprise"))),
|
|
87
|
+
Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "flowgrid-enterprise" */ "./tracking/enterprise"))),
|
|
88
|
+
]).then(([features, tracking]) => {
|
|
89
|
+
_enterpriseFeatures = features;
|
|
90
|
+
_enterpriseTracking = tracking;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
39
93
|
const UNHANDLED_TRACK = { handled: false };
|
|
40
94
|
const PRODUCT_KEYS = [
|
|
41
95
|
"productId",
|
|
@@ -112,7 +166,7 @@ const DEFAULT_ENDPOINT = "https://core.flow-grid.xyz";
|
|
|
112
166
|
* Each feature is exposed as a lazily-initialised shortcut wrapper, so the
|
|
113
167
|
* SDK has zero overhead for unused features.
|
|
114
168
|
*/
|
|
115
|
-
|
|
169
|
+
class FlowGrid {
|
|
116
170
|
/**
|
|
117
171
|
* One-line init. Idempotent — calling twice returns the same instance and
|
|
118
172
|
* logs a warning instead of starting auto-instrumentation again.
|
|
@@ -147,6 +201,9 @@ export class FlowGrid {
|
|
|
147
201
|
}
|
|
148
202
|
const fg = new FlowGrid(config.webId, config.endpoint ?? DEFAULT_ENDPOINT, config.apiKey, config.visitorId, config.identityManager, config.transport);
|
|
149
203
|
FlowGrid._instance = fg;
|
|
204
|
+
// Pre-fetch the enterprise chunk immediately so getters are ready by the
|
|
205
|
+
// time user code first accesses them (typically well after init returns).
|
|
206
|
+
void loadEnterpriseModules();
|
|
150
207
|
// Identify the user before auto-instrumentation so the very first events
|
|
151
208
|
// (session_start, page_view) carry the userId.
|
|
152
209
|
if (config.user?.userId) {
|
|
@@ -154,8 +211,8 @@ export class FlowGrid {
|
|
|
154
211
|
}
|
|
155
212
|
const autoTrack = config.autoTrack;
|
|
156
213
|
const replay = config.replay;
|
|
157
|
-
const autoOpts = autoTrack === false ? { sessions: false, pageViews: false, performance: false, heatmaps: false, attribution: false, engagement: false }
|
|
158
|
-
: autoTrack === true || autoTrack === undefined ? {}
|
|
214
|
+
const autoOpts = autoTrack === false ? { sessions: false, pageViews: false, performance: false, heatmaps: false, attribution: false, engagement: false, replay: false }
|
|
215
|
+
: autoTrack === true || autoTrack === undefined ? { sessions: false, pageViews: false, performance: false, heatmaps: false, attribution: false }
|
|
159
216
|
: autoTrack;
|
|
160
217
|
if (replay !== undefined && autoOpts.replay === undefined) {
|
|
161
218
|
autoOpts.replay = replay;
|
|
@@ -170,6 +227,15 @@ export class FlowGrid {
|
|
|
170
227
|
static instance() {
|
|
171
228
|
return FlowGrid._instance;
|
|
172
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Await the enterprise feature chunk. Call this before accessing any
|
|
232
|
+
* enterprise namespace (`fg.engagement`, `fg.churn`, etc.) if you need
|
|
233
|
+
* guaranteed availability rather than relying on the background pre-fetch
|
|
234
|
+
* started by `init()`.
|
|
235
|
+
*/
|
|
236
|
+
static loadEnterprise() {
|
|
237
|
+
return loadEnterpriseModules();
|
|
238
|
+
}
|
|
173
239
|
/**
|
|
174
240
|
* Reset the singleton — primarily for tests / hot-reload. Tears down any
|
|
175
241
|
* active auto-instrumentation.
|
|
@@ -196,7 +262,7 @@ export class FlowGrid {
|
|
|
196
262
|
this.endpoint = endpoint;
|
|
197
263
|
this.apiKey = apiKey;
|
|
198
264
|
this.visitorId = visitorId;
|
|
199
|
-
this.identityManager = identityManager ?? new IdentityManager(visitorId ? { visitorId } : undefined);
|
|
265
|
+
this.identityManager = identityManager ?? new identity_1.IdentityManager(visitorId ? { visitorId } : undefined);
|
|
200
266
|
this.config = config;
|
|
201
267
|
}
|
|
202
268
|
raw(key, Klass) {
|
|
@@ -216,44 +282,57 @@ export class FlowGrid {
|
|
|
216
282
|
return instance;
|
|
217
283
|
}
|
|
218
284
|
// ---- Core ----
|
|
219
|
-
get activation() { return this.wrap("activation", Activation, ActivationTracker); }
|
|
220
|
-
get features() { return this.wrap("features", TrackFeature, FeatureTracker); }
|
|
221
|
-
get prompts() { return this.wrap("prompts", TrackPrompt, PromptTracker); }
|
|
222
|
-
get experiments() { return this.wrap("experiments", Experiment, ExperimentTracker); }
|
|
285
|
+
get activation() { return this.wrap("activation", core_1.Activation, core_2.ActivationTracker); }
|
|
286
|
+
get features() { return this.wrap("features", core_1.TrackFeature, core_2.FeatureTracker); }
|
|
287
|
+
get prompts() { return this.wrap("prompts", core_1.TrackPrompt, core_2.PromptTracker); }
|
|
288
|
+
get experiments() { return this.wrap("experiments", core_1.Experiment, core_2.ExperimentTracker); }
|
|
223
289
|
// ---- Analytics ----
|
|
224
|
-
get pageViews() { return this.wrap("pageViews", PageViews, PageViewTracker); }
|
|
225
|
-
get sessions() { return this.wrap("sessions", Sessions, SessionTracker); }
|
|
226
|
-
get events() { return this.wrap("events", Events, EventTracker); }
|
|
227
|
-
get identify() { return this.wrap("identify", Identify, IdentifyTracker); }
|
|
228
|
-
get funnels() { return this.wrap("funnels", Funnels, FunnelTracker); }
|
|
229
|
-
get retention() { return this.wrap("retention", Retention, RetentionTracker); }
|
|
230
|
-
get attribution() { return this.wrap("attribution", Attribution, AttributionTracker); }
|
|
231
|
-
get heatmaps() { return this.wrap("heatmaps", Heatmaps, HeatmapTracker); }
|
|
232
|
-
get performance() { return this.wrap("performance", PerformanceTracking, PerformanceTracker); }
|
|
233
|
-
get replay() { return this.wrap("replay", SessionReplay, ReplayTracker); }
|
|
290
|
+
get pageViews() { return this.wrap("pageViews", analytics_1.PageViews, analytics_2.PageViewTracker); }
|
|
291
|
+
get sessions() { return this.wrap("sessions", analytics_1.Sessions, analytics_2.SessionTracker); }
|
|
292
|
+
get events() { return this.wrap("events", analytics_1.Events, analytics_2.EventTracker); }
|
|
293
|
+
get identify() { return this.wrap("identify", analytics_1.Identify, analytics_2.IdentifyTracker); }
|
|
294
|
+
get funnels() { return this.wrap("funnels", analytics_1.Funnels, analytics_2.FunnelTracker); }
|
|
295
|
+
get retention() { return this.wrap("retention", analytics_1.Retention, analytics_2.RetentionTracker); }
|
|
296
|
+
get attribution() { return this.wrap("attribution", analytics_1.Attribution, analytics_2.AttributionTracker); }
|
|
297
|
+
get heatmaps() { return this.wrap("heatmaps", analytics_1.Heatmaps, analytics_2.HeatmapTracker); }
|
|
298
|
+
get performance() { return this.wrap("performance", analytics_1.PerformanceTracking, analytics_2.PerformanceTracker); }
|
|
299
|
+
get replay() { return this.wrap("replay", analytics_1.SessionReplay, analytics_2.ReplayTracker); }
|
|
234
300
|
// ---- Ecommerce ----
|
|
235
|
-
get products() { return this.wrap("products", Products, ProductTracker); }
|
|
236
|
-
get cart() { return this.wrap("cart", CartTracking, CartTracker); }
|
|
237
|
-
get checkout() { return this.wrap("checkout", Checkout, CheckoutTracker); }
|
|
238
|
-
get purchases() { return this.wrap("purchases", Purchases, PurchaseTracker); }
|
|
239
|
-
get refunds() { return this.wrap("refunds", Refunds, RefundTracker); }
|
|
240
|
-
get promotions() { return this.wrap("promotions", Promotions, PromotionTracker); }
|
|
241
|
-
get wishlist() { return this.wrap("wishlist", WishlistTracking, WishlistTracker); }
|
|
242
|
-
get ltv() { return this.wrap("ltv", CustomerLTV, LTVTracker); }
|
|
243
|
-
get search() { return this.wrap("search", SearchAnalytics, SearchTracker); }
|
|
244
|
-
get subscriptions() { return this.wrap("subscriptions", Subscriptions, SubscriptionTracker); }
|
|
301
|
+
get products() { return this.wrap("products", ecommerce_1.Products, ecommerce_2.ProductTracker); }
|
|
302
|
+
get cart() { return this.wrap("cart", ecommerce_1.CartTracking, ecommerce_2.CartTracker); }
|
|
303
|
+
get checkout() { return this.wrap("checkout", ecommerce_1.Checkout, ecommerce_2.CheckoutTracker); }
|
|
304
|
+
get purchases() { return this.wrap("purchases", ecommerce_1.Purchases, ecommerce_2.PurchaseTracker); }
|
|
305
|
+
get refunds() { return this.wrap("refunds", ecommerce_1.Refunds, ecommerce_2.RefundTracker); }
|
|
306
|
+
get promotions() { return this.wrap("promotions", ecommerce_1.Promotions, ecommerce_2.PromotionTracker); }
|
|
307
|
+
get wishlist() { return this.wrap("wishlist", ecommerce_1.WishlistTracking, ecommerce_2.WishlistTracker); }
|
|
308
|
+
get ltv() { return this.wrap("ltv", ecommerce_1.CustomerLTV, ecommerce_2.LTVTracker); }
|
|
309
|
+
get search() { return this.wrap("search", ecommerce_1.SearchAnalytics, ecommerce_2.SearchTracker); }
|
|
310
|
+
get subscriptions() { return this.wrap("subscriptions", ecommerce_1.Subscriptions, ecommerce_2.SubscriptionTracker); }
|
|
245
311
|
// ---- Enterprise ----
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
312
|
+
// These getters pull classes from the lazily-loaded enterprise chunk.
|
|
313
|
+
// The chunk is pre-fetched by init() so it's almost always ready by the
|
|
314
|
+
// time user code accesses these properties. loadEnterprise() is available
|
|
315
|
+
// for the rare case where callers need to await readiness explicitly.
|
|
316
|
+
_requireEnterprise() {
|
|
317
|
+
const ent = _enterpriseFeatures;
|
|
318
|
+
const entT = _enterpriseTracking;
|
|
319
|
+
if (!ent || !entT) {
|
|
320
|
+
throw new Error("[FlowGrid] Enterprise features are still loading. " +
|
|
321
|
+
"await FlowGrid.loadEnterprise() before accessing enterprise namespaces directly.");
|
|
322
|
+
}
|
|
323
|
+
return { ent, entT };
|
|
324
|
+
}
|
|
325
|
+
get engagement() { const { ent, entT } = this._requireEnterprise(); return this.wrap("engagement", ent.Engagement, entT.EngagementTracker); }
|
|
326
|
+
get cohorts() { const { ent, entT } = this._requireEnterprise(); return this.wrap("cohorts", ent.Cohorts, entT.CohortTracker); }
|
|
327
|
+
get churn() { const { ent, entT } = this._requireEnterprise(); return this.wrap("churn", ent.ChurnAnalytics, entT.ChurnTracker); }
|
|
328
|
+
get monetization() { const { ent, entT } = this._requireEnterprise(); return this.wrap("monetization", ent.Monetization, entT.MonetizationTracker); }
|
|
329
|
+
get multiPathFunnels() { const { ent, entT } = this._requireEnterprise(); return this.wrap("multiPathFunnels", ent.MultiPathFunnels, entT.MultiPathFunnelTracker); }
|
|
330
|
+
get support() { const { ent, entT } = this._requireEnterprise(); return this.wrap("support", ent.SupportAnalytics, entT.SupportTracker); }
|
|
331
|
+
get acquisition() { const { ent, entT } = this._requireEnterprise(); return this.wrap("acquisition", ent.AcquisitionAnalytics, entT.AcquisitionTracker); }
|
|
332
|
+
get paths() { const { ent, entT } = this._requireEnterprise(); return this.wrap("paths", ent.PathAnalytics, entT.PathTracker); }
|
|
333
|
+
get alerts() { const { ent, entT } = this._requireEnterprise(); return this.wrap("alerts", ent.AlertsAnalytics, entT.AlertTracker); }
|
|
334
|
+
get security() { const { ent, entT } = this._requireEnterprise(); return this.wrap("security", ent.SecurityAnalytics, entT.SecurityTracker); }
|
|
335
|
+
get forecasting() { const { ent, entT } = this._requireEnterprise(); return this.wrap("forecasting", ent.Forecasting, entT.ForecastingTracker); }
|
|
257
336
|
track(eventName, properties = {}, options = {}) {
|
|
258
337
|
const contextualProperties = this.withTrackContext(properties, options);
|
|
259
338
|
const routed = this.dispatchTrack(eventName, contextualProperties, Boolean(options.domain), options.domain);
|
|
@@ -662,6 +741,9 @@ export class FlowGrid {
|
|
|
662
741
|
}
|
|
663
742
|
}
|
|
664
743
|
dispatchEnterpriseTrack(eventName, properties, strict, domain) {
|
|
744
|
+
// Enterprise chunk not yet loaded — let the event fall through to events.track().
|
|
745
|
+
if (!_enterpriseFeatures || !_enterpriseTracking)
|
|
746
|
+
return UNHANDLED_TRACK;
|
|
665
747
|
switch (eventName) {
|
|
666
748
|
case "engagement.dwell_time":
|
|
667
749
|
case "engagement_dwell_time":
|
|
@@ -879,17 +961,17 @@ export class FlowGrid {
|
|
|
879
961
|
return this.pageViews.view(pathOrUrl, properties, options);
|
|
880
962
|
}
|
|
881
963
|
/**
|
|
882
|
-
* Enable browser-side auto-instrumentation in a single call.
|
|
964
|
+
* Enable browser-side auto-instrumentation in a single call.
|
|
883
965
|
*
|
|
884
|
-
*
|
|
885
|
-
* - **Page views** — initial view + SPA `pushState`/`popstate` + scroll-depth + time-on-page
|
|
886
|
-
* - **Performance** — Core Web Vitals via `web-vitals` + navigation timing
|
|
887
|
-
* - **Heatmaps** — click + scroll listeners
|
|
966
|
+
* On by default (opt-out with `false`):
|
|
888
967
|
* - **Engagement** — session depth, action count, and active/passive/idle transitions
|
|
889
|
-
* - **
|
|
968
|
+
* - **Replay** — DOM session recording via rrweb
|
|
890
969
|
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
970
|
+
* Off by default (these are handled by the flowgrid.js core script):
|
|
971
|
+
* - **Sessions**, **Page views**, **Performance**, **Heatmaps**, **Attribution**
|
|
972
|
+
*
|
|
973
|
+
* Pass `false` for any feature to disable it. Returns a single teardown
|
|
974
|
+
* function that detaches every listener; safe no-op on the server.
|
|
893
975
|
*
|
|
894
976
|
* @example
|
|
895
977
|
* ```ts
|
|
@@ -901,28 +983,43 @@ export class FlowGrid {
|
|
|
901
983
|
autoTrack(options = {}) {
|
|
902
984
|
const teardowns = [];
|
|
903
985
|
const ctx = { userId: options.userId };
|
|
904
|
-
if (options.sessions
|
|
986
|
+
if (options.sessions === true) {
|
|
905
987
|
teardowns.push(this.sessions.autoTrack(ctx.userId ? { user: { userId: ctx.userId } } : {}));
|
|
906
988
|
}
|
|
907
|
-
if (options.pageViews
|
|
989
|
+
if (options.pageViews === true) {
|
|
908
990
|
teardowns.push(this.pageViews.autoTrack(ctx));
|
|
909
991
|
}
|
|
910
|
-
if (options.performance !== false) {
|
|
992
|
+
if (options.performance === true || (options.performance !== false && typeof options.performance === "object")) {
|
|
911
993
|
const perfOpts = typeof options.performance === "object" ? options.performance : {};
|
|
912
994
|
teardowns.push(this.performance.autoTrack({ ...perfOpts, userId: ctx.userId }));
|
|
913
995
|
}
|
|
914
|
-
if (options.heatmaps !== false) {
|
|
996
|
+
if (options.heatmaps === true || (options.heatmaps !== false && typeof options.heatmaps === "object")) {
|
|
915
997
|
const hmOpts = typeof options.heatmaps === "object" ? options.heatmaps : {};
|
|
916
998
|
teardowns.push(this.heatmaps.autoTrack({ ...hmOpts, userId: ctx.userId }));
|
|
917
999
|
}
|
|
918
1000
|
if (options.engagement !== false) {
|
|
919
1001
|
const engOpts = typeof options.engagement === "object" ? options.engagement : {};
|
|
920
|
-
|
|
1002
|
+
// Engagement lives in the enterprise chunk — start async (mirrors replay pattern).
|
|
1003
|
+
let resolvedEngStop = null;
|
|
1004
|
+
let engStopRequested = false;
|
|
1005
|
+
void loadEnterpriseModules().then(() => {
|
|
1006
|
+
if (engStopRequested)
|
|
1007
|
+
return;
|
|
1008
|
+
resolvedEngStop = this.engagement.client.autoTrack({ ...engOpts, userId: ctx.userId });
|
|
1009
|
+
});
|
|
1010
|
+
teardowns.push(() => {
|
|
1011
|
+
engStopRequested = true;
|
|
1012
|
+
if (resolvedEngStop)
|
|
1013
|
+
try {
|
|
1014
|
+
resolvedEngStop();
|
|
1015
|
+
}
|
|
1016
|
+
catch { /* noop */ }
|
|
1017
|
+
});
|
|
921
1018
|
}
|
|
922
|
-
if (options.attribution
|
|
1019
|
+
if (options.attribution === true && ctx.userId) {
|
|
923
1020
|
this.attribution.captureFromUrl(ctx.userId);
|
|
924
1021
|
}
|
|
925
|
-
if (options.replay) {
|
|
1022
|
+
if (options.replay !== false) {
|
|
926
1023
|
const replayOpts = typeof options.replay === "object" ? options.replay : {};
|
|
927
1024
|
// start() is async; track its resolved teardown so the outer stop()
|
|
928
1025
|
// tears down recording even if the user calls it before rrweb resolved.
|
|
@@ -957,10 +1054,11 @@ export class FlowGrid {
|
|
|
957
1054
|
} };
|
|
958
1055
|
}
|
|
959
1056
|
}
|
|
1057
|
+
exports.FlowGrid = FlowGrid;
|
|
960
1058
|
/** Singleton created by {@link FlowGrid.init}. */
|
|
961
1059
|
FlowGrid._instance = null;
|
|
962
1060
|
// ---- Consent passthrough (static on transport) ----
|
|
963
|
-
FlowGrid.setConsent = FlowGridTransport.setConsent.bind(FlowGridTransport);
|
|
964
|
-
FlowGrid.hasConsent = FlowGridTransport.hasConsent.bind(FlowGridTransport);
|
|
965
|
-
|
|
1061
|
+
FlowGrid.setConsent = transport_1.FlowGridTransport.setConsent.bind(transport_1.FlowGridTransport);
|
|
1062
|
+
FlowGrid.hasConsent = transport_1.FlowGridTransport.hasConsent.bind(transport_1.FlowGridTransport);
|
|
1063
|
+
exports.default = FlowGrid;
|
|
966
1064
|
//# sourceMappingURL=flowgrid.js.map
|