@temps-sdk/react-analytics 0.0.1-beta.9 → 0.0.3
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 +534 -0
- package/dist/EngagementTracker.d.ts +55 -0
- package/dist/EngagementTracker.d.ts.map +1 -0
- package/dist/EngagementTracker.js +223 -0
- package/dist/Provider.d.ts +1 -1
- package/dist/Provider.d.ts.map +1 -1
- package/dist/Provider.js +65 -37
- package/dist/SessionRecorder.d.ts +57 -0
- package/dist/SessionRecorder.d.ts.map +1 -0
- package/dist/SessionRecorder.js +536 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/types.d.ts +52 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useEngagementTracking.d.ts +34 -0
- package/dist/useEngagementTracking.d.ts.map +1 -0
- package/dist/useEngagementTracking.js +65 -0
- package/dist/usePageLeave.d.ts.map +1 -1
- package/dist/usePageLeave.js +2 -1
- package/dist/useScrollVisibility.d.ts +58 -0
- package/dist/useScrollVisibility.d.ts.map +1 -0
- package/dist/useScrollVisibility.js +65 -0
- package/dist/useSessionRecording.d.ts +23 -0
- package/dist/useSessionRecording.d.ts.map +1 -0
- package/dist/useSessionRecording.js +99 -0
- package/dist/useSpeedAnalytics.d.ts +8 -0
- package/dist/useSpeedAnalytics.d.ts.map +1 -0
- package/dist/useSpeedAnalytics.js +60 -0
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/package.json +27 -5
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { sendAnalytics, sendAnalyticsReliable } from "./utils";
|
|
3
|
+
export class EngagementTracker {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.engagementTime = 0;
|
|
6
|
+
this.lastEngagementStart = null;
|
|
7
|
+
this.heartbeatCount = 0;
|
|
8
|
+
this.isActive = true;
|
|
9
|
+
this.heartbeatTimer = null;
|
|
10
|
+
this.inactivityTimer = null;
|
|
11
|
+
this.hasTrackedLeave = false;
|
|
12
|
+
this.handleVisibilityChange = () => {
|
|
13
|
+
const wasVisible = this.isVisible;
|
|
14
|
+
this.isVisible = document.visibilityState === "visible";
|
|
15
|
+
if (!wasVisible && this.isVisible) {
|
|
16
|
+
// Tab became visible - but don't start engagement until user interacts
|
|
17
|
+
this.startHeartbeat();
|
|
18
|
+
}
|
|
19
|
+
else if (wasVisible && !this.isVisible) {
|
|
20
|
+
// Tab became hidden - pause engagement
|
|
21
|
+
this.pauseEngagement();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.handleFocus = () => {
|
|
25
|
+
this.isFocused = true;
|
|
26
|
+
};
|
|
27
|
+
this.handleBlur = () => {
|
|
28
|
+
this.isFocused = false;
|
|
29
|
+
// When window loses focus, pause engagement tracking
|
|
30
|
+
this.pauseEngagement();
|
|
31
|
+
};
|
|
32
|
+
this.handleUserActivity = () => {
|
|
33
|
+
// Only track activity if tab is visible AND focused
|
|
34
|
+
if (!this.isVisible || !this.isFocused)
|
|
35
|
+
return;
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
if (!this.isActive) {
|
|
38
|
+
// Resume from inactive state
|
|
39
|
+
this.isActive = true;
|
|
40
|
+
this.lastEngagementStart = now;
|
|
41
|
+
this.startHeartbeat();
|
|
42
|
+
}
|
|
43
|
+
this.lastActivityTime = now;
|
|
44
|
+
this.resetInactivityTimer();
|
|
45
|
+
};
|
|
46
|
+
this.handlePageLeave = () => {
|
|
47
|
+
if (this.hasTrackedLeave)
|
|
48
|
+
return;
|
|
49
|
+
this.hasTrackedLeave = true;
|
|
50
|
+
this.updateEngagementTime();
|
|
51
|
+
const data = this.getEngagementData();
|
|
52
|
+
if (this.onPageLeave) {
|
|
53
|
+
this.onPageLeave(data);
|
|
54
|
+
}
|
|
55
|
+
sendAnalyticsReliable("event", {
|
|
56
|
+
event_name: "page_leave",
|
|
57
|
+
request_path: window.location.pathname,
|
|
58
|
+
request_query: window.location.search,
|
|
59
|
+
domain: this.domain,
|
|
60
|
+
event_data: {
|
|
61
|
+
engagement_time_seconds: data.engagement_time_seconds,
|
|
62
|
+
total_time_seconds: data.total_time_seconds,
|
|
63
|
+
heartbeat_count: this.heartbeatCount,
|
|
64
|
+
was_engaged: data.is_engaged,
|
|
65
|
+
url: window.location.href,
|
|
66
|
+
referrer: document.referrer,
|
|
67
|
+
},
|
|
68
|
+
}, this.basePath);
|
|
69
|
+
};
|
|
70
|
+
this.handleNavigation = () => {
|
|
71
|
+
this.handlePageLeave();
|
|
72
|
+
this.reset();
|
|
73
|
+
};
|
|
74
|
+
this.basePath = options.basePath || "/api/_temps";
|
|
75
|
+
this.domain = options.domain || window.location.hostname;
|
|
76
|
+
this.heartbeatInterval = options.heartbeatInterval || 30000; // 30 seconds
|
|
77
|
+
this.inactivityTimeout = options.inactivityTimeout || 30000; // 30 seconds
|
|
78
|
+
this.engagementThreshold = options.engagementThreshold || 10000; // 10 seconds
|
|
79
|
+
this.onHeartbeat = options.onHeartbeat;
|
|
80
|
+
this.onPageLeave = options.onPageLeave;
|
|
81
|
+
this.startTime = Date.now();
|
|
82
|
+
this.lastActivityTime = Date.now();
|
|
83
|
+
this.isVisible = document.visibilityState === "visible";
|
|
84
|
+
this.isFocused = document.hasFocus();
|
|
85
|
+
// Don't start engagement tracking until first user interaction
|
|
86
|
+
this.lastEngagementStart = null;
|
|
87
|
+
this.isActive = false;
|
|
88
|
+
this.setupEventListeners();
|
|
89
|
+
this.startHeartbeat();
|
|
90
|
+
}
|
|
91
|
+
setupEventListeners() {
|
|
92
|
+
// Visibility change
|
|
93
|
+
document.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
94
|
+
// Focus/blur for better multi-monitor support
|
|
95
|
+
window.addEventListener("focus", this.handleFocus);
|
|
96
|
+
window.addEventListener("blur", this.handleBlur);
|
|
97
|
+
// User activity tracking - use more specific events to avoid false positives
|
|
98
|
+
const activityEvents = ["mousedown", "keypress", "scroll", "touchstart", "click"];
|
|
99
|
+
activityEvents.forEach(event => {
|
|
100
|
+
document.addEventListener(event, this.handleUserActivity, { passive: true });
|
|
101
|
+
});
|
|
102
|
+
// Page leave events
|
|
103
|
+
window.addEventListener("pagehide", this.handlePageLeave);
|
|
104
|
+
window.addEventListener("beforeunload", this.handlePageLeave);
|
|
105
|
+
// SPA navigation
|
|
106
|
+
const originalPushState = window.history.pushState;
|
|
107
|
+
window.history.pushState = (...args) => {
|
|
108
|
+
this.handlePageLeave();
|
|
109
|
+
originalPushState.apply(window.history, args);
|
|
110
|
+
this.reset();
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("popstate", this.handleNavigation);
|
|
113
|
+
}
|
|
114
|
+
pauseEngagement() {
|
|
115
|
+
this.updateEngagementTime();
|
|
116
|
+
this.lastEngagementStart = null;
|
|
117
|
+
if (!this.isVisible) {
|
|
118
|
+
this.stopHeartbeat();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
resetInactivityTimer() {
|
|
122
|
+
if (this.inactivityTimer) {
|
|
123
|
+
clearTimeout(this.inactivityTimer);
|
|
124
|
+
}
|
|
125
|
+
this.inactivityTimer = setTimeout(() => {
|
|
126
|
+
if (this.isVisible) {
|
|
127
|
+
this.updateEngagementTime();
|
|
128
|
+
this.isActive = false;
|
|
129
|
+
this.lastEngagementStart = null;
|
|
130
|
+
}
|
|
131
|
+
}, this.inactivityTimeout);
|
|
132
|
+
}
|
|
133
|
+
updateEngagementTime() {
|
|
134
|
+
if (this.lastEngagementStart !== null) {
|
|
135
|
+
const currentEngagement = Date.now() - this.lastEngagementStart;
|
|
136
|
+
this.engagementTime += currentEngagement;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
startHeartbeat() {
|
|
140
|
+
if (this.heartbeatTimer)
|
|
141
|
+
return;
|
|
142
|
+
this.heartbeatTimer = setInterval(() => {
|
|
143
|
+
// Only send heartbeat if tab is visible AND user has been active
|
|
144
|
+
if (this.isVisible && this.isActive) {
|
|
145
|
+
this.sendHeartbeat();
|
|
146
|
+
}
|
|
147
|
+
}, this.heartbeatInterval);
|
|
148
|
+
}
|
|
149
|
+
stopHeartbeat() {
|
|
150
|
+
if (this.heartbeatTimer) {
|
|
151
|
+
clearInterval(this.heartbeatTimer);
|
|
152
|
+
this.heartbeatTimer = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async sendHeartbeat() {
|
|
156
|
+
this.updateEngagementTime();
|
|
157
|
+
this.heartbeatCount++;
|
|
158
|
+
const data = this.getEngagementData();
|
|
159
|
+
if (this.onHeartbeat) {
|
|
160
|
+
this.onHeartbeat(data);
|
|
161
|
+
}
|
|
162
|
+
await sendAnalytics("event", {
|
|
163
|
+
event_name: "heartbeat",
|
|
164
|
+
request_path: window.location.pathname,
|
|
165
|
+
request_query: window.location.search,
|
|
166
|
+
domain: this.domain,
|
|
167
|
+
event_data: {
|
|
168
|
+
engagement_time: Math.round(this.engagementTime),
|
|
169
|
+
total_time: Math.round(Date.now() - this.startTime),
|
|
170
|
+
is_engaged: data.is_engaged,
|
|
171
|
+
is_visible: this.isVisible,
|
|
172
|
+
time_since_last_activity: data.time_since_last_activity,
|
|
173
|
+
heartbeat_count: this.heartbeatCount,
|
|
174
|
+
},
|
|
175
|
+
}, "POST", this.basePath);
|
|
176
|
+
// Reset engagement start for next period
|
|
177
|
+
if (this.isActive && this.isVisible) {
|
|
178
|
+
this.lastEngagementStart = Date.now();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
getEngagementData() {
|
|
182
|
+
const totalTime = Date.now() - this.startTime;
|
|
183
|
+
const timeSinceLastActivity = Date.now() - this.lastActivityTime;
|
|
184
|
+
return {
|
|
185
|
+
engagement_time_seconds: Math.round(this.engagementTime / 1000),
|
|
186
|
+
total_time_seconds: Math.round(totalTime / 1000),
|
|
187
|
+
heartbeat_count: this.heartbeatCount,
|
|
188
|
+
is_engaged: this.engagementTime >= this.engagementThreshold,
|
|
189
|
+
is_visible: this.isVisible,
|
|
190
|
+
time_since_last_activity: Math.round(timeSinceLastActivity / 1000),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
reset() {
|
|
194
|
+
this.startTime = Date.now();
|
|
195
|
+
this.engagementTime = 0;
|
|
196
|
+
this.lastActivityTime = Date.now();
|
|
197
|
+
this.heartbeatCount = 0;
|
|
198
|
+
this.hasTrackedLeave = false;
|
|
199
|
+
// Reset to inactive state - wait for user interaction
|
|
200
|
+
this.isActive = false;
|
|
201
|
+
this.lastEngagementStart = null;
|
|
202
|
+
if (this.isVisible) {
|
|
203
|
+
this.startHeartbeat();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
destroy() {
|
|
207
|
+
this.handlePageLeave();
|
|
208
|
+
this.stopHeartbeat();
|
|
209
|
+
if (this.inactivityTimer) {
|
|
210
|
+
clearTimeout(this.inactivityTimer);
|
|
211
|
+
}
|
|
212
|
+
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
213
|
+
window.removeEventListener("focus", this.handleFocus);
|
|
214
|
+
window.removeEventListener("blur", this.handleBlur);
|
|
215
|
+
window.removeEventListener("pagehide", this.handlePageLeave);
|
|
216
|
+
window.removeEventListener("beforeunload", this.handlePageLeave);
|
|
217
|
+
window.removeEventListener("popstate", this.handleNavigation);
|
|
218
|
+
const activityEvents = ["mousedown", "keypress", "scroll", "touchstart", "click"];
|
|
219
|
+
activityEvents.forEach(event => {
|
|
220
|
+
document.removeEventListener(event, this.handleUserActivity);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
package/dist/Provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AnalyticsContextValue, TempsAnalyticsProviderProps } from "./types";
|
|
2
|
-
export declare function TempsAnalyticsProvider({ basePath, disabled, ignoreLocalhost, autoTrackPageviews, autoTrackPageLeave, pageLeaveEventName, domain, children, }: TempsAnalyticsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function TempsAnalyticsProvider({ basePath, disabled, ignoreLocalhost, autoTrackPageviews, autoTrackPageLeave, pageLeaveEventName, autoTrackSpeedAnalytics, autoTrackEngagement, heartbeatInterval, inactivityTimeout, engagementThreshold, enableSessionRecording, sessionRecordingConfig, domain, children, }: TempsAnalyticsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare function useTempsAnalytics(): AnalyticsContextValue;
|
|
4
4
|
//# sourceMappingURL=Provider.d.ts.map
|
package/dist/Provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAUlF,wBAAgB,sBAAsB,CAAC,EACrC,QAA4B,EAC5B,QAAgB,EAChB,eAAsB,EACtB,kBAAyB,EACzB,kBAAyB,EACzB,kBAAiC,EACjC,uBAA8B,EAC9B,mBAA0B,EAC1B,iBAAyB,EACzB,iBAAyB,EACzB,mBAA2B,EAC3B,sBAA8B,EAC9B,sBAA2B,EAC3B,MAAM,EACN,QAAQ,GACT,EAAE,2BAA2B,2CAmO7B;AAED,wBAAgB,iBAAiB,IAAI,qBAAqB,CAMzD"}
|
package/dist/Provider.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { isLocalhostLike, isTestEnvironment, sendAnalytics, sendAnalyticsReliable } from "./utils";
|
|
5
|
+
import { useSpeedAnalytics } from "./useSpeedAnalytics";
|
|
6
|
+
import { EngagementTracker } from "./EngagementTracker";
|
|
7
|
+
import { SessionRecorder } from "./SessionRecorder";
|
|
8
|
+
import { SessionRecordingProvider, useSessionRecordingControl } from "./useSessionRecording";
|
|
9
|
+
import { DEFAULT_BASE_PATH } from "./constants";
|
|
5
10
|
const AnalyticsContext = createContext(undefined);
|
|
6
|
-
export function TempsAnalyticsProvider({ basePath =
|
|
11
|
+
export function TempsAnalyticsProvider({ basePath = DEFAULT_BASE_PATH, disabled = false, ignoreLocalhost = true, autoTrackPageviews = true, autoTrackPageLeave = true, pageLeaveEventName = "page_leave", autoTrackSpeedAnalytics = true, autoTrackEngagement = true, heartbeatInterval = 30000, inactivityTimeout = 30000, engagementThreshold = 10000, enableSessionRecording = false, sessionRecordingConfig = {}, domain, children, }) {
|
|
7
12
|
const enabled = useMemo(() => {
|
|
8
13
|
if (disabled)
|
|
9
14
|
return false;
|
|
@@ -33,7 +38,7 @@ export function TempsAnalyticsProvider({ basePath = "/api/_temps", disabled = fa
|
|
|
33
38
|
if (!enabled)
|
|
34
39
|
return;
|
|
35
40
|
void sendAnalytics("event", {
|
|
36
|
-
event_name: "
|
|
41
|
+
event_name: "page_view",
|
|
37
42
|
request_query: window.location.search,
|
|
38
43
|
request_path: window.location.pathname,
|
|
39
44
|
domain: domain || window.location.hostname,
|
|
@@ -122,43 +127,66 @@ export function TempsAnalyticsProvider({ basePath = "/api/_temps", disabled = fa
|
|
|
122
127
|
document.addEventListener("click", onClick);
|
|
123
128
|
return () => document.removeEventListener("click", onClick);
|
|
124
129
|
}, [enabled, trackEvent]);
|
|
125
|
-
//
|
|
130
|
+
// Engagement tracking with heartbeats and page leave
|
|
126
131
|
useEffect(() => {
|
|
127
|
-
if (!
|
|
132
|
+
if (!enabled)
|
|
128
133
|
return;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
134
|
+
// If engagement tracking is enabled, it handles both heartbeats and page leave
|
|
135
|
+
if (autoTrackEngagement) {
|
|
136
|
+
const tracker = new EngagementTracker({
|
|
137
|
+
basePath,
|
|
138
|
+
domain,
|
|
139
|
+
heartbeatInterval,
|
|
140
|
+
inactivityTimeout,
|
|
141
|
+
engagementThreshold,
|
|
142
|
+
});
|
|
143
|
+
return () => {
|
|
144
|
+
tracker.destroy();
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Legacy page leave tracking without engagement metrics
|
|
148
|
+
else if (autoTrackPageLeave) {
|
|
149
|
+
let hasTracked = false;
|
|
150
|
+
let startTime = Date.now();
|
|
151
|
+
const trackPageLeave = () => {
|
|
152
|
+
if (hasTracked)
|
|
153
|
+
return;
|
|
154
|
+
hasTracked = true;
|
|
155
|
+
const timeOnPage = Date.now() - startTime;
|
|
156
|
+
sendAnalyticsReliable("event", {
|
|
157
|
+
event_name: pageLeaveEventName,
|
|
158
|
+
request_query: window.location.search,
|
|
159
|
+
request_path: window.location.pathname,
|
|
160
|
+
domain: domain || window.location.hostname,
|
|
161
|
+
event_data: {
|
|
162
|
+
time_on_page_ms: timeOnPage,
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
164
|
+
url: window.location.href,
|
|
165
|
+
referrer: document.referrer,
|
|
166
|
+
},
|
|
167
|
+
}, basePath);
|
|
168
|
+
};
|
|
169
|
+
// Use pagehide as primary (most reliable), with beforeunload as fallback
|
|
170
|
+
const handlePageLeave = () => trackPageLeave();
|
|
171
|
+
// pagehide is the most reliable for modern browsers
|
|
172
|
+
window.addEventListener("pagehide", handlePageLeave);
|
|
173
|
+
// beforeunload as fallback for older browsers
|
|
174
|
+
window.addEventListener("beforeunload", handlePageLeave);
|
|
175
|
+
return () => {
|
|
176
|
+
window.removeEventListener("pagehide", handlePageLeave);
|
|
177
|
+
window.removeEventListener("beforeunload", handlePageLeave);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}, [autoTrackPageLeave, autoTrackEngagement, enabled, pageLeaveEventName, domain, basePath, heartbeatInterval, inactivityTimeout, engagementThreshold]);
|
|
181
|
+
// Speed analytics tracking
|
|
182
|
+
useSpeedAnalytics({
|
|
183
|
+
basePath,
|
|
184
|
+
disabled: !enabled || !autoTrackSpeedAnalytics,
|
|
185
|
+
});
|
|
186
|
+
// Session recording control
|
|
187
|
+
const { isEnabled: isRecordingEnabled } = useSessionRecordingControl(enableSessionRecording);
|
|
160
188
|
const value = useMemo(() => ({ trackEvent, identify, trackPageview, enabled }), [trackEvent, identify, trackPageview, enabled]);
|
|
161
|
-
return _jsx(AnalyticsContext.Provider, { value: value, children: children });
|
|
189
|
+
return (_jsx(AnalyticsContext.Provider, { value: value, children: _jsxs(SessionRecordingProvider, { defaultEnabled: enableSessionRecording, children: [children, enabled && (_jsx(SessionRecorder, { basePath: basePath, domain: domain, enabled: isRecordingEnabled, excludedPaths: sessionRecordingConfig.excludedPaths, sessionSampleRate: sessionRecordingConfig.sessionSampleRate, maskAllInputs: sessionRecordingConfig.maskAllInputs, maskTextSelector: sessionRecordingConfig.maskTextSelector, blockClass: sessionRecordingConfig.blockClass, ignoreClass: sessionRecordingConfig.ignoreClass, maskTextClass: sessionRecordingConfig.maskTextClass, recordCanvas: sessionRecordingConfig.recordCanvas, collectFonts: sessionRecordingConfig.collectFonts, batchSize: sessionRecordingConfig.batchSize, flushInterval: sessionRecordingConfig.flushInterval }))] }) }));
|
|
162
190
|
}
|
|
163
191
|
export function useTempsAnalytics() {
|
|
164
192
|
const ctx = useContext(AnalyticsContext);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const SESSION_RECORDER_ENDPOINT = "session-replay";
|
|
2
|
+
interface SessionRecorderProps {
|
|
3
|
+
basePath: string;
|
|
4
|
+
domain?: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
excludedPaths?: string[];
|
|
7
|
+
sessionSampleRate?: number;
|
|
8
|
+
maskAllInputs?: boolean;
|
|
9
|
+
maskTextSelector?: string;
|
|
10
|
+
blockClass?: string;
|
|
11
|
+
ignoreClass?: string;
|
|
12
|
+
maskTextClass?: string;
|
|
13
|
+
recordCanvas?: boolean;
|
|
14
|
+
collectFonts?: boolean;
|
|
15
|
+
slimDOMOptions?: Record<string, boolean>;
|
|
16
|
+
maskInputOptions?: {
|
|
17
|
+
password?: boolean;
|
|
18
|
+
email?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Number of events to batch before sending. Default: 500
|
|
22
|
+
* Events are sent when EITHER batchSize is reached OR flushInterval elapses (whichever comes first).
|
|
23
|
+
* Increased from 200 to reduce request frequency.
|
|
24
|
+
*/
|
|
25
|
+
batchSize?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Interval in milliseconds to flush events. Default: 60000 (60s)
|
|
28
|
+
* Events are sent when EITHER flushInterval elapses OR batchSize is reached (whichever comes first).
|
|
29
|
+
* Increased from 30s to reduce request frequency.
|
|
30
|
+
*/
|
|
31
|
+
flushInterval?: number;
|
|
32
|
+
ignoreSelector?: string;
|
|
33
|
+
blockSelector?: string;
|
|
34
|
+
sampling?: {
|
|
35
|
+
scroll?: number;
|
|
36
|
+
media?: number;
|
|
37
|
+
mouseInteraction?: boolean | {
|
|
38
|
+
click?: boolean;
|
|
39
|
+
dblclick?: boolean;
|
|
40
|
+
contextmenu?: boolean;
|
|
41
|
+
focus?: boolean;
|
|
42
|
+
blur?: boolean;
|
|
43
|
+
touchstart?: boolean;
|
|
44
|
+
touchend?: boolean;
|
|
45
|
+
touchcancel?: boolean;
|
|
46
|
+
play?: boolean;
|
|
47
|
+
pause?: boolean;
|
|
48
|
+
};
|
|
49
|
+
mousemove?: boolean | number;
|
|
50
|
+
input?: "all" | "last";
|
|
51
|
+
canvas?: number | "all";
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare function SessionRecorder({ basePath, // Required, no default
|
|
55
|
+
domain, enabled, excludedPaths, sessionSampleRate, maskAllInputs, maskTextSelector, blockClass, ignoreClass, maskTextClass, ignoreSelector, blockSelector, recordCanvas, collectFonts, slimDOMOptions, maskInputOptions, batchSize, flushInterval, sampling, }: SessionRecorderProps): null;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=SessionRecorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionRecorder.d.ts","sourceRoot":"","sources":["../src/SessionRecorder.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB,CAAC,EAAE,OAAO,GAAG;YAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,WAAW,CAAC,EAAE,OAAO,CAAC;YACtB,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,UAAU,CAAC,EAAE,OAAO,CAAC;YACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,WAAW,CAAC,EAAE,OAAO,CAAC;YACtB,IAAI,CAAC,EAAE,OAAO,CAAC;YACf,KAAK,CAAC,EAAE,OAAO,CAAC;SACjB,CAAC;QACF,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QAC7B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KACzB,CAAC;CACH;AA2CD,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EAAG,uBAAuB;AAClC,MAAM,EACN,OAAe,EACf,aAAkB,EAClB,iBAAuB,EACvB,aAAoB,EACpB,gBAAgC,EAChC,UAAuB,EACvB,WAAyB,EACzB,aAAyB,EACzB,cAAgC,EAChC,aAAgC,EAChC,YAAoB,EACpB,YAAmB,EACnB,cAWC,EACD,gBAGC,EACD,SAAe,EACf,aAAqB,EACrB,QAAa,GACd,EAAE,oBAAoB,GAAG,IAAI,CAshB7B"}
|