@alpic-ai/insights 1.157.0 → 1.157.1
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/react/index.mjs +7 -2
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -239,14 +239,19 @@ function AlpicAnalytics({ children, beforeSend, autoCapture }) {
|
|
|
239
239
|
}, [client]);
|
|
240
240
|
useEffect(() => {
|
|
241
241
|
if (lifecycle) client.capture(AUTO_EVENT.loaded);
|
|
242
|
+
let closed = false;
|
|
242
243
|
const onVisibilityChange = () => {
|
|
243
244
|
if (document.visibilityState === "hidden") {
|
|
244
|
-
if (lifecycle) client.capture(AUTO_EVENT.hidden);
|
|
245
|
+
if (lifecycle && !closed) client.capture(AUTO_EVENT.hidden);
|
|
245
246
|
client.flush();
|
|
246
|
-
} else
|
|
247
|
+
} else {
|
|
248
|
+
closed = false;
|
|
249
|
+
if (lifecycle) client.capture(AUTO_EVENT.visible);
|
|
250
|
+
}
|
|
247
251
|
};
|
|
248
252
|
const onPageHide = () => {
|
|
249
253
|
if (lifecycle) client.capture(AUTO_EVENT.closed);
|
|
254
|
+
closed = true;
|
|
250
255
|
client.flush();
|
|
251
256
|
};
|
|
252
257
|
document.addEventListener("visibilitychange", onVisibilityChange);
|