@magicfeedback/popup-sdk 1.11.0 → 1.12.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.
@@ -571,8 +571,15 @@ declare class DeepdotsPopups {
571
571
  */
572
572
  private closeSession;
573
573
  /**
574
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
575
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
574
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
575
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
576
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
577
+ * - `foreground`: onForeground() tras un cierre (RN).
578
+ * - `tracking_enabled`: setTrackingEnabled(true).
579
+ * - `user_change`: setUserId() o init() con otro userId.
580
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
581
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
582
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
576
583
  */
577
584
  private openSession;
578
585
  /** Web: si la pestaña se ve. Sin `document` (RN) manda AppState vía onForeground/onBackground. */
@@ -571,8 +571,15 @@ declare class DeepdotsPopups {
571
571
  */
572
572
  private closeSession;
573
573
  /**
574
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
575
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
574
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
575
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
576
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
577
+ * - `foreground`: onForeground() tras un cierre (RN).
578
+ * - `tracking_enabled`: setTrackingEnabled(true).
579
+ * - `user_change`: setUserId() o init() con otro userId.
580
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
581
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
582
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
576
583
  */
577
584
  private openSession;
578
585
  /** Web: si la pestaña se ve. Sin `document` (RN) manda AppState vía onForeground/onBackground. */
@@ -5712,7 +5712,7 @@ var DeepdotsPopups = class {
5712
5712
  this.navObserver.install();
5713
5713
  this.engagement = new EngagementTracker();
5714
5714
  this.setupAnalyticsFlush();
5715
- this.openSession();
5715
+ this.openSession("cold_start");
5716
5716
  if (resumable && this.analyticsFeedbackSessionId === resumable.sessionId) {
5717
5717
  this.notifyFeedbackSession(resumable.sessionId, "open");
5718
5718
  }
@@ -5770,7 +5770,7 @@ var DeepdotsPopups = class {
5770
5770
  setTrackingEnabled(enabled) {
5771
5771
  if (!enabled) this.closeSession("tracking_disabled");
5772
5772
  this.tracking?.setTrackingEnabled(enabled);
5773
- if (enabled) this.openSession();
5773
+ if (enabled) this.openSession("tracking_enabled");
5774
5774
  if (enabled) this.resolveGeo();
5775
5775
  this.log("tracking \xB7 setTrackingEnabled:", enabled, "\xB7 session_id:", this.tracking?.getSessionId() ?? null);
5776
5776
  }
@@ -5887,7 +5887,7 @@ var DeepdotsPopups = class {
5887
5887
  /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
5888
5888
  onForeground() {
5889
5889
  this.engagement?.resume();
5890
- this.openSession();
5890
+ this.openSession("foreground");
5891
5891
  }
5892
5892
  /**
5893
5893
  * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
@@ -5935,7 +5935,7 @@ var DeepdotsPopups = class {
5935
5935
  this.answeredSurveys.clear();
5936
5936
  clearPopupState(storage);
5937
5937
  this.log("tracking \xB7 user_change \xB7 user_id:", this.tracking.getUserId());
5938
- this.openSession();
5938
+ this.openSession("user_change");
5939
5939
  }
5940
5940
  /**
5941
5941
  * Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
@@ -5961,17 +5961,24 @@ var DeepdotsPopups = class {
5961
5961
  this.log("tracking \xB7 session_end:", reason);
5962
5962
  }
5963
5963
  /**
5964
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
5965
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
5964
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
5965
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
5966
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
5967
+ * - `foreground`: onForeground() tras un cierre (RN).
5968
+ * - `tracking_enabled`: setTrackingEnabled(true).
5969
+ * - `user_change`: setUserId() o init() con otro userId.
5970
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
5971
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
5972
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
5966
5973
  */
5967
- openSession() {
5974
+ openSession(reason) {
5968
5975
  if (this.sessionOpen) return;
5969
5976
  if (!this.tracking?.isTrackingEnabled()) return;
5970
5977
  const suspendedMs = this.takeSuspendedSession();
5971
5978
  this.sessionOpen = true;
5972
5979
  this.lastEngagementAt = Date.now();
5973
5980
  if (suspendedMs === null) {
5974
- this.track("deepdots_session_start", {});
5981
+ this.track("deepdots_session_start", { reason });
5975
5982
  } else {
5976
5983
  this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
5977
5984
  this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
@@ -6038,7 +6045,7 @@ var DeepdotsPopups = class {
6038
6045
  } else {
6039
6046
  this.discardSession();
6040
6047
  }
6041
- this.openSession();
6048
+ this.openSession("idle_timeout");
6042
6049
  }
6043
6050
  /**
6044
6051
  * `pagehide` en web: SUSPENDE la sesión en vez de cerrarla, porque el navegador lo lanza
@@ -6162,7 +6169,7 @@ var DeepdotsPopups = class {
6162
6169
  window.addEventListener("pageshow", (event) => {
6163
6170
  if (!event.persisted) return;
6164
6171
  this.startAnalyticsFlushTimer();
6165
- this.openSession();
6172
+ this.openSession("bfcache_restore");
6166
6173
  });
6167
6174
  document.addEventListener("visibilitychange", () => {
6168
6175
  if (document.visibilityState === "hidden") {