@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
package/dist/index.d.ts CHANGED
@@ -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 };
package/dist/index.js CHANGED
@@ -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 = `${"web"}@${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_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,
@@ -13948,6 +13971,8 @@ var CrashReporter = class {
13948
13971
  this.windowInstalled = false;
13949
13972
  /** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
13950
13973
  this.hookedErrorUtils = /* @__PURE__ */ new Set();
13974
+ /** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
13975
+ this.hookedRejections = /* @__PURE__ */ new Set();
13951
13976
  this.options = options;
13952
13977
  this.now = options.now ?? (() => Date.now());
13953
13978
  }
@@ -14047,6 +14072,18 @@ var CrashReporter = class {
14047
14072
  previous?.(error, isFatal);
14048
14073
  });
14049
14074
  }
14075
+ /**
14076
+ * Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
14077
+ * persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
14078
+ * Idempotente por fuente.
14079
+ */
14080
+ installPromiseRejections(source) {
14081
+ if (this.hookedRejections.has(source)) return;
14082
+ this.hookedRejections.add(source);
14083
+ source.addUnhandledListener((error) => {
14084
+ if (this.isEnabled()) this.captureUnhandled(error ?? "unhandledrejection");
14085
+ });
14086
+ }
14050
14087
  /** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
14051
14088
  _persistForTest(error) {
14052
14089
  this.captureUnhandled(error);
@@ -14151,6 +14188,51 @@ function resolveBackgroundTask(explicit, platform) {
14151
14188
  }
14152
14189
  return void 0;
14153
14190
  }
14191
+ var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
14192
+ function createHermesRejectionHub(hermes, options) {
14193
+ if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
14194
+ const original = hermes.enablePromiseRejectionTracker.bind(hermes);
14195
+ const listeners = /* @__PURE__ */ new Set();
14196
+ let hostOptions = null;
14197
+ let active2 = false;
14198
+ const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
14199
+ const apply = () => {
14200
+ original({
14201
+ allRejections: true,
14202
+ onUnhandled: (id, error) => {
14203
+ listeners.forEach((listener) => {
14204
+ try {
14205
+ listener(error);
14206
+ } catch {
14207
+ }
14208
+ });
14209
+ if (hostOptions?.onUnhandled) {
14210
+ if (forwardsToHost(error)) hostOptions.onUnhandled(id, error);
14211
+ } else if (options.dev) {
14212
+ console.warn(`Possible unhandled promise rejection (id: ${id}):`, error);
14213
+ }
14214
+ },
14215
+ onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
14216
+ });
14217
+ };
14218
+ hermes.enablePromiseRejectionTracker = (next) => {
14219
+ hostOptions = next ?? null;
14220
+ if (active2) apply();
14221
+ else original(next);
14222
+ };
14223
+ return {
14224
+ addUnhandledListener(listener) {
14225
+ listeners.add(listener);
14226
+ if (!active2) {
14227
+ active2 = true;
14228
+ apply();
14229
+ }
14230
+ return () => {
14231
+ listeners.delete(listener);
14232
+ };
14233
+ }
14234
+ };
14235
+ }
14154
14236
 
14155
14237
  // src/analytics/messaging.ts
14156
14238
  var MESSAGE_CHANNELS = ["push", "in_app"];
@@ -14315,6 +14397,8 @@ var DeepdotsPopups = class {
14315
14397
  this.lastEngagementAt = 0;
14316
14398
  /** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
14317
14399
  this.hiddenAt = null;
14400
+ /** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
14401
+ this.autoTrackErrors = true;
14318
14402
  /** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
14319
14403
  this.appStateSubscription = void 0;
14320
14404
  /**
@@ -14361,6 +14445,7 @@ var DeepdotsPopups = class {
14361
14445
  this.surveyCss = config.surveyCss;
14362
14446
  this.cspNonce = config.cspNonce;
14363
14447
  this.onFeedbackSession = config.onFeedbackSession;
14448
+ this.autoTrackErrors = config.autoTrack?.errors !== false;
14364
14449
  this.config = {
14365
14450
  apiKey: config.apiKey || void 0,
14366
14451
  debug: config.debug || false,
@@ -14559,11 +14644,14 @@ var DeepdotsPopups = class {
14559
14644
  */
14560
14645
  installCrashHandlers() {
14561
14646
  if (!this.crashReporter || !this.tracking?.isTrackingEnabled()) return;
14562
- this.crashReporter.install();
14563
- const errorUtils = this.rnErrorUtils ?? globalThis.ErrorUtils;
14647
+ const auto = this.autoTrackErrors;
14648
+ if (auto) this.crashReporter.install();
14649
+ const errorUtils = this.rnErrorUtils ?? (auto ? globalThis.ErrorUtils : void 0);
14564
14650
  if (errorUtils && typeof errorUtils.setGlobalHandler === "function") {
14565
14651
  this.crashReporter.installReactNative(errorUtils);
14566
14652
  }
14653
+ const rejections = auto ? getReactNativePlatform()?.promiseRejections : null;
14654
+ if (rejections) this.crashReporter.installPromiseRejections(rejections);
14567
14655
  }
14568
14656
  /**
14569
14657
  * Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
@@ -14709,11 +14797,24 @@ var DeepdotsPopups = class {
14709
14797
  * anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
14710
14798
  * identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
14711
14799
  *
14800
+ * Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
14801
+ * persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
14802
+ * `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
14803
+ * cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
14804
+ * respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
14805
+ * contaba dos veces: una que "abandona" en el login y otra registrada nueva.
14806
+ *
14712
14807
  * Equivale a llamar a `init()` otra vez con otro `userId`.
14713
14808
  */
14714
14809
  setUserId(userId) {
14715
14810
  const next = userId || void 0;
14716
14811
  if (!this.initialized || !this.config || next === this.config.userId) return;
14812
+ const identifying = !this.config.userId && !!next;
14813
+ const previous = identifying ? {
14814
+ identified: true,
14815
+ previous_user_id: this.tracking?.getUserId() ?? void 0,
14816
+ previous_session_id: this.analyticsFeedbackSessionId
14817
+ } : void 0;
14717
14818
  this.closeSession("user_change");
14718
14819
  const enabled = this.tracking?.isTrackingEnabled() ?? true;
14719
14820
  const storage = this.storage ?? createDefaultStorage();
@@ -14726,13 +14827,18 @@ var DeepdotsPopups = class {
14726
14827
  post: (body) => this.postContact(body)
14727
14828
  }) : null;
14728
14829
  this.analytics?.resetUserScope();
14729
- this.messageGuard.reset();
14730
- this.lastShown.clear();
14731
- this.surveyProgress.clear();
14732
- this.answeredSurveys.clear();
14733
- clearPopupState(storage);
14734
- this.log("tracking \xB7 user_change \xB7 user_id:", this.tracking.getUserId());
14735
- this.openSession("user_change");
14830
+ if (!identifying) {
14831
+ this.messageGuard.reset();
14832
+ this.lastShown.clear();
14833
+ this.surveyProgress.clear();
14834
+ this.answeredSurveys.clear();
14835
+ clearPopupState(storage);
14836
+ }
14837
+ this.log(
14838
+ identifying ? "tracking \xB7 user identified \xB7 user_id:" : "tracking \xB7 user_change \xB7 user_id:",
14839
+ this.tracking.getUserId()
14840
+ );
14841
+ this.openSession("user_change", previous);
14736
14842
  }
14737
14843
  /**
14738
14844
  * Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
@@ -14768,14 +14874,14 @@ var DeepdotsPopups = class {
14768
14874
  * - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
14769
14875
  * Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
14770
14876
  */
14771
- openSession(reason) {
14877
+ openSession(reason, extra) {
14772
14878
  if (this.sessionOpen) return;
14773
14879
  if (!this.tracking?.isTrackingEnabled()) return;
14774
14880
  const suspendedMs = this.takeSuspendedSession();
14775
14881
  this.sessionOpen = true;
14776
14882
  this.lastEngagementAt = Date.now();
14777
14883
  if (suspendedMs === null) {
14778
- this.track("deepdots_session_start", { reason });
14884
+ this.track("deepdots_session_start", { reason, ...extra });
14779
14885
  } else {
14780
14886
  this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
14781
14887
  this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);