@magicfeedback/popup-sdk 1.19.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 (34) hide show
  1. package/dist/{chunk-EW2ARDEY.mjs → chunk-BWYWXAIQ.mjs} +23 -3
  2. package/dist/chunk-BWYWXAIQ.mjs.map +1 -0
  3. package/dist/{chunk-7ZQOAKXR.mjs → chunk-H434NTBB.mjs} +26 -4
  4. package/dist/chunk-H434NTBB.mjs.map +1 -0
  5. package/dist/{chunk-XOEEBDBJ.mjs → chunk-UBUY6G6Z.mjs} +26 -4
  6. package/dist/chunk-UBUY6G6Z.mjs.map +1 -0
  7. package/dist/index.d.mts +105 -10
  8. package/dist/index.d.ts +105 -10
  9. package/dist/index.js +186 -37
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +163 -36
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/index.native.d.mts +105 -10
  14. package/dist/index.native.d.ts +105 -10
  15. package/dist/index.native.js +204 -42
  16. package/dist/index.native.js.map +1 -1
  17. package/dist/index.native.mjs +181 -41
  18. package/dist/index.native.mjs.map +1 -1
  19. package/dist/react-native.d.mts +47 -8
  20. package/dist/react-native.d.ts +47 -8
  21. package/dist/react-native.js +200 -41
  22. package/dist/react-native.js.map +1 -1
  23. package/dist/react-native.mjs +180 -41
  24. package/dist/react-native.mjs.map +1 -1
  25. package/dist/{renderPopup-2Y4QMWR7.mjs → renderPopup-HNSFPFVT.mjs} +2 -2
  26. package/dist/{renderPopup-ZHTRMFO2.mjs → renderPopup-VXKWSZ4E.mjs} +2 -2
  27. package/dist/{renderPopup-YDJUON42.mjs → renderPopup-WNF67H5T.mjs} +2 -2
  28. package/package.json +1 -1
  29. package/dist/chunk-7ZQOAKXR.mjs.map +0 -1
  30. package/dist/chunk-EW2ARDEY.mjs.map +0 -1
  31. package/dist/chunk-XOEEBDBJ.mjs.map +0 -1
  32. /package/dist/{renderPopup-2Y4QMWR7.mjs.map → renderPopup-HNSFPFVT.mjs.map} +0 -0
  33. /package/dist/{renderPopup-ZHTRMFO2.mjs.map → renderPopup-VXKWSZ4E.mjs.map} +0 -0
  34. /package/dist/{renderPopup-YDJUON42.mjs.map → renderPopup-WNF67H5T.mjs.map} +0 -0
@@ -29,7 +29,7 @@ import {
29
29
  style_default,
30
30
  surveySdkCssUrls,
31
31
  surveySdkUrls
32
- } from "./chunk-7ZQOAKXR.mjs";
32
+ } from "./chunk-H434NTBB.mjs";
33
33
  import "./chunk-3QS3WKRC.mjs";
34
34
 
35
35
  // src/index.native.ts
@@ -64,6 +64,68 @@ function resolveBackgroundTask(explicit, platform) {
64
64
  }
65
65
  return void 0;
66
66
  }
67
+ var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
68
+ function createHermesRejectionHub(hermes, options) {
69
+ if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
70
+ const original = hermes.enablePromiseRejectionTracker.bind(hermes);
71
+ const listeners = /* @__PURE__ */ new Set();
72
+ let hostOptions = null;
73
+ let active = false;
74
+ const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
75
+ const apply = () => {
76
+ original({
77
+ allRejections: true,
78
+ onUnhandled: (id, error) => {
79
+ listeners.forEach((listener) => {
80
+ try {
81
+ listener(error);
82
+ } catch {
83
+ }
84
+ });
85
+ if (hostOptions?.onUnhandled) {
86
+ if (forwardsToHost(error)) hostOptions.onUnhandled(id, error);
87
+ } else if (options.dev) {
88
+ console.warn(`Possible unhandled promise rejection (id: ${id}):`, error);
89
+ }
90
+ },
91
+ onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
92
+ });
93
+ };
94
+ hermes.enablePromiseRejectionTracker = (next) => {
95
+ hostOptions = next ?? null;
96
+ if (active) apply();
97
+ else original(next);
98
+ };
99
+ return {
100
+ addUnhandledListener(listener) {
101
+ listeners.add(listener);
102
+ if (!active) {
103
+ active = true;
104
+ apply();
105
+ }
106
+ return () => {
107
+ listeners.delete(listener);
108
+ };
109
+ }
110
+ };
111
+ }
112
+
113
+ // src/platform/react-native-defaults.ts
114
+ var hub;
115
+ function registerReactNativeDefaults(rn) {
116
+ if (hub === void 0) {
117
+ hub = getReactNativePlatform()?.promiseRejections ?? createHermesRejectionHub(
118
+ globalThis.HermesInternal,
119
+ { dev: typeof __DEV__ !== "undefined" && !!__DEV__ }
120
+ );
121
+ }
122
+ registerReactNativePlatform({
123
+ os: rn.Platform.OS,
124
+ appState: rn.AppState,
125
+ backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
126
+ promiseRejections: hub
127
+ });
128
+ }
67
129
 
68
130
  // src/types/index.ts
69
131
  var POPUP_TRIGGER_CONDITION_STATUSES = [
@@ -1030,7 +1092,7 @@ function logRnSurveySdkChoice(choice, debug) {
1030
1092
  }
1031
1093
 
1032
1094
  // src/ui/preload.ts
1033
- var defaultLoader = () => import("./renderPopup-YDJUON42.mjs");
1095
+ var defaultLoader = () => import("./renderPopup-WNF67H5T.mjs");
1034
1096
  var pending = null;
1035
1097
  function preloadRenderPopup(loader = defaultLoader) {
1036
1098
  if (pending) return pending;
@@ -1103,7 +1165,7 @@ var BrowserPopupRenderer = class {
1103
1165
  if (!this.container) return;
1104
1166
  this.visible = true;
1105
1167
  const container = this.container;
1106
- void import("./renderPopup-YDJUON42.mjs").then(
1168
+ void import("./renderPopup-WNF67H5T.mjs").then(
1107
1169
  ({ renderPopup }) => {
1108
1170
  renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
1109
1171
  },
@@ -1583,9 +1645,11 @@ function createFeedbackSink(options) {
1583
1645
  const body = buildAnalyticsFeedbackBody(envelope, options.keys, feedbackSessionId, { sessionEnd });
1584
1646
  options.log?.("[DeepdotsAnalytics] POST /sdk/feedback \u2192", body);
1585
1647
  const batch = { body, at: now() };
1586
- if (sessionEnd) {
1587
- feedbackSessionId = void 0;
1588
- options.onSessionReset?.();
1648
+ if (sessionEnd || meta?.persist) {
1649
+ if (sessionEnd) {
1650
+ feedbackSessionId = void 0;
1651
+ options.onSessionReset?.();
1652
+ }
1589
1653
  addPending(batch);
1590
1654
  await drain();
1591
1655
  return;
@@ -2014,6 +2078,8 @@ var CrashReporter = class {
2014
2078
  this.windowInstalled = false;
2015
2079
  /** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
2016
2080
  this.hookedErrorUtils = /* @__PURE__ */ new Set();
2081
+ /** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
2082
+ this.hookedRejections = /* @__PURE__ */ new Set();
2017
2083
  this.options = options;
2018
2084
  this.now = options.now ?? (() => Date.now());
2019
2085
  }
@@ -2113,6 +2179,18 @@ var CrashReporter = class {
2113
2179
  previous?.(error, isFatal);
2114
2180
  });
2115
2181
  }
2182
+ /**
2183
+ * Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
2184
+ * persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
2185
+ * Idempotente por fuente.
2186
+ */
2187
+ installPromiseRejections(source) {
2188
+ if (this.hookedRejections.has(source)) return;
2189
+ this.hookedRejections.add(source);
2190
+ source.addUnhandledListener((error) => {
2191
+ if (this.isEnabled()) this.captureUnhandled(error ?? "unhandledrejection");
2192
+ });
2193
+ }
2116
2194
  /** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
2117
2195
  _persistForTest(error) {
2118
2196
  this.captureUnhandled(error);
@@ -2264,6 +2342,7 @@ var ANALYTICS_SESSION_TIMEOUT_MS = 30 * 6e4;
2264
2342
  var ANALYTICS_SERVER_IDLE_MS = 60 * 6e4;
2265
2343
  var ANALYTICS_SESSION_DISCARD_MS = ANALYTICS_SERVER_IDLE_MS - 10 * 6e4;
2266
2344
  var ANALYTICS_RESUME_WINDOW_MS = 6e4;
2345
+ var ANALYTICS_BACKGROUND_RESUME_WINDOW_MS = 5 * 6e4;
2267
2346
  var RESERVED_EVENT_PREFIX = "deepdots_";
2268
2347
  var CUSTOM_EVENT_PREFIX = "deepdots_event_";
2269
2348
  var MAX_PENDING_TRIGGERS = 20;
@@ -2351,6 +2430,8 @@ var DeepdotsPopups = class {
2351
2430
  this.lastEngagementAt = 0;
2352
2431
  /** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
2353
2432
  this.hiddenAt = null;
2433
+ /** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
2434
+ this.autoTrackErrors = true;
2354
2435
  /** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
2355
2436
  this.appStateSubscription = void 0;
2356
2437
  /**
@@ -2397,6 +2478,7 @@ var DeepdotsPopups = class {
2397
2478
  this.surveyCss = config.surveyCss;
2398
2479
  this.cspNonce = config.cspNonce;
2399
2480
  this.onFeedbackSession = config.onFeedbackSession;
2481
+ this.autoTrackErrors = config.autoTrack?.errors !== false;
2400
2482
  this.config = {
2401
2483
  apiKey: config.apiKey || void 0,
2402
2484
  debug: config.debug || false,
@@ -2428,7 +2510,7 @@ var DeepdotsPopups = class {
2428
2510
  const resumable = this.readResumableSession();
2429
2511
  if (resumable) {
2430
2512
  this.analyticsFeedbackSessionId = resumable.sessionId;
2431
- this.suspended = { at: resumable.at, userId: resumable.userId };
2513
+ this.suspended = { at: resumable.at, userId: resumable.userId, windowMs: ANALYTICS_RESUME_WINDOW_MS };
2432
2514
  }
2433
2515
  const analyticsSink = config.analytics ? createFeedbackSink({
2434
2516
  baseUrl: this.baseUrl,
@@ -2595,11 +2677,14 @@ var DeepdotsPopups = class {
2595
2677
  */
2596
2678
  installCrashHandlers() {
2597
2679
  if (!this.crashReporter || !this.tracking?.isTrackingEnabled()) return;
2598
- this.crashReporter.install();
2599
- const errorUtils = this.rnErrorUtils ?? globalThis.ErrorUtils;
2680
+ const auto = this.autoTrackErrors;
2681
+ if (auto) this.crashReporter.install();
2682
+ const errorUtils = this.rnErrorUtils ?? (auto ? globalThis.ErrorUtils : void 0);
2600
2683
  if (errorUtils && typeof errorUtils.setGlobalHandler === "function") {
2601
2684
  this.crashReporter.installReactNative(errorUtils);
2602
2685
  }
2686
+ const rejections = auto ? getReactNativePlatform()?.promiseRejections : null;
2687
+ if (rejections) this.crashReporter.installPromiseRejections(rejections);
2603
2688
  }
2604
2689
  /**
2605
2690
  * Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
@@ -2684,21 +2769,28 @@ var DeepdotsPopups = class {
2684
2769
  this.navObserver.visit(name);
2685
2770
  }
2686
2771
  }
2687
- /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
2772
+ /**
2773
+ * App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
2774
+ * background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
2775
+ * (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
2776
+ */
2688
2777
  onForeground() {
2689
2778
  this.engagement?.resume();
2690
2779
  this.openSession("foreground");
2691
2780
  }
2692
2781
  /**
2693
- * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
2694
- * (page_view), mini-services (mini_service_exit), emite engagement + `session_end` y
2695
- * envía el último lote con `completed:true`.
2696
- *
2697
- * Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
2782
+ * App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
2783
+ * actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
2784
+ * `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
2785
+ * - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
2786
+ * en el mismo registro;
2787
+ * - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
2788
+ * minutos con un `session_end` `background` a la hora de la suspensión.
2789
+ * Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
2698
2790
  */
2699
2791
  onBackground() {
2700
2792
  this.cancelDelayedPopups("app to background");
2701
- this.closeSession("background");
2793
+ if (!this.suspendSession("background")) this.closeSession("background");
2702
2794
  this.engagement?.pause();
2703
2795
  }
2704
2796
  /**
@@ -2745,11 +2837,24 @@ var DeepdotsPopups = class {
2745
2837
  * anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
2746
2838
  * identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
2747
2839
  *
2840
+ * Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
2841
+ * persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
2842
+ * `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
2843
+ * cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
2844
+ * respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
2845
+ * contaba dos veces: una que "abandona" en el login y otra registrada nueva.
2846
+ *
2748
2847
  * Equivale a llamar a `init()` otra vez con otro `userId`.
2749
2848
  */
2750
2849
  setUserId(userId) {
2751
2850
  const next = userId || void 0;
2752
2851
  if (!this.initialized || !this.config || next === this.config.userId) return;
2852
+ const identifying = !this.config.userId && !!next;
2853
+ const previous = identifying ? {
2854
+ identified: true,
2855
+ previous_user_id: this.tracking?.getUserId() ?? void 0,
2856
+ previous_session_id: this.analyticsFeedbackSessionId
2857
+ } : void 0;
2753
2858
  this.closeSession("user_change");
2754
2859
  const enabled = this.tracking?.isTrackingEnabled() ?? true;
2755
2860
  const storage = this.storage ?? createDefaultStorage();
@@ -2762,13 +2867,18 @@ var DeepdotsPopups = class {
2762
2867
  post: (body) => this.postContact(body)
2763
2868
  }) : null;
2764
2869
  this.analytics?.resetUserScope();
2765
- this.messageGuard.reset();
2766
- this.lastShown.clear();
2767
- this.surveyProgress.clear();
2768
- this.answeredSurveys.clear();
2769
- clearPopupState(storage);
2770
- this.log("tracking \xB7 user_change \xB7 user_id:", this.tracking.getUserId());
2771
- this.openSession("user_change");
2870
+ if (!identifying) {
2871
+ this.messageGuard.reset();
2872
+ this.lastShown.clear();
2873
+ this.surveyProgress.clear();
2874
+ this.answeredSurveys.clear();
2875
+ clearPopupState(storage);
2876
+ }
2877
+ this.log(
2878
+ identifying ? "tracking \xB7 user identified \xB7 user_id:" : "tracking \xB7 user_change \xB7 user_id:",
2879
+ this.tracking.getUserId()
2880
+ );
2881
+ this.openSession("user_change", previous);
2772
2882
  }
2773
2883
  /**
2774
2884
  * Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
@@ -2804,14 +2914,14 @@ var DeepdotsPopups = class {
2804
2914
  * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
2805
2915
  * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
2806
2916
  */
2807
- openSession(reason) {
2917
+ openSession(reason, extra) {
2808
2918
  if (this.sessionOpen) return;
2809
2919
  if (!this.tracking?.isTrackingEnabled()) return;
2810
2920
  const suspendedMs = this.takeSuspendedSession();
2811
2921
  this.sessionOpen = true;
2812
2922
  this.lastEngagementAt = Date.now();
2813
2923
  if (suspendedMs === null) {
2814
- this.track("deepdots_session_start", { reason });
2924
+ this.track("deepdots_session_start", { reason, ...extra });
2815
2925
  } else {
2816
2926
  this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
2817
2927
  this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
@@ -2905,27 +3015,37 @@ var DeepdotsPopups = class {
2905
3015
  * - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
2906
3016
  * - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
2907
3017
  *
3018
+ * En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
3019
+ * background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
3020
+ *
2908
3021
  * Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
2909
- * POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra como antes.
3022
+ * POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
3023
+ * como antes.
2910
3024
  */
2911
- suspendSession() {
3025
+ suspendSession(reason) {
2912
3026
  if (!this.sessionOpen || !this.tracking?.isTrackingEnabled()) return false;
2913
3027
  const sessionId = this.analyticsFeedbackSessionId;
2914
3028
  const integration = this.analyticsIntegration;
2915
- const storage = getSessionStorage();
2916
- if (!sessionId || !integration || !storage) return false;
3029
+ if (!sessionId || !integration) return false;
2917
3030
  const at = Date.now();
2918
3031
  const userId = this.tracking.getUserId();
2919
- if (!writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
3032
+ if (reason === "page_hide") {
3033
+ const storage = getSessionStorage();
3034
+ if (!storage || !writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
3035
+ }
2920
3036
  this.sessionOpen = false;
2921
- this.suspended = { at, userId };
3037
+ this.suspended = {
3038
+ at,
3039
+ userId,
3040
+ windowMs: reason === "page_hide" ? ANALYTICS_RESUME_WINDOW_MS : ANALYTICS_BACKGROUND_RESUME_WINDOW_MS
3041
+ };
2922
3042
  this.navObserver?.stop();
2923
3043
  this.navStarted = false;
2924
3044
  this.analytics?.exitAllMiniServices();
2925
3045
  this.flushEngagement();
2926
3046
  this.engagement?.pause();
2927
- this.track("deepdots_session_suspend", { reason: "page_hide" });
2928
- this.flushAnalytics({ final: true });
3047
+ this.track("deepdots_session_suspend", { reason });
3048
+ this.flushAnalytics(reason === "page_hide" ? { final: true } : { persist: true });
2929
3049
  this.log("tracking \xB7 session suspended:", sessionId);
2930
3050
  return true;
2931
3051
  }
@@ -2947,7 +3067,8 @@ var DeepdotsPopups = class {
2947
3067
  }
2948
3068
  /**
2949
3069
  * Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
2950
- * ella (mismo usuario, dentro de ANALYTICS_RESUME_WINDOW_MS); null si no había o ya no toca.
3070
+ * ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
3071
+ * ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
2951
3072
  * En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
2952
3073
  * se abre ahora va a uno nuevo.
2953
3074
  */
@@ -2958,7 +3079,7 @@ var DeepdotsPopups = class {
2958
3079
  const storage = getSessionStorage();
2959
3080
  if (storage) clearSuspendedSession(storage);
2960
3081
  const suspendedMs = Math.max(0, Date.now() - suspended.at);
2961
- if (this.analyticsFeedbackSessionId && suspendedMs <= ANALYTICS_RESUME_WINDOW_MS && suspended.userId === (this.tracking?.getUserId() ?? null)) {
3082
+ if (this.analyticsFeedbackSessionId && suspendedMs <= suspended.windowMs && suspended.userId === (this.tracking?.getUserId() ?? null)) {
2962
3083
  return suspendedMs;
2963
3084
  }
2964
3085
  this.analytics?.discardSession(this.analyticsIdentity());
@@ -2966,6 +3087,27 @@ var DeepdotsPopups = class {
2966
3087
  this.tracking?.setSessionId(null);
2967
3088
  return null;
2968
3089
  }
3090
+ /**
3091
+ * `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
3092
+ * misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
3093
+ * (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
3094
+ * el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
3095
+ * #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
3096
+ * - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
3097
+ * - Más: el backend ya la cerró → se descarta sin enviar nada.
3098
+ * Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
3099
+ */
3100
+ closeStaleHiddenSession() {
3101
+ if (!this.sessionOpen || this.hiddenAt === null) return false;
3102
+ const hiddenFor = Date.now() - this.hiddenAt;
3103
+ if (hiddenFor < ANALYTICS_SESSION_TIMEOUT_MS) return false;
3104
+ if (hiddenFor < ANALYTICS_SESSION_DISCARD_MS) {
3105
+ this.closeSession("idle_timeout");
3106
+ } else {
3107
+ this.discardSession();
3108
+ }
3109
+ return true;
3110
+ }
2969
3111
  /** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
2970
3112
  discardSession() {
2971
3113
  this.sessionOpen = false;
@@ -3014,7 +3156,8 @@ var DeepdotsPopups = class {
3014
3156
  if (typeof document === "undefined" || typeof window === "undefined") return;
3015
3157
  window.addEventListener("pagehide", () => {
3016
3158
  clearInterval(this.analyticsFlushTimer);
3017
- if (!this.suspendSession()) this.closeSession("page_hide");
3159
+ if (this.closeStaleHiddenSession()) return;
3160
+ if (!this.suspendSession("page_hide")) this.closeSession("page_hide");
3018
3161
  });
3019
3162
  window.addEventListener("pageshow", (event) => {
3020
3163
  if (!event.persisted) return;
@@ -3872,11 +4015,7 @@ function setupReactNative(sdk, config, deps = {}) {
3872
4015
  }
3873
4016
 
3874
4017
  // src/index.native.ts
3875
- registerReactNativePlatform({
3876
- os: Platform.OS,
3877
- appState: AppState,
3878
- backgroundTaskModule: NativeModules?.DeepdotsBackgroundTask ?? null
3879
- });
4018
+ registerReactNativeDefaults({ AppState, NativeModules, Platform });
3880
4019
  export {
3881
4020
  BACKGROUND_TASK_MAX_MS,
3882
4021
  BrowserPopupRenderer,
@@ -3903,6 +4042,7 @@ export {
3903
4042
  crashRecordToParams,
3904
4043
  createDefaultRenderer,
3905
4044
  createFeedbackSink,
4045
+ createHermesRejectionHub,
3906
4046
  directionFor,
3907
4047
  getLabels,
3908
4048
  isRtlLanguage,