@magicfeedback/popup-sdk 1.20.0 → 1.21.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.
Files changed (31) hide show
  1. package/dist/{chunk-FROREHRG.mjs → chunk-BWYWXAIQ.mjs} +2 -2
  2. package/dist/{chunk-ZJ5HG3QF.mjs → chunk-H434NTBB.mjs} +2 -2
  3. package/dist/{chunk-OPR5I7WO.mjs → chunk-UBUY6G6Z.mjs} +2 -2
  4. package/dist/index.d.mts +38 -8
  5. package/dist/index.d.ts +38 -8
  6. package/dist/index.js +66 -23
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +68 -25
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.native.d.mts +38 -8
  11. package/dist/index.native.d.ts +38 -8
  12. package/dist/index.native.js +66 -23
  13. package/dist/index.native.js.map +1 -1
  14. package/dist/index.native.mjs +68 -25
  15. package/dist/index.native.mjs.map +1 -1
  16. package/dist/react-native.d.mts +32 -8
  17. package/dist/react-native.d.ts +32 -8
  18. package/dist/react-native.js +66 -23
  19. package/dist/react-native.js.map +1 -1
  20. package/dist/react-native.mjs +68 -25
  21. package/dist/react-native.mjs.map +1 -1
  22. package/dist/{renderPopup-RUY3OBYV.mjs → renderPopup-HNSFPFVT.mjs} +2 -2
  23. package/dist/{renderPopup-I6CPIR75.mjs → renderPopup-VXKWSZ4E.mjs} +2 -2
  24. package/dist/{renderPopup-XNVNP2ZU.mjs → renderPopup-WNF67H5T.mjs} +2 -2
  25. package/package.json +1 -1
  26. /package/dist/{chunk-FROREHRG.mjs.map → chunk-BWYWXAIQ.mjs.map} +0 -0
  27. /package/dist/{chunk-ZJ5HG3QF.mjs.map → chunk-H434NTBB.mjs.map} +0 -0
  28. /package/dist/{chunk-OPR5I7WO.mjs.map → chunk-UBUY6G6Z.mjs.map} +0 -0
  29. /package/dist/{renderPopup-RUY3OBYV.mjs.map → renderPopup-HNSFPFVT.mjs.map} +0 -0
  30. /package/dist/{renderPopup-I6CPIR75.mjs.map → renderPopup-VXKWSZ4E.mjs.map} +0 -0
  31. /package/dist/{renderPopup-XNVNP2ZU.mjs.map → renderPopup-WNF67H5T.mjs.map} +0 -0
@@ -146,6 +146,12 @@ interface AnalyticsFlushMeta {
146
146
  * registro nuevo, igual que tras `sessionEnd`, pero sin POST.
147
147
  */
148
148
  resetSession?: boolean;
149
+ /**
150
+ * `true` cuando el lote puede ser lo último que salga de la sesión sin cerrarla (app a
151
+ * background en RN: la sesión queda suspendida). El sink lo guarda ANTES de enviarlo, como
152
+ * el lote de cierre, para reenviarlo en el arranque siguiente si el SO mata la app.
153
+ */
154
+ persist?: boolean;
149
155
  }
150
156
  /**
151
157
  * Envío del lote. Si devuelve una promesa que **rechaza**, el manager re-encola los
@@ -1056,14 +1062,21 @@ declare class DeepdotsPopups {
1056
1062
  * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
1057
1063
  */
1058
1064
  setScreen(name: string): void;
1059
- /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
1065
+ /**
1066
+ * App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
1067
+ * background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
1068
+ * (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
1069
+ */
1060
1070
  onForeground(): void;
1061
1071
  /**
1062
- * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
1063
- * (page_view), mini-services (mini_service_exit), emite engagement + `session_end` y
1064
- * envía el último lote con `completed:true`.
1065
- *
1066
- * Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
1072
+ * App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
1073
+ * actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
1074
+ * `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
1075
+ * - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
1076
+ * en el mismo registro;
1077
+ * - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
1078
+ * minutos con un `session_end` `background` a la hora de la suspensión.
1079
+ * Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
1067
1080
  */
1068
1081
  onBackground(): void;
1069
1082
  /**
@@ -1135,6 +1148,7 @@ declare class DeepdotsPopups {
1135
1148
  flushAnalytics(options?: {
1136
1149
  final?: boolean;
1137
1150
  sessionEnd?: boolean;
1151
+ persist?: boolean;
1138
1152
  }): void;
1139
1153
  /**
1140
1154
  * Emite un evento `user_engagement` con el tiempo activo acumulado (#8) y la pantalla en
@@ -1170,8 +1184,12 @@ declare class DeepdotsPopups {
1170
1184
  * - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
1171
1185
  * - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
1172
1186
  *
1187
+ * En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
1188
+ * background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
1189
+ *
1173
1190
  * Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
1174
- * POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra como antes.
1191
+ * POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
1192
+ * como antes.
1175
1193
  */
1176
1194
  private suspendSession;
1177
1195
  /**
@@ -1182,11 +1200,23 @@ declare class DeepdotsPopups {
1182
1200
  private readResumableSession;
1183
1201
  /**
1184
1202
  * Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
1185
- * ella (mismo usuario, dentro de ANALYTICS_RESUME_WINDOW_MS); null si no había o ya no toca.
1203
+ * ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
1204
+ * ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
1186
1205
  * En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
1187
1206
  * se abre ahora va a uno nuevo.
1188
1207
  */
1189
1208
  private takeSuspendedSession;
1209
+ /**
1210
+ * `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
1211
+ * misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
1212
+ * (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
1213
+ * el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
1214
+ * #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
1215
+ * - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
1216
+ * - Más: el backend ya la cerró → se descarta sin enviar nada.
1217
+ * Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
1218
+ */
1219
+ private closeStaleHiddenSession;
1190
1220
  /** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
1191
1221
  private discardSession;
1192
1222
  /**
@@ -146,6 +146,12 @@ interface AnalyticsFlushMeta {
146
146
  * registro nuevo, igual que tras `sessionEnd`, pero sin POST.
147
147
  */
148
148
  resetSession?: boolean;
149
+ /**
150
+ * `true` cuando el lote puede ser lo último que salga de la sesión sin cerrarla (app a
151
+ * background en RN: la sesión queda suspendida). El sink lo guarda ANTES de enviarlo, como
152
+ * el lote de cierre, para reenviarlo en el arranque siguiente si el SO mata la app.
153
+ */
154
+ persist?: boolean;
149
155
  }
150
156
  /**
151
157
  * Envío del lote. Si devuelve una promesa que **rechaza**, el manager re-encola los
@@ -1056,14 +1062,21 @@ declare class DeepdotsPopups {
1056
1062
  * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
1057
1063
  */
1058
1064
  setScreen(name: string): void;
1059
- /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
1065
+ /**
1066
+ * App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
1067
+ * background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
1068
+ * (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
1069
+ */
1060
1070
  onForeground(): void;
1061
1071
  /**
1062
- * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
1063
- * (page_view), mini-services (mini_service_exit), emite engagement + `session_end` y
1064
- * envía el último lote con `completed:true`.
1065
- *
1066
- * Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
1072
+ * App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
1073
+ * actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
1074
+ * `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
1075
+ * - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
1076
+ * en el mismo registro;
1077
+ * - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
1078
+ * minutos con un `session_end` `background` a la hora de la suspensión.
1079
+ * Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
1067
1080
  */
1068
1081
  onBackground(): void;
1069
1082
  /**
@@ -1135,6 +1148,7 @@ declare class DeepdotsPopups {
1135
1148
  flushAnalytics(options?: {
1136
1149
  final?: boolean;
1137
1150
  sessionEnd?: boolean;
1151
+ persist?: boolean;
1138
1152
  }): void;
1139
1153
  /**
1140
1154
  * Emite un evento `user_engagement` con el tiempo activo acumulado (#8) y la pantalla en
@@ -1170,8 +1184,12 @@ declare class DeepdotsPopups {
1170
1184
  * - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
1171
1185
  * - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
1172
1186
  *
1187
+ * En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
1188
+ * background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
1189
+ *
1173
1190
  * Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
1174
- * POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra como antes.
1191
+ * POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
1192
+ * como antes.
1175
1193
  */
1176
1194
  private suspendSession;
1177
1195
  /**
@@ -1182,11 +1200,23 @@ declare class DeepdotsPopups {
1182
1200
  private readResumableSession;
1183
1201
  /**
1184
1202
  * Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
1185
- * ella (mismo usuario, dentro de ANALYTICS_RESUME_WINDOW_MS); null si no había o ya no toca.
1203
+ * ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
1204
+ * ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
1186
1205
  * En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
1187
1206
  * se abre ahora va a uno nuevo.
1188
1207
  */
1189
1208
  private takeSuspendedSession;
1209
+ /**
1210
+ * `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
1211
+ * misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
1212
+ * (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
1213
+ * el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
1214
+ * #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
1215
+ * - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
1216
+ * - Más: el backend ya la cerró → se descarta sin enviar nada.
1217
+ * Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
1218
+ */
1219
+ private closeStaleHiddenSession;
1190
1220
  /** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
1191
1221
  private discardSession;
1192
1222
  /**
@@ -38,7 +38,7 @@ var SDK_VERSION, SDK_IDENTIFIER, POPUP_CHANNEL;
38
38
  var init_version = __esm({
39
39
  "src/version.ts"() {
40
40
  "use strict";
41
- SDK_VERSION = "1.20.0";
41
+ SDK_VERSION = "1.21.0";
42
42
  SDK_IDENTIFIER = `${"react-native"}@${SDK_VERSION}`;
43
43
  POPUP_CHANNEL = "popup";
44
44
  }
@@ -13632,9 +13632,11 @@ function createFeedbackSink(options) {
13632
13632
  const body = buildAnalyticsFeedbackBody(envelope, options.keys, feedbackSessionId, { sessionEnd });
13633
13633
  options.log?.("[DeepdotsAnalytics] POST /sdk/feedback \u2192", body);
13634
13634
  const batch = { body, at: now() };
13635
- if (sessionEnd) {
13636
- feedbackSessionId = void 0;
13637
- options.onSessionReset?.();
13635
+ if (sessionEnd || meta?.persist) {
13636
+ if (sessionEnd) {
13637
+ feedbackSessionId = void 0;
13638
+ options.onSessionReset?.();
13639
+ }
13638
13640
  addPending(batch);
13639
13641
  await drain();
13640
13642
  return;
@@ -14331,6 +14333,7 @@ var ANALYTICS_SESSION_TIMEOUT_MS = 30 * 6e4;
14331
14333
  var ANALYTICS_SERVER_IDLE_MS = 60 * 6e4;
14332
14334
  var ANALYTICS_SESSION_DISCARD_MS = ANALYTICS_SERVER_IDLE_MS - 10 * 6e4;
14333
14335
  var ANALYTICS_RESUME_WINDOW_MS = 6e4;
14336
+ var ANALYTICS_BACKGROUND_RESUME_WINDOW_MS = 5 * 6e4;
14334
14337
  var RESERVED_EVENT_PREFIX = "deepdots_";
14335
14338
  var CUSTOM_EVENT_PREFIX = "deepdots_event_";
14336
14339
  var MAX_PENDING_TRIGGERS = 20;
@@ -14498,7 +14501,7 @@ var DeepdotsPopups = class {
14498
14501
  const resumable = this.readResumableSession();
14499
14502
  if (resumable) {
14500
14503
  this.analyticsFeedbackSessionId = resumable.sessionId;
14501
- this.suspended = { at: resumable.at, userId: resumable.userId };
14504
+ this.suspended = { at: resumable.at, userId: resumable.userId, windowMs: ANALYTICS_RESUME_WINDOW_MS };
14502
14505
  }
14503
14506
  const analyticsSink = config.analytics ? createFeedbackSink({
14504
14507
  baseUrl: this.baseUrl,
@@ -14757,21 +14760,28 @@ var DeepdotsPopups = class {
14757
14760
  this.navObserver.visit(name);
14758
14761
  }
14759
14762
  }
14760
- /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
14763
+ /**
14764
+ * App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
14765
+ * background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
14766
+ * (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
14767
+ */
14761
14768
  onForeground() {
14762
14769
  this.engagement?.resume();
14763
14770
  this.openSession("foreground");
14764
14771
  }
14765
14772
  /**
14766
- * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
14767
- * (page_view), mini-services (mini_service_exit), emite engagement + `session_end` y
14768
- * envía el último lote con `completed:true`.
14769
- *
14770
- * Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
14773
+ * App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
14774
+ * actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
14775
+ * `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
14776
+ * - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
14777
+ * en el mismo registro;
14778
+ * - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
14779
+ * minutos con un `session_end` `background` a la hora de la suspensión.
14780
+ * Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
14771
14781
  */
14772
14782
  onBackground() {
14773
14783
  this.cancelDelayedPopups("app to background");
14774
- this.closeSession("background");
14784
+ if (!this.suspendSession("background")) this.closeSession("background");
14775
14785
  this.engagement?.pause();
14776
14786
  }
14777
14787
  /**
@@ -14996,27 +15006,37 @@ var DeepdotsPopups = class {
14996
15006
  * - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
14997
15007
  * - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
14998
15008
  *
15009
+ * En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
15010
+ * background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
15011
+ *
14999
15012
  * Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
15000
- * POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra como antes.
15013
+ * POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
15014
+ * como antes.
15001
15015
  */
15002
- suspendSession() {
15016
+ suspendSession(reason) {
15003
15017
  if (!this.sessionOpen || !this.tracking?.isTrackingEnabled()) return false;
15004
15018
  const sessionId = this.analyticsFeedbackSessionId;
15005
15019
  const integration = this.analyticsIntegration;
15006
- const storage = getSessionStorage();
15007
- if (!sessionId || !integration || !storage) return false;
15020
+ if (!sessionId || !integration) return false;
15008
15021
  const at = Date.now();
15009
15022
  const userId = this.tracking.getUserId();
15010
- if (!writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
15023
+ if (reason === "page_hide") {
15024
+ const storage = getSessionStorage();
15025
+ if (!storage || !writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
15026
+ }
15011
15027
  this.sessionOpen = false;
15012
- this.suspended = { at, userId };
15028
+ this.suspended = {
15029
+ at,
15030
+ userId,
15031
+ windowMs: reason === "page_hide" ? ANALYTICS_RESUME_WINDOW_MS : ANALYTICS_BACKGROUND_RESUME_WINDOW_MS
15032
+ };
15013
15033
  this.navObserver?.stop();
15014
15034
  this.navStarted = false;
15015
15035
  this.analytics?.exitAllMiniServices();
15016
15036
  this.flushEngagement();
15017
15037
  this.engagement?.pause();
15018
- this.track("deepdots_session_suspend", { reason: "page_hide" });
15019
- this.flushAnalytics({ final: true });
15038
+ this.track("deepdots_session_suspend", { reason });
15039
+ this.flushAnalytics(reason === "page_hide" ? { final: true } : { persist: true });
15020
15040
  this.log("tracking \xB7 session suspended:", sessionId);
15021
15041
  return true;
15022
15042
  }
@@ -15038,7 +15058,8 @@ var DeepdotsPopups = class {
15038
15058
  }
15039
15059
  /**
15040
15060
  * Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
15041
- * ella (mismo usuario, dentro de ANALYTICS_RESUME_WINDOW_MS); null si no había o ya no toca.
15061
+ * ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
15062
+ * ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
15042
15063
  * En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
15043
15064
  * se abre ahora va a uno nuevo.
15044
15065
  */
@@ -15049,7 +15070,7 @@ var DeepdotsPopups = class {
15049
15070
  const storage = getSessionStorage();
15050
15071
  if (storage) clearSuspendedSession(storage);
15051
15072
  const suspendedMs = Math.max(0, Date.now() - suspended.at);
15052
- if (this.analyticsFeedbackSessionId && suspendedMs <= ANALYTICS_RESUME_WINDOW_MS && suspended.userId === (this.tracking?.getUserId() ?? null)) {
15073
+ if (this.analyticsFeedbackSessionId && suspendedMs <= suspended.windowMs && suspended.userId === (this.tracking?.getUserId() ?? null)) {
15053
15074
  return suspendedMs;
15054
15075
  }
15055
15076
  this.analytics?.discardSession(this.analyticsIdentity());
@@ -15057,6 +15078,27 @@ var DeepdotsPopups = class {
15057
15078
  this.tracking?.setSessionId(null);
15058
15079
  return null;
15059
15080
  }
15081
+ /**
15082
+ * `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
15083
+ * misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
15084
+ * (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
15085
+ * el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
15086
+ * #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
15087
+ * - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
15088
+ * - Más: el backend ya la cerró → se descarta sin enviar nada.
15089
+ * Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
15090
+ */
15091
+ closeStaleHiddenSession() {
15092
+ if (!this.sessionOpen || this.hiddenAt === null) return false;
15093
+ const hiddenFor = Date.now() - this.hiddenAt;
15094
+ if (hiddenFor < ANALYTICS_SESSION_TIMEOUT_MS) return false;
15095
+ if (hiddenFor < ANALYTICS_SESSION_DISCARD_MS) {
15096
+ this.closeSession("idle_timeout");
15097
+ } else {
15098
+ this.discardSession();
15099
+ }
15100
+ return true;
15101
+ }
15060
15102
  /** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
15061
15103
  discardSession() {
15062
15104
  this.sessionOpen = false;
@@ -15105,7 +15147,8 @@ var DeepdotsPopups = class {
15105
15147
  if (typeof document === "undefined" || typeof window === "undefined") return;
15106
15148
  window.addEventListener("pagehide", () => {
15107
15149
  clearInterval(this.analyticsFlushTimer);
15108
- if (!this.suspendSession()) this.closeSession("page_hide");
15150
+ if (this.closeStaleHiddenSession()) return;
15151
+ if (!this.suspendSession("page_hide")) this.closeSession("page_hide");
15109
15152
  });
15110
15153
  window.addEventListener("pageshow", (event) => {
15111
15154
  if (!event.persisted) return;