@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.
package/dist/index.d.mts CHANGED
@@ -383,6 +383,23 @@ type EventListener = (event: DeepdotsEvent) => void;
383
383
  * anterior se cierra y se abre otra, como hace GA con su timeout de sesión.
384
384
  */
385
385
  type SessionEndReason = 'page_hide' | 'background' | 'user_change' | 'tracking_disabled' | 'manual' | 'idle_timeout';
386
+ /**
387
+ * Motivo del `deepdots_session_start` (param `reason`): por qué EMPIEZA la sesión. Permite a
388
+ * analytics separar una carga/arranque real de una vuelta desde background ("Started here").
389
+ * Mismos valores que el SDK nativo donde el significado coincide:
390
+ * - `cold_start`: `init()` (carga de la página / arranque de la app RN) sin sesión suspendida
391
+ * que reanudar. Una recarga en menos de 1 min no emite `session_start` sino
392
+ * `deepdots_session_resume`.
393
+ * - `foreground`: `onForeground()` (RN, AppState 'active') tras un cierre (`onBackground()`
394
+ * o `endSession()`). Con la sesión abierta no emite nada.
395
+ * - `tracking_enabled`: `setTrackingEnabled(true)` (consentimiento concedido).
396
+ * - `user_change`: `setUserId()` o un `init()` con otro `userId`, tras cerrar la del anterior.
397
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta (web): la sesión
398
+ * anterior se cerró (o se descartó) y empieza otra.
399
+ * - `bfcache_restore`: la página vuelve de la bfcache (botón atrás, `pageshow` con
400
+ * `persisted`) fuera de la ventana de reanudación (web).
401
+ */
402
+ type SessionStartReason = 'cold_start' | 'foreground' | 'tracking_enabled' | 'user_change' | 'idle_timeout' | 'bfcache_restore';
386
403
  /** Trigger type used by remote popup definitions */
387
404
  type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click' | 'event';
388
405
  type PopupTriggerConditionStatus = 'SHOWED' | 'PARTIAL' | 'COMPLETED';
@@ -888,8 +905,15 @@ declare class DeepdotsPopups {
888
905
  */
889
906
  private closeSession;
890
907
  /**
891
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
892
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
908
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
909
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
910
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
911
+ * - `foreground`: onForeground() tras un cierre (RN).
912
+ * - `tracking_enabled`: setTrackingEnabled(true).
913
+ * - `user_change`: setUserId() o init() con otro userId.
914
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
915
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
916
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
893
917
  */
894
918
  private openSession;
895
919
  /** Web: si la pestaña se ve. Sin `document` (RN) manda AppState vía onForeground/onBackground. */
@@ -1362,4 +1386,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1362
1386
  */
1363
1387
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1364
1388
 
1365
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1389
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type SessionStartReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
package/dist/index.d.ts CHANGED
@@ -383,6 +383,23 @@ type EventListener = (event: DeepdotsEvent) => void;
383
383
  * anterior se cierra y se abre otra, como hace GA con su timeout de sesión.
384
384
  */
385
385
  type SessionEndReason = 'page_hide' | 'background' | 'user_change' | 'tracking_disabled' | 'manual' | 'idle_timeout';
386
+ /**
387
+ * Motivo del `deepdots_session_start` (param `reason`): por qué EMPIEZA la sesión. Permite a
388
+ * analytics separar una carga/arranque real de una vuelta desde background ("Started here").
389
+ * Mismos valores que el SDK nativo donde el significado coincide:
390
+ * - `cold_start`: `init()` (carga de la página / arranque de la app RN) sin sesión suspendida
391
+ * que reanudar. Una recarga en menos de 1 min no emite `session_start` sino
392
+ * `deepdots_session_resume`.
393
+ * - `foreground`: `onForeground()` (RN, AppState 'active') tras un cierre (`onBackground()`
394
+ * o `endSession()`). Con la sesión abierta no emite nada.
395
+ * - `tracking_enabled`: `setTrackingEnabled(true)` (consentimiento concedido).
396
+ * - `user_change`: `setUserId()` o un `init()` con otro `userId`, tras cerrar la del anterior.
397
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta (web): la sesión
398
+ * anterior se cerró (o se descartó) y empieza otra.
399
+ * - `bfcache_restore`: la página vuelve de la bfcache (botón atrás, `pageshow` con
400
+ * `persisted`) fuera de la ventana de reanudación (web).
401
+ */
402
+ type SessionStartReason = 'cold_start' | 'foreground' | 'tracking_enabled' | 'user_change' | 'idle_timeout' | 'bfcache_restore';
386
403
  /** Trigger type used by remote popup definitions */
387
404
  type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click' | 'event';
388
405
  type PopupTriggerConditionStatus = 'SHOWED' | 'PARTIAL' | 'COMPLETED';
@@ -888,8 +905,15 @@ declare class DeepdotsPopups {
888
905
  */
889
906
  private closeSession;
890
907
  /**
891
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
892
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
908
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
909
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
910
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
911
+ * - `foreground`: onForeground() tras un cierre (RN).
912
+ * - `tracking_enabled`: setTrackingEnabled(true).
913
+ * - `user_change`: setUserId() o init() con otro userId.
914
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
915
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
916
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
893
917
  */
894
918
  private openSession;
895
919
  /** Web: si la pestaña se ve. Sin `document` (RN) manda AppState vía onForeground/onBackground. */
@@ -1362,4 +1386,4 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1362
1386
  */
1363
1387
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1364
1388
 
1365
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1389
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, BrowserPopupRenderer, type BuildBodyOptions, type ContactAttributeValue, type ContactAttributes, type ContactBody, ContactManager, type CrashRecord, CrashReporter, type CrashSeverity, type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, type DeepdotsInitParams, type DeepdotsLogger, DeepdotsPopups, type DeviceInfo, type DeviceInfoLike, type DeviceSnapshot, type EventListener, type FeedbackKV, type FeedbackSession, InMemoryStorage, type KeyValueStorage, LABELS, MAX_TRACKED_MESSAGES, MESSAGE_CHANNELS, type MessageChannel, MessageGuard, type MessageGuardVerdict, type MessageRejectionReason, type MessageStage, type MmkvLike, NATIVE_READY_GRACE_MS, NoopPopupRenderer, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupLabels, type PopupLocale, type PopupRenderer, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type SessionStartReason, type TrackMessageOptions, type TriggerConfig, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
package/dist/index.js CHANGED
@@ -8472,7 +8472,7 @@ var DeepdotsPopups = class {
8472
8472
  this.navObserver.install();
8473
8473
  this.engagement = new EngagementTracker();
8474
8474
  this.setupAnalyticsFlush();
8475
- this.openSession();
8475
+ this.openSession("cold_start");
8476
8476
  if (resumable && this.analyticsFeedbackSessionId === resumable.sessionId) {
8477
8477
  this.notifyFeedbackSession(resumable.sessionId, "open");
8478
8478
  }
@@ -8530,7 +8530,7 @@ var DeepdotsPopups = class {
8530
8530
  setTrackingEnabled(enabled) {
8531
8531
  if (!enabled) this.closeSession("tracking_disabled");
8532
8532
  this.tracking?.setTrackingEnabled(enabled);
8533
- if (enabled) this.openSession();
8533
+ if (enabled) this.openSession("tracking_enabled");
8534
8534
  if (enabled) this.resolveGeo();
8535
8535
  this.log("tracking \xB7 setTrackingEnabled:", enabled, "\xB7 session_id:", this.tracking?.getSessionId() ?? null);
8536
8536
  }
@@ -8647,7 +8647,7 @@ var DeepdotsPopups = class {
8647
8647
  /** App a foreground (RN: AppState 'active'): reanuda el engagement time y abre sesión nueva. */
8648
8648
  onForeground() {
8649
8649
  this.engagement?.resume();
8650
- this.openSession();
8650
+ this.openSession("foreground");
8651
8651
  }
8652
8652
  /**
8653
8653
  * App a background (RN: AppState 'background'): FIN DE SESIÓN. Cierra pantalla actual
@@ -8695,7 +8695,7 @@ var DeepdotsPopups = class {
8695
8695
  this.answeredSurveys.clear();
8696
8696
  clearPopupState(storage);
8697
8697
  this.log("tracking \xB7 user_change \xB7 user_id:", this.tracking.getUserId());
8698
- this.openSession();
8698
+ this.openSession("user_change");
8699
8699
  }
8700
8700
  /**
8701
8701
  * Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
@@ -8721,17 +8721,24 @@ var DeepdotsPopups = class {
8721
8721
  this.log("tracking \xB7 session_end:", reason);
8722
8722
  }
8723
8723
  /**
8724
- * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente:
8725
- * se llama en init(), al volver a foreground y al conceder el consentimiento.
8724
+ * Abre sesión (`session_start`) si no hay una abierta y el tracking está activo. Idempotente.
8725
+ * El `reason` dice por qué empieza (ver `SessionStartReason`):
8726
+ * - `cold_start`: init() (carga de la página / arranque de la app RN).
8727
+ * - `foreground`: onForeground() tras un cierre (RN).
8728
+ * - `tracking_enabled`: setTrackingEnabled(true).
8729
+ * - `user_change`: setUserId() o init() con otro userId.
8730
+ * - `idle_timeout`: la pestaña vuelve a verse tras más de 30 min oculta.
8731
+ * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
8732
+ * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
8726
8733
  */
8727
- openSession() {
8734
+ openSession(reason) {
8728
8735
  if (this.sessionOpen) return;
8729
8736
  if (!this.tracking?.isTrackingEnabled()) return;
8730
8737
  const suspendedMs = this.takeSuspendedSession();
8731
8738
  this.sessionOpen = true;
8732
8739
  this.lastEngagementAt = Date.now();
8733
8740
  if (suspendedMs === null) {
8734
- this.track("deepdots_session_start", {});
8741
+ this.track("deepdots_session_start", { reason });
8735
8742
  } else {
8736
8743
  this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
8737
8744
  this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
@@ -8798,7 +8805,7 @@ var DeepdotsPopups = class {
8798
8805
  } else {
8799
8806
  this.discardSession();
8800
8807
  }
8801
- this.openSession();
8808
+ this.openSession("idle_timeout");
8802
8809
  }
8803
8810
  /**
8804
8811
  * `pagehide` en web: SUSPENDE la sesión en vez de cerrarla, porque el navegador lo lanza
@@ -8922,7 +8929,7 @@ var DeepdotsPopups = class {
8922
8929
  window.addEventListener("pageshow", (event) => {
8923
8930
  if (!event.persisted) return;
8924
8931
  this.startAnalyticsFlushTimer();
8925
- this.openSession();
8932
+ this.openSession("bfcache_restore");
8926
8933
  });
8927
8934
  document.addEventListener("visibilitychange", () => {
8928
8935
  if (document.visibilityState === "hidden") {