@neroom/nevision 0.1.8 → 0.1.9
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/index.js +30 -0
- package/dist/index.mjs +30 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -196,6 +196,36 @@ function NevisionRecorder({
|
|
|
196
196
|
if (stopFn) {
|
|
197
197
|
stopFnRef.current = stopFn;
|
|
198
198
|
}
|
|
199
|
+
const emitPageLifecycleEvent = (eventName) => {
|
|
200
|
+
const customEvent = {
|
|
201
|
+
type: 5,
|
|
202
|
+
// Custom event type in rrweb
|
|
203
|
+
data: {
|
|
204
|
+
tag: "page_lifecycle",
|
|
205
|
+
payload: {
|
|
206
|
+
event: eventName
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
timestamp: Date.now()
|
|
210
|
+
};
|
|
211
|
+
eventsBufferRef.current.push(customEvent);
|
|
212
|
+
};
|
|
213
|
+
const handleVisibilityChangeForTimeline = () => {
|
|
214
|
+
if (document.visibilityState === "hidden") {
|
|
215
|
+
emitPageLifecycleEvent("page_hidden");
|
|
216
|
+
} else {
|
|
217
|
+
emitPageLifecycleEvent("page_visible");
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const handleWindowFocusForTimeline = () => {
|
|
221
|
+
emitPageLifecycleEvent("page_focus");
|
|
222
|
+
};
|
|
223
|
+
const handleWindowBlurForTimeline = () => {
|
|
224
|
+
emitPageLifecycleEvent("page_blur");
|
|
225
|
+
};
|
|
226
|
+
document.addEventListener("visibilitychange", handleVisibilityChangeForTimeline);
|
|
227
|
+
window.addEventListener("focus", handleWindowFocusForTimeline);
|
|
228
|
+
window.addEventListener("blur", handleWindowBlurForTimeline);
|
|
199
229
|
intervalId = setInterval(() => {
|
|
200
230
|
sendChunk(apiUrl, sessionId);
|
|
201
231
|
}, CHUNK_INTERVAL);
|
package/dist/index.mjs
CHANGED
|
@@ -162,6 +162,36 @@ function NevisionRecorder({
|
|
|
162
162
|
if (stopFn) {
|
|
163
163
|
stopFnRef.current = stopFn;
|
|
164
164
|
}
|
|
165
|
+
const emitPageLifecycleEvent = (eventName) => {
|
|
166
|
+
const customEvent = {
|
|
167
|
+
type: 5,
|
|
168
|
+
// Custom event type in rrweb
|
|
169
|
+
data: {
|
|
170
|
+
tag: "page_lifecycle",
|
|
171
|
+
payload: {
|
|
172
|
+
event: eventName
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
timestamp: Date.now()
|
|
176
|
+
};
|
|
177
|
+
eventsBufferRef.current.push(customEvent);
|
|
178
|
+
};
|
|
179
|
+
const handleVisibilityChangeForTimeline = () => {
|
|
180
|
+
if (document.visibilityState === "hidden") {
|
|
181
|
+
emitPageLifecycleEvent("page_hidden");
|
|
182
|
+
} else {
|
|
183
|
+
emitPageLifecycleEvent("page_visible");
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const handleWindowFocusForTimeline = () => {
|
|
187
|
+
emitPageLifecycleEvent("page_focus");
|
|
188
|
+
};
|
|
189
|
+
const handleWindowBlurForTimeline = () => {
|
|
190
|
+
emitPageLifecycleEvent("page_blur");
|
|
191
|
+
};
|
|
192
|
+
document.addEventListener("visibilitychange", handleVisibilityChangeForTimeline);
|
|
193
|
+
window.addEventListener("focus", handleWindowFocusForTimeline);
|
|
194
|
+
window.addEventListener("blur", handleWindowBlurForTimeline);
|
|
165
195
|
intervalId = setInterval(() => {
|
|
166
196
|
sendChunk(apiUrl, sessionId);
|
|
167
197
|
}, CHUNK_INTERVAL);
|