@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.
@@ -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 if (lifecycle) client.capture(AUTO_EVENT.visible);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/insights",
3
- "version": "1.157.0",
3
+ "version": "1.157.1",
4
4
  "description": "User insights middlewares for Alpic-hosted MCP servers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",