@magicfeedback/popup-sdk 1.19.0 → 1.20.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-FROREHRG.mjs} +23 -3
  2. package/dist/chunk-FROREHRG.mjs.map +1 -0
  3. package/dist/{chunk-XOEEBDBJ.mjs → chunk-OPR5I7WO.mjs} +26 -4
  4. package/dist/chunk-OPR5I7WO.mjs.map +1 -0
  5. package/dist/{chunk-7ZQOAKXR.mjs → chunk-ZJ5HG3QF.mjs} +26 -4
  6. package/dist/chunk-ZJ5HG3QF.mjs.map +1 -0
  7. package/dist/index.d.mts +67 -2
  8. package/dist/index.d.ts +67 -2
  9. package/dist/index.js +121 -15
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +98 -14
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/index.native.d.mts +67 -2
  14. package/dist/index.native.d.ts +67 -2
  15. package/dist/index.native.js +139 -20
  16. package/dist/index.native.js.map +1 -1
  17. package/dist/index.native.mjs +116 -19
  18. package/dist/index.native.mjs.map +1 -1
  19. package/dist/react-native.d.mts +15 -0
  20. package/dist/react-native.d.ts +15 -0
  21. package/dist/react-native.js +135 -19
  22. package/dist/react-native.js.map +1 -1
  23. package/dist/react-native.mjs +115 -19
  24. package/dist/react-native.mjs.map +1 -1
  25. package/dist/{renderPopup-ZHTRMFO2.mjs → renderPopup-I6CPIR75.mjs} +2 -2
  26. package/dist/{renderPopup-2Y4QMWR7.mjs → renderPopup-RUY3OBYV.mjs} +2 -2
  27. package/dist/{renderPopup-YDJUON42.mjs → renderPopup-XNVNP2ZU.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-ZHTRMFO2.mjs.map → renderPopup-I6CPIR75.mjs.map} +0 -0
  33. /package/dist/{renderPopup-2Y4QMWR7.mjs.map → renderPopup-RUY3OBYV.mjs.map} +0 -0
  34. /package/dist/{renderPopup-YDJUON42.mjs.map → renderPopup-XNVNP2ZU.mjs.map} +0 -0
@@ -308,6 +308,12 @@ interface FeedbackSession {
308
308
  interface AutoTrackOptions {
309
309
  /** React Native: listen to `AppState` for session start/end. Default `true`. */
310
310
  lifecycle?: boolean;
311
+ /**
312
+ * Uncaught errors: `window` `error`/`unhandledrejection` (web), `ErrorUtils` and promise
313
+ * rejections without `catch` under Hermes (React Native). Default `true`. Handlers installed
314
+ * by other tools (Sentry, Crashlytics) keep receiving everything.
315
+ */
316
+ errors?: boolean;
311
317
  }
312
318
  interface DeepdotsInitParams {
313
319
  /** API key for authentication */
@@ -762,6 +768,10 @@ interface ReactNativeErrorUtils {
762
768
  getGlobalHandler?(): ((error: unknown, isFatal?: boolean) => void) | undefined;
763
769
  setGlobalHandler(handler: (error: unknown, isFatal?: boolean) => void): void;
764
770
  }
771
+ /** Fuente de promesas rechazadas sin `catch` (en RN, el hub del tracker de Hermes). */
772
+ interface UnhandledRejectionSource {
773
+ addUnhandledListener(listener: (error: unknown) => void): () => void;
774
+ }
765
775
  interface CrashReporterOptions {
766
776
  storage: KeyValueStorage;
767
777
  /** Emite un evento deepdots_app_crash AHORA (app viva). */
@@ -783,6 +793,8 @@ declare class CrashReporter {
783
793
  private windowInstalled;
784
794
  /** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
785
795
  private hookedErrorUtils;
796
+ /** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
797
+ private hookedRejections;
786
798
  constructor(options: CrashReporterOptions);
787
799
  private isEnabled;
788
800
  /** Construye un CrashRecord capturando contexto en el momento del crash. */
@@ -799,6 +811,12 @@ declare class CrashReporter {
799
811
  install(): void;
800
812
  /** Engancha `global.ErrorUtils` de RN (no hay `window`): persiste y encadena al handler previo. Idempotente por instancia de ErrorUtils. */
801
813
  installReactNative(errorUtils: ReactNativeErrorUtils): void;
814
+ /**
815
+ * Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
816
+ * persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
817
+ * Idempotente por fuente.
818
+ */
819
+ installPromiseRejections(source: UnhandledRejectionSource): void;
802
820
  /** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
803
821
  _persistForTest(error: unknown): void;
804
822
  }
@@ -938,6 +956,8 @@ declare class DeepdotsPopups {
938
956
  private lastEngagementAt;
939
957
  /** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
940
958
  private hiddenAt;
959
+ /** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
960
+ private autoTrackErrors;
941
961
  /** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
942
962
  private appStateSubscription;
943
963
  /**
@@ -1072,6 +1092,13 @@ declare class DeepdotsPopups {
1072
1092
  * anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
1073
1093
  * identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
1074
1094
  *
1095
+ * Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
1096
+ * persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
1097
+ * `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
1098
+ * cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
1099
+ * respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
1100
+ * contaba dos veces: una que "abandona" en el login y otra registrada nueva.
1101
+ *
1075
1102
  * Equivale a llamar a `init()` otra vez con otro `userId`.
1076
1103
  */
1077
1104
  setUserId(userId?: string): void;
@@ -1488,7 +1515,7 @@ declare const REVEAL_TIMEOUT_MS = 1200;
1488
1515
  * resolución, para que las tres rutas (popup DOM web, WebView de RN y Compose) digan lo mismo.
1489
1516
  */
1490
1517
  /** Locales con traducción propia. Cualquier otro idioma cae a `en`. */
1491
- type PopupLocale = 'en' | 'es' | 'da' | 'no' | 'sv' | 'fi' | 'de' | 'fr' | 'pt' | 'ar' | 'bn' | 'zh-CN' | 'bg' | 'cs' | 'el' | 'et' | 'ga' | 'hr' | 'hu' | 'it' | 'lt' | 'lv' | 'mt' | 'nl' | 'pl' | 'ro' | 'sk' | 'sl';
1518
+ type PopupLocale = 'en' | 'es' | 'da' | 'no' | 'sv' | 'fi' | 'de' | 'fr' | 'pt' | 'ar' | 'bn' | 'zh-CN' | 'bg' | 'cs' | 'el' | 'et' | 'ga' | 'hr' | 'hu' | 'it' | 'lt' | 'lv' | 'mt' | 'nl' | 'pl' | 'ro' | 'sk' | 'sl' | 'ca';
1492
1519
  interface PopupLabels {
1493
1520
  /** Acción principal: enviar la respuesta. */
1494
1521
  accept: string;
@@ -1613,4 +1640,42 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1613
1640
  */
1614
1641
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1615
1642
 
1616
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, type AutoTrackOptions, BACKGROUND_TASK_MAX_MS, type BackgroundTaskRunner, type BackgroundTimerLike, 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, backgroundTimerTask, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1643
+ /**
1644
+ * Lo que el SDK necesita de React Native para detectar solo el ciclo de vida y el tiempo de
1645
+ * background (DD-55, contrato de detección automática). El core no importa `react-native` (se
1646
+ * usa también en web): lo registra la entrada de React Native del paquete
1647
+ * (`src/index.native.ts`, que Metro elige por la condición `react-native`) y el Provider.
1648
+ */
1649
+
1650
+ /** Opciones de `HermesInternal.enablePromiseRejectionTracker` (las mismas que `promise/rejection-tracking`). */
1651
+ interface RejectionTrackingOptions {
1652
+ allRejections?: boolean;
1653
+ onUnhandled?: (id: number, error: unknown) => void;
1654
+ onHandled?: (id: number, error?: unknown) => void;
1655
+ }
1656
+ /** Lo que el SDK necesita de `global.HermesInternal`. */
1657
+ interface HermesRejectionTrackerLike {
1658
+ enablePromiseRejectionTracker?: (options?: RejectionTrackingOptions) => void;
1659
+ }
1660
+ interface PromiseRejectionHub {
1661
+ /** Avisa de cada promesa rechazada sin `catch`. Devuelve la función que lo quita. */
1662
+ addUnhandledListener(listener: (error: unknown) => void): () => void;
1663
+ }
1664
+ /**
1665
+ * Promesas rechazadas sin `catch` en React Native (contrato de detección automática, paso 2).
1666
+ *
1667
+ * Hermes solo admite UN tracker (`enablePromiseRejectionTracker` sustituye al anterior) y no deja
1668
+ * leer el que hay. Para no quitarle las rejections a Sentry/Crashlytics, la entrada de React
1669
+ * Native envuelve la función al importarse el paquete, que es antes de que el código de la app
1670
+ * llame a `Sentry.init()` (los imports se evalúan primero): lo que instale después cualquiera se
1671
+ * compone con lo nuestro en vez de sustituirlo. Antes del import solo lo pudo instalar React
1672
+ * Native, y solo en desarrollo (el aviso "Possible unhandled promise rejection"), que se mantiene
1673
+ * con `dev`. Mientras el SDK no se engancha, la función envuelta pasa todo tal cual a Hermes.
1674
+ *
1675
+ * Devuelve null sin Hermes o sin el tracker (JSC): el SDK sigue sin capturarlas, como antes.
1676
+ */
1677
+ declare function createHermesRejectionHub(hermes: HermesRejectionTrackerLike | null | undefined, options: {
1678
+ dev: boolean;
1679
+ }): PromiseRejectionHub | null;
1680
+
1681
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, type AutoTrackOptions, BACKGROUND_TASK_MAX_MS, type BackgroundTaskRunner, type BackgroundTimerLike, 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, type HermesRejectionTrackerLike, 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, type PromiseRejectionHub, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type RejectionTrackingOptions, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type SessionStartReason, type TrackMessageOptions, type TriggerConfig, backgroundTimerTask, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, createHermesRejectionHub, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
@@ -308,6 +308,12 @@ interface FeedbackSession {
308
308
  interface AutoTrackOptions {
309
309
  /** React Native: listen to `AppState` for session start/end. Default `true`. */
310
310
  lifecycle?: boolean;
311
+ /**
312
+ * Uncaught errors: `window` `error`/`unhandledrejection` (web), `ErrorUtils` and promise
313
+ * rejections without `catch` under Hermes (React Native). Default `true`. Handlers installed
314
+ * by other tools (Sentry, Crashlytics) keep receiving everything.
315
+ */
316
+ errors?: boolean;
311
317
  }
312
318
  interface DeepdotsInitParams {
313
319
  /** API key for authentication */
@@ -762,6 +768,10 @@ interface ReactNativeErrorUtils {
762
768
  getGlobalHandler?(): ((error: unknown, isFatal?: boolean) => void) | undefined;
763
769
  setGlobalHandler(handler: (error: unknown, isFatal?: boolean) => void): void;
764
770
  }
771
+ /** Fuente de promesas rechazadas sin `catch` (en RN, el hub del tracker de Hermes). */
772
+ interface UnhandledRejectionSource {
773
+ addUnhandledListener(listener: (error: unknown) => void): () => void;
774
+ }
765
775
  interface CrashReporterOptions {
766
776
  storage: KeyValueStorage;
767
777
  /** Emite un evento deepdots_app_crash AHORA (app viva). */
@@ -783,6 +793,8 @@ declare class CrashReporter {
783
793
  private windowInstalled;
784
794
  /** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
785
795
  private hookedErrorUtils;
796
+ /** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
797
+ private hookedRejections;
786
798
  constructor(options: CrashReporterOptions);
787
799
  private isEnabled;
788
800
  /** Construye un CrashRecord capturando contexto en el momento del crash. */
@@ -799,6 +811,12 @@ declare class CrashReporter {
799
811
  install(): void;
800
812
  /** Engancha `global.ErrorUtils` de RN (no hay `window`): persiste y encadena al handler previo. Idempotente por instancia de ErrorUtils. */
801
813
  installReactNative(errorUtils: ReactNativeErrorUtils): void;
814
+ /**
815
+ * Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
816
+ * persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
817
+ * Idempotente por fuente.
818
+ */
819
+ installPromiseRejections(source: UnhandledRejectionSource): void;
802
820
  /** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
803
821
  _persistForTest(error: unknown): void;
804
822
  }
@@ -938,6 +956,8 @@ declare class DeepdotsPopups {
938
956
  private lastEngagementAt;
939
957
  /** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
940
958
  private hiddenAt;
959
+ /** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
960
+ private autoTrackErrors;
941
961
  /** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
942
962
  private appStateSubscription;
943
963
  /**
@@ -1072,6 +1092,13 @@ declare class DeepdotsPopups {
1072
1092
  * anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
1073
1093
  * identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
1074
1094
  *
1095
+ * Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
1096
+ * persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
1097
+ * `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
1098
+ * cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
1099
+ * respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
1100
+ * contaba dos veces: una que "abandona" en el login y otra registrada nueva.
1101
+ *
1075
1102
  * Equivale a llamar a `init()` otra vez con otro `userId`.
1076
1103
  */
1077
1104
  setUserId(userId?: string): void;
@@ -1488,7 +1515,7 @@ declare const REVEAL_TIMEOUT_MS = 1200;
1488
1515
  * resolución, para que las tres rutas (popup DOM web, WebView de RN y Compose) digan lo mismo.
1489
1516
  */
1490
1517
  /** Locales con traducción propia. Cualquier otro idioma cae a `en`. */
1491
- type PopupLocale = 'en' | 'es' | 'da' | 'no' | 'sv' | 'fi' | 'de' | 'fr' | 'pt' | 'ar' | 'bn' | 'zh-CN' | 'bg' | 'cs' | 'el' | 'et' | 'ga' | 'hr' | 'hu' | 'it' | 'lt' | 'lv' | 'mt' | 'nl' | 'pl' | 'ro' | 'sk' | 'sl';
1518
+ type PopupLocale = 'en' | 'es' | 'da' | 'no' | 'sv' | 'fi' | 'de' | 'fr' | 'pt' | 'ar' | 'bn' | 'zh-CN' | 'bg' | 'cs' | 'el' | 'et' | 'ga' | 'hr' | 'hu' | 'it' | 'lt' | 'lv' | 'mt' | 'nl' | 'pl' | 'ro' | 'sk' | 'sl' | 'ca';
1492
1519
  interface PopupLabels {
1493
1520
  /** Acción principal: enviar la respuesta. */
1494
1521
  accept: string;
@@ -1613,4 +1640,42 @@ declare function collectRnDevice(d: DeviceInfoLike): DeviceInfo;
1613
1640
  */
1614
1641
  declare function setupReactNative(sdk: DeepdotsPopups, config: DeepdotsInitParams, deps?: ReactNativeSetupDeps): () => void;
1615
1642
 
1616
- export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, type AutoTrackOptions, BACKGROUND_TASK_MAX_MS, type BackgroundTaskRunner, type BackgroundTimerLike, 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, backgroundTimerTask, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
1643
+ /**
1644
+ * Lo que el SDK necesita de React Native para detectar solo el ciclo de vida y el tiempo de
1645
+ * background (DD-55, contrato de detección automática). El core no importa `react-native` (se
1646
+ * usa también en web): lo registra la entrada de React Native del paquete
1647
+ * (`src/index.native.ts`, que Metro elige por la condición `react-native`) y el Provider.
1648
+ */
1649
+
1650
+ /** Opciones de `HermesInternal.enablePromiseRejectionTracker` (las mismas que `promise/rejection-tracking`). */
1651
+ interface RejectionTrackingOptions {
1652
+ allRejections?: boolean;
1653
+ onUnhandled?: (id: number, error: unknown) => void;
1654
+ onHandled?: (id: number, error?: unknown) => void;
1655
+ }
1656
+ /** Lo que el SDK necesita de `global.HermesInternal`. */
1657
+ interface HermesRejectionTrackerLike {
1658
+ enablePromiseRejectionTracker?: (options?: RejectionTrackingOptions) => void;
1659
+ }
1660
+ interface PromiseRejectionHub {
1661
+ /** Avisa de cada promesa rechazada sin `catch`. Devuelve la función que lo quita. */
1662
+ addUnhandledListener(listener: (error: unknown) => void): () => void;
1663
+ }
1664
+ /**
1665
+ * Promesas rechazadas sin `catch` en React Native (contrato de detección automática, paso 2).
1666
+ *
1667
+ * Hermes solo admite UN tracker (`enablePromiseRejectionTracker` sustituye al anterior) y no deja
1668
+ * leer el que hay. Para no quitarle las rejections a Sentry/Crashlytics, la entrada de React
1669
+ * Native envuelve la función al importarse el paquete, que es antes de que el código de la app
1670
+ * llame a `Sentry.init()` (los imports se evalúan primero): lo que instale después cualquiera se
1671
+ * compone con lo nuestro en vez de sustituirlo. Antes del import solo lo pudo instalar React
1672
+ * Native, y solo en desarrollo (el aviso "Possible unhandled promise rejection"), que se mantiene
1673
+ * con `dev`. Mientras el SDK no se engancha, la función envuelta pasa todo tal cual a Hermes.
1674
+ *
1675
+ * Devuelve null sin Hermes o sin el tracker (JSC): el SDK sigue sin capturarlas, como antes.
1676
+ */
1677
+ declare function createHermesRejectionHub(hermes: HermesRejectionTrackerLike | null | undefined, options: {
1678
+ dev: boolean;
1679
+ }): PromiseRejectionHub | null;
1680
+
1681
+ export { type AnalyticsFeedbackBody, type AnalyticsKeys, type AppStateLike, type AutoTrackOptions, BACKGROUND_TASK_MAX_MS, type BackgroundTaskRunner, type BackgroundTimerLike, 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, type HermesRejectionTrackerLike, 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, type PromiseRejectionHub, REVEAL_TIMEOUT_MS, RTL_LOCALES, type ReactNativeErrorUtils, ReactNativePopupRenderer, type ReactNativeRendererOptions, type ReactNativeSetupDeps, type ReactNativeSurveyPayload, type RejectionTrackingOptions, type ReportErrorOptions, type ResolvedActionLabels, SUPPORTED_LANGUAGES, type SessionEndReason, type SessionStartReason, type TrackMessageOptions, type TriggerConfig, backgroundTimerTask, buildAnalyticsFeedbackBody, buildMessageParams, buildSurveyHtml, collectRnDevice, crashRecordToParams, createDefaultRenderer, createFeedbackSink, createHermesRejectionHub, directionFor, getLabels, isRtlLanguage, mmkvStorage, resolveActionLabels, resolveLocale, setupReactNative };
@@ -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.19.0";
41
+ SDK_VERSION = "1.20.0";
42
42
  SDK_IDENTIFIER = `${"react-native"}@${SDK_VERSION}`;
43
43
  POPUP_CHANNEL = "popup";
44
44
  }
@@ -307,6 +307,8 @@ function resolveLocale(lang) {
307
307
  return "sk";
308
308
  case "sl":
309
309
  return "sl";
310
+ case "ca":
311
+ return "ca";
310
312
  default:
311
313
  return "en";
312
314
  }
@@ -334,7 +336,7 @@ function resolveActionLabels(actions, lang) {
334
336
  back: pick(actions?.back?.label, labels.back)
335
337
  };
336
338
  }
337
- var EN, ES, DA, NO, SV, FI, DE, FR, PT, AR, BN, ZH_CN, BG, CS, EL, ET, GA, HR, HU, IT, LT, LV, MT, NL, PL, RO, SK, SL, LABELS, SUPPORTED_LANGUAGES, RTL_LOCALES, RESOLVE_LOCALE_JS;
339
+ var EN, ES, DA, NO, SV, FI, DE, FR, PT, AR, BN, ZH_CN, BG, CS, EL, ET, GA, HR, HU, IT, LT, LV, MT, NL, PL, RO, SK, SL, CA, LABELS, SUPPORTED_LANGUAGES, RTL_LOCALES, RESOLVE_LOCALE_JS;
338
340
  var init_labels = __esm({
339
341
  "src/i18n/labels.ts"() {
340
342
  "use strict";
@@ -786,6 +788,22 @@ var init_labels = __esm({
786
788
  errorSubmit: "Pri po\u0161iljanju je pri\u0161lo do napake. Poskusite znova ali zaprite okno.",
787
789
  errorLoad: "Ankete ni bilo mogo\u010De nalo\u017Eiti."
788
790
  };
791
+ CA = {
792
+ accept: "Envia",
793
+ decline: "Cancel\xB7la",
794
+ start: "Comen\xE7a l'enquesta",
795
+ complete: "Completa l'enquesta",
796
+ back: "Enrere",
797
+ question: "Pregunta",
798
+ of: "de",
799
+ followUp: "Seguiment",
800
+ closeAria: "Tanca la finestra emergent",
801
+ loadingAria: "S'est\xE0 carregant l'enquesta",
802
+ errorRequired: "Respon la pregunta obligat\xF2ria per continuar.",
803
+ errorInvalidEmail: "Introdueix una adre\xE7a de correu electr\xF2nic v\xE0lida.",
804
+ errorSubmit: "S'ha produ\xEFt un error en enviar. Torna-ho a provar o tanca la finestra.",
805
+ errorLoad: "No s'ha pogut carregar l'enquesta."
806
+ };
789
807
  LABELS = {
790
808
  en: EN,
791
809
  es: ES,
@@ -814,7 +832,8 @@ var init_labels = __esm({
814
832
  pl: PL,
815
833
  ro: RO,
816
834
  sk: SK,
817
- sl: SL
835
+ sl: SL,
836
+ ca: CA
818
837
  };
819
838
  SUPPORTED_LANGUAGES = [
820
839
  // Los 11 idiomas que la plataforma ofrece para un survey, más zh-CN (que el SDK nativo ya
@@ -849,7 +868,9 @@ var init_labels = __esm({
849
868
  "pl",
850
869
  "ro",
851
870
  "sk",
852
- "sl"
871
+ "sl",
872
+ // Catalán (no oficial de la UE).
873
+ "ca"
853
874
  ];
854
875
  RTL_LOCALES = ["ar"];
855
876
  RESOLVE_LOCALE_JS = `function ddResolveLocale(lang){
@@ -885,6 +906,7 @@ var init_labels = __esm({
885
906
  if(p==='ro') return 'ro';
886
907
  if(p==='sk') return 'sk';
887
908
  if(p==='sl') return 'sl';
909
+ if(p==='ca') return 'ca';
888
910
  return 'en';
889
911
  }`;
890
912
  }
@@ -11969,6 +11991,7 @@ __export(index_native_exports, {
11969
11991
  crashRecordToParams: () => crashRecordToParams,
11970
11992
  createDefaultRenderer: () => createDefaultRenderer,
11971
11993
  createFeedbackSink: () => createFeedbackSink,
11994
+ createHermesRejectionHub: () => createHermesRejectionHub,
11972
11995
  directionFor: () => directionFor,
11973
11996
  getLabels: () => getLabels,
11974
11997
  isRtlLanguage: () => isRtlLanguage,
@@ -12009,6 +12032,68 @@ function resolveBackgroundTask(explicit, platform) {
12009
12032
  }
12010
12033
  return void 0;
12011
12034
  }
12035
+ var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
12036
+ function createHermesRejectionHub(hermes, options) {
12037
+ if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
12038
+ const original = hermes.enablePromiseRejectionTracker.bind(hermes);
12039
+ const listeners = /* @__PURE__ */ new Set();
12040
+ let hostOptions = null;
12041
+ let active2 = false;
12042
+ const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
12043
+ const apply = () => {
12044
+ original({
12045
+ allRejections: true,
12046
+ onUnhandled: (id, error) => {
12047
+ listeners.forEach((listener) => {
12048
+ try {
12049
+ listener(error);
12050
+ } catch {
12051
+ }
12052
+ });
12053
+ if (hostOptions?.onUnhandled) {
12054
+ if (forwardsToHost(error)) hostOptions.onUnhandled(id, error);
12055
+ } else if (options.dev) {
12056
+ console.warn(`Possible unhandled promise rejection (id: ${id}):`, error);
12057
+ }
12058
+ },
12059
+ onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
12060
+ });
12061
+ };
12062
+ hermes.enablePromiseRejectionTracker = (next) => {
12063
+ hostOptions = next ?? null;
12064
+ if (active2) apply();
12065
+ else original(next);
12066
+ };
12067
+ return {
12068
+ addUnhandledListener(listener) {
12069
+ listeners.add(listener);
12070
+ if (!active2) {
12071
+ active2 = true;
12072
+ apply();
12073
+ }
12074
+ return () => {
12075
+ listeners.delete(listener);
12076
+ };
12077
+ }
12078
+ };
12079
+ }
12080
+
12081
+ // src/platform/react-native-defaults.ts
12082
+ var hub;
12083
+ function registerReactNativeDefaults(rn) {
12084
+ if (hub === void 0) {
12085
+ hub = getReactNativePlatform()?.promiseRejections ?? createHermesRejectionHub(
12086
+ globalThis.HermesInternal,
12087
+ { dev: typeof __DEV__ !== "undefined" && !!__DEV__ }
12088
+ );
12089
+ }
12090
+ registerReactNativePlatform({
12091
+ os: rn.Platform.OS,
12092
+ appState: rn.AppState,
12093
+ backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
12094
+ promiseRejections: hub
12095
+ });
12096
+ }
12012
12097
 
12013
12098
  // src/types/index.ts
12014
12099
  var POPUP_TRIGGER_CONDITION_STATUSES = [
@@ -13979,6 +14064,8 @@ var CrashReporter = class {
13979
14064
  this.windowInstalled = false;
13980
14065
  /** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
13981
14066
  this.hookedErrorUtils = /* @__PURE__ */ new Set();
14067
+ /** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
14068
+ this.hookedRejections = /* @__PURE__ */ new Set();
13982
14069
  this.options = options;
13983
14070
  this.now = options.now ?? (() => Date.now());
13984
14071
  }
@@ -14078,6 +14165,18 @@ var CrashReporter = class {
14078
14165
  previous?.(error, isFatal);
14079
14166
  });
14080
14167
  }
14168
+ /**
14169
+ * Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
14170
+ * persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
14171
+ * Idempotente por fuente.
14172
+ */
14173
+ installPromiseRejections(source) {
14174
+ if (this.hookedRejections.has(source)) return;
14175
+ this.hookedRejections.add(source);
14176
+ source.addUnhandledListener((error) => {
14177
+ if (this.isEnabled()) this.captureUnhandled(error ?? "unhandledrejection");
14178
+ });
14179
+ }
14081
14180
  /** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
14082
14181
  _persistForTest(error) {
14083
14182
  this.captureUnhandled(error);
@@ -14319,6 +14418,8 @@ var DeepdotsPopups = class {
14319
14418
  this.lastEngagementAt = 0;
14320
14419
  /** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
14321
14420
  this.hiddenAt = null;
14421
+ /** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
14422
+ this.autoTrackErrors = true;
14322
14423
  /** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
14323
14424
  this.appStateSubscription = void 0;
14324
14425
  /**
@@ -14365,6 +14466,7 @@ var DeepdotsPopups = class {
14365
14466
  this.surveyCss = config.surveyCss;
14366
14467
  this.cspNonce = config.cspNonce;
14367
14468
  this.onFeedbackSession = config.onFeedbackSession;
14469
+ this.autoTrackErrors = config.autoTrack?.errors !== false;
14368
14470
  this.config = {
14369
14471
  apiKey: config.apiKey || void 0,
14370
14472
  debug: config.debug || false,
@@ -14563,11 +14665,14 @@ var DeepdotsPopups = class {
14563
14665
  */
14564
14666
  installCrashHandlers() {
14565
14667
  if (!this.crashReporter || !this.tracking?.isTrackingEnabled()) return;
14566
- this.crashReporter.install();
14567
- const errorUtils = this.rnErrorUtils ?? globalThis.ErrorUtils;
14668
+ const auto = this.autoTrackErrors;
14669
+ if (auto) this.crashReporter.install();
14670
+ const errorUtils = this.rnErrorUtils ?? (auto ? globalThis.ErrorUtils : void 0);
14568
14671
  if (errorUtils && typeof errorUtils.setGlobalHandler === "function") {
14569
14672
  this.crashReporter.installReactNative(errorUtils);
14570
14673
  }
14674
+ const rejections = auto ? getReactNativePlatform()?.promiseRejections : null;
14675
+ if (rejections) this.crashReporter.installPromiseRejections(rejections);
14571
14676
  }
14572
14677
  /**
14573
14678
  * Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
@@ -14713,11 +14818,24 @@ var DeepdotsPopups = class {
14713
14818
  * anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
14714
14819
  * identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
14715
14820
  *
14821
+ * Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
14822
+ * persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
14823
+ * `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
14824
+ * cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
14825
+ * respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
14826
+ * contaba dos veces: una que "abandona" en el login y otra registrada nueva.
14827
+ *
14716
14828
  * Equivale a llamar a `init()` otra vez con otro `userId`.
14717
14829
  */
14718
14830
  setUserId(userId) {
14719
14831
  const next = userId || void 0;
14720
14832
  if (!this.initialized || !this.config || next === this.config.userId) return;
14833
+ const identifying = !this.config.userId && !!next;
14834
+ const previous = identifying ? {
14835
+ identified: true,
14836
+ previous_user_id: this.tracking?.getUserId() ?? void 0,
14837
+ previous_session_id: this.analyticsFeedbackSessionId
14838
+ } : void 0;
14721
14839
  this.closeSession("user_change");
14722
14840
  const enabled = this.tracking?.isTrackingEnabled() ?? true;
14723
14841
  const storage = this.storage ?? createDefaultStorage();
@@ -14730,13 +14848,18 @@ var DeepdotsPopups = class {
14730
14848
  post: (body) => this.postContact(body)
14731
14849
  }) : null;
14732
14850
  this.analytics?.resetUserScope();
14733
- this.messageGuard.reset();
14734
- this.lastShown.clear();
14735
- this.surveyProgress.clear();
14736
- this.answeredSurveys.clear();
14737
- clearPopupState(storage);
14738
- this.log("tracking \xB7 user_change \xB7 user_id:", this.tracking.getUserId());
14739
- this.openSession("user_change");
14851
+ if (!identifying) {
14852
+ this.messageGuard.reset();
14853
+ this.lastShown.clear();
14854
+ this.surveyProgress.clear();
14855
+ this.answeredSurveys.clear();
14856
+ clearPopupState(storage);
14857
+ }
14858
+ this.log(
14859
+ identifying ? "tracking \xB7 user identified \xB7 user_id:" : "tracking \xB7 user_change \xB7 user_id:",
14860
+ this.tracking.getUserId()
14861
+ );
14862
+ this.openSession("user_change", previous);
14740
14863
  }
14741
14864
  /**
14742
14865
  * Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
@@ -14772,14 +14895,14 @@ var DeepdotsPopups = class {
14772
14895
  * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
14773
14896
  * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
14774
14897
  */
14775
- openSession(reason) {
14898
+ openSession(reason, extra) {
14776
14899
  if (this.sessionOpen) return;
14777
14900
  if (!this.tracking?.isTrackingEnabled()) return;
14778
14901
  const suspendedMs = this.takeSuspendedSession();
14779
14902
  this.sessionOpen = true;
14780
14903
  this.lastEngagementAt = Date.now();
14781
14904
  if (suspendedMs === null) {
14782
- this.track("deepdots_session_start", { reason });
14905
+ this.track("deepdots_session_start", { reason, ...extra });
14783
14906
  } else {
14784
14907
  this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
14785
14908
  this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
@@ -15845,9 +15968,5 @@ function setupReactNative(sdk, config, deps = {}) {
15845
15968
  }
15846
15969
 
15847
15970
  // src/index.native.ts
15848
- registerReactNativePlatform({
15849
- os: import_react_native.Platform.OS,
15850
- appState: import_react_native.AppState,
15851
- backgroundTaskModule: import_react_native.NativeModules?.DeepdotsBackgroundTask ?? null
15852
- });
15971
+ registerReactNativeDefaults({ AppState: import_react_native.AppState, NativeModules: import_react_native.NativeModules, Platform: import_react_native.Platform });
15853
15972
  //# sourceMappingURL=index.native.js.map