@magicfeedback/popup-sdk 1.18.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.
- package/MagicfeedbackPopupSdk.podspec +18 -0
- package/README.md +23 -0
- package/dist/2.2.38-CCK7SF4A.mjs +2343 -0
- package/dist/2.2.38-CCK7SF4A.mjs.map +1 -0
- package/dist/2.2.38-LGZRM7GX.mjs +2343 -0
- package/dist/2.2.38-LGZRM7GX.mjs.map +1 -0
- package/dist/2.2.39-BJJ3YRJ4.mjs +2344 -0
- package/dist/2.2.39-BJJ3YRJ4.mjs.map +1 -0
- package/dist/2.2.39-HPNDYUPP.mjs +2344 -0
- package/dist/2.2.39-HPNDYUPP.mjs.map +1 -0
- package/dist/assets/assets/style.css +107 -1
- package/dist/assets/assets/survey-css/2.2.38.css +2335 -0
- package/dist/assets/assets/survey-css/2.2.39.css +2336 -0
- package/dist/chunk-3QS3WKRC.mjs +31 -0
- package/dist/chunk-3QS3WKRC.mjs.map +1 -0
- package/dist/chunk-BJTO5JO5.mjs +11 -0
- package/dist/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/{chunk-DNBFTJCA.mjs → chunk-FROREHRG.mjs} +516 -52
- package/dist/chunk-FROREHRG.mjs.map +1 -0
- package/dist/{chunk-7ZVOPIWE.mjs → chunk-OPR5I7WO.mjs} +557 -11
- package/dist/chunk-OPR5I7WO.mjs.map +1 -0
- package/dist/chunk-ZJ5HG3QF.mjs +3357 -0
- package/dist/chunk-ZJ5HG3QF.mjs.map +1 -0
- package/dist/index.d.mts +217 -9
- package/dist/index.d.ts +217 -9
- package/dist/index.js +7253 -1519
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +389 -49
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +1681 -0
- package/dist/index.native.d.ts +1681 -0
- package/dist/index.native.js +15972 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.native.mjs +4011 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/react-native.d.mts +113 -7
- package/dist/react-native.d.ts +113 -7
- package/dist/react-native.js +5846 -162
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +396 -51
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-B6VIV4VS.mjs → renderPopup-I6CPIR75.mjs} +133 -6
- package/dist/renderPopup-I6CPIR75.mjs.map +1 -0
- package/dist/renderPopup-RUY3OBYV.mjs +3847 -0
- package/dist/renderPopup-RUY3OBYV.mjs.map +1 -0
- package/dist/renderPopup-XNVNP2ZU.mjs +3847 -0
- package/dist/renderPopup-XNVNP2ZU.mjs.map +1 -0
- package/ios/DeepdotsBackgroundTask.m +71 -0
- package/package.json +14 -5
- package/react-native.config.js +9 -0
- package/dist/chunk-7ZVOPIWE.mjs.map +0 -1
- package/dist/chunk-DNBFTJCA.mjs.map +0 -1
- package/dist/renderPopup-B6VIV4VS.mjs.map +0 -1
- package/dist/renderPopup-BKZPAZZG.mjs +0 -3682
- package/dist/renderPopup-BKZPAZZG.mjs.map +0 -1
package/dist/react-native.d.mts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Tiempo de ejecución en segundo plano para los envíos de analytics (DD-55).
|
|
5
|
+
*
|
|
6
|
+
* En iOS la app se suspende pocos segundos después de pasar a background. Si el POST con el
|
|
7
|
+
* cierre de la sesión sigue en vuelo, no termina hasta que el usuario vuelve a abrir la app
|
|
8
|
+
* (medido en producción con React Native, nov 2026: una de cada tres sesiones iOS se cerraba tarde o nunca, frente
|
|
9
|
+
* a ~2 % en Android). iOS concede más tiempo si la app lo pide (`beginBackgroundTask`), pero
|
|
10
|
+
* eso es una API nativa: el SDK es JS puro, así que el host le pasa una función que la abre.
|
|
11
|
+
*
|
|
12
|
+
* Contrato (igual que `beginBackgroundTask` del SDK nativo): `begin(name)` abre una tarea y
|
|
13
|
+
* devuelve la función que la cierra. Puede llamarse varias veces a la vez.
|
|
14
|
+
*/
|
|
15
|
+
type BackgroundTaskRunner = (name: string) => () => void;
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* Identidad + sesión para el tracking de navegación (Fase 1).
|
|
5
19
|
* Implementa el "Contrato común Web+KMP".
|
|
@@ -71,6 +85,8 @@ interface AnalyticsEnvelope {
|
|
|
71
85
|
sessionId: string | null;
|
|
72
86
|
context: {
|
|
73
87
|
platform: string;
|
|
88
|
+
/** SDK que produce la analítica, `<plataforma>@<versión>` (`deepdots_sdk`). */
|
|
89
|
+
sdk?: string;
|
|
74
90
|
language?: string;
|
|
75
91
|
/** Info de dispositivo (Technology #11–13). */
|
|
76
92
|
device?: DeviceInfo;
|
|
@@ -93,7 +109,7 @@ interface AnalyticsEnvelope {
|
|
|
93
109
|
* `feedback.finished` se queda siempre en `false` (no es la señal de cierre acordada).
|
|
94
110
|
*
|
|
95
111
|
* Encoding:
|
|
96
|
-
* - todo va en `feedback.metadata`: contexto (user_id, session_id, platform…) + eventos
|
|
112
|
+
* - todo va en `feedback.metadata`: contexto (user_id, session_id, platform, sdk…) + eventos
|
|
97
113
|
* - cada entrada usa `value: string[]` (array de un elemento)
|
|
98
114
|
* - eventos: {key: nombre_evento, value: [JSON(timestamp + params)]}
|
|
99
115
|
* - identidad (user_id) → `profile` como `external-user-id`
|
|
@@ -107,10 +123,6 @@ interface AnalyticsKeys {
|
|
|
107
123
|
integration: string;
|
|
108
124
|
}
|
|
109
125
|
|
|
110
|
-
/**
|
|
111
|
-
* Configuration options for initializing the DeepdotsPopups SDK
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
126
|
/**
|
|
115
127
|
* Custom logger to receive the SDK's debug output instead of the console.
|
|
116
128
|
* Only `log` is required; `warn`/`error`/`info` fall back to `log` when omitted.
|
|
@@ -135,6 +147,17 @@ interface FeedbackSession {
|
|
|
135
147
|
sessionId: string;
|
|
136
148
|
status: 'open' | 'closed';
|
|
137
149
|
}
|
|
150
|
+
/** Signals the SDK detects on its own (see `DeepdotsInitParams.autoTrack`). */
|
|
151
|
+
interface AutoTrackOptions {
|
|
152
|
+
/** React Native: listen to `AppState` for session start/end. Default `true`. */
|
|
153
|
+
lifecycle?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Uncaught errors: `window` `error`/`unhandledrejection` (web), `ErrorUtils` and promise
|
|
156
|
+
* rejections without `catch` under Hermes (React Native). Default `true`. Handlers installed
|
|
157
|
+
* by other tools (Sentry, Crashlytics) keep receiving everything.
|
|
158
|
+
*/
|
|
159
|
+
errors?: boolean;
|
|
160
|
+
}
|
|
138
161
|
interface DeepdotsInitParams {
|
|
139
162
|
/** API key for authentication */
|
|
140
163
|
apiKey?: string;
|
|
@@ -164,6 +187,24 @@ interface DeepdotsInitParams {
|
|
|
164
187
|
language?: string;
|
|
165
188
|
/** Injectable device info (RN: from react-native-device-info). If missing, it is derived from the browser. */
|
|
166
189
|
device?: DeviceInfo;
|
|
190
|
+
/**
|
|
191
|
+
* React Native (iOS): opens a native background task while each analytics request is in
|
|
192
|
+
* flight, so the session's closing request finishes after the app goes to background
|
|
193
|
+
* instead of when the user opens the app again. `begin(name)` starts the task and returns
|
|
194
|
+
* the function that ends it (iOS `beginBackgroundTask` / `endBackgroundTask`). The SDK ends
|
|
195
|
+
* it when the request settles, or after 25 s. Use `backgroundTimerTask(BackgroundTimer)`
|
|
196
|
+
* for `react-native-background-timer`, iOS only. Without it, nothing changes: a closing
|
|
197
|
+
* request that does not finish is stored and sent on the next launch.
|
|
198
|
+
*/
|
|
199
|
+
backgroundTask?: BackgroundTaskRunner;
|
|
200
|
+
/**
|
|
201
|
+
* What the SDK detects on its own. Everything is on by default; set a signal to `false` to
|
|
202
|
+
* turn it off. `lifecycle` (React Native): the SDK listens to `AppState` itself
|
|
203
|
+
* (`active` → session start, `inactive` → send pending data, `background` → session end), so
|
|
204
|
+
* the host does not need to call `onForeground` / `onInactive` / `onBackground`. Calling them
|
|
205
|
+
* as well is harmless: nothing is sent twice.
|
|
206
|
+
*/
|
|
207
|
+
autoTrack?: AutoTrackOptions;
|
|
167
208
|
/**
|
|
168
209
|
* Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
|
|
169
210
|
* to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
|
|
@@ -239,6 +280,11 @@ interface TriggerConfig {
|
|
|
239
280
|
surveyId: string;
|
|
240
281
|
/** Optional popup definition id (used to disambiguate repeated survey ids) */
|
|
241
282
|
popupId?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Seconds to wait once the trigger fires before showing the popup ("Delay" in the Admin).
|
|
285
|
+
* For `exit` it is the wait on the next route. 0 or missing = at once.
|
|
286
|
+
*/
|
|
287
|
+
delaySeconds?: number;
|
|
242
288
|
}
|
|
243
289
|
/**
|
|
244
290
|
* Event types emitted by the SDK
|
|
@@ -335,6 +381,13 @@ interface PopupRenderOptions {
|
|
|
335
381
|
* la hoja del survey. No aplica a React Native (el survey vive en su propio WebView).
|
|
336
382
|
*/
|
|
337
383
|
cspNonce?: string;
|
|
384
|
+
/**
|
|
385
|
+
* `surveyFrontend.sdkVersion` del popup (DD-70): versión de `@magicfeedback/native` asignada
|
|
386
|
+
* al survey en el Admin. Se usa si está en el rango soportado y carga; si no, la empaquetada.
|
|
387
|
+
*/
|
|
388
|
+
surveySdkVersion?: string | null;
|
|
389
|
+
/** `init({debug})`, para el log de la versión de survey SDK elegida. */
|
|
390
|
+
debug?: boolean;
|
|
338
391
|
}
|
|
339
392
|
interface PopupRenderer {
|
|
340
393
|
/** Preparar recursos si aplica */
|
|
@@ -436,6 +489,10 @@ declare class DeepdotsPopups {
|
|
|
436
489
|
private lastShown;
|
|
437
490
|
private surveyToPopupId;
|
|
438
491
|
private deferredExitTimers;
|
|
492
|
+
/** Popups esperando su `delaySeconds` (uno por popup). */
|
|
493
|
+
private delayedPopups;
|
|
494
|
+
/** Última pantalla de `setScreen` (React Native). */
|
|
495
|
+
private currentScreen;
|
|
439
496
|
private baseUrl;
|
|
440
497
|
private env;
|
|
441
498
|
/** Si el SDK pinta el "modal" del popup (RN). Default true; false = el host lo envuelve. */
|
|
@@ -481,6 +538,10 @@ declare class DeepdotsPopups {
|
|
|
481
538
|
private lastEngagementAt;
|
|
482
539
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
483
540
|
private hiddenAt;
|
|
541
|
+
/** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
|
|
542
|
+
private autoTrackErrors;
|
|
543
|
+
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
544
|
+
private appStateSubscription;
|
|
484
545
|
/**
|
|
485
546
|
* Sesión suspendida por un `pagehide` (ms epoch y `deepdots_user_id`); null si no hay.
|
|
486
547
|
* `openSession` la reanuda si sigue a tiempo (ver ANALYTICS_RESUME_WINDOW_MS).
|
|
@@ -587,6 +648,22 @@ declare class DeepdotsPopups {
|
|
|
587
648
|
* Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
|
|
588
649
|
*/
|
|
589
650
|
onBackground(): void;
|
|
651
|
+
/**
|
|
652
|
+
* App a `inactive` (RN, iOS: centro de control, llamada, app switcher, y SIEMPRE justo antes
|
|
653
|
+
* de `background`). NO cierra la sesión (es transitorio), pero envía lo acumulado con un
|
|
654
|
+
* `user_engagement` que lleva la pantalla en curso, como web al ocultar la pestaña: si el
|
|
655
|
+
* lote de cierre de `background` no llega a salir (iOS suspende la app), el backend ya
|
|
656
|
+
* tiene el tiempo activo y la última pantalla. El contador sigue en marcha.
|
|
657
|
+
*/
|
|
658
|
+
onInactive(): void;
|
|
659
|
+
/**
|
|
660
|
+
* Ciclo de vida automático en React Native (contrato de detección automática): el SDK escucha
|
|
661
|
+
* AppState él mismo, así que el host no tiene que llamar a `onForeground`/`onInactive`/
|
|
662
|
+
* `onBackground`. Si el host los llama además (integraciones anteriores), no se duplica nada:
|
|
663
|
+
* abrir o cerrar una sesión ya abierta o cerrada no hace nada, y el engagement se consume.
|
|
664
|
+
* `autoTrack.lifecycle: false` lo apaga.
|
|
665
|
+
*/
|
|
666
|
+
private installAutoLifecycle;
|
|
590
667
|
/**
|
|
591
668
|
* Cierre EXPLÍCITO de la sesión por parte del host (logout, fin de flujo…): emite
|
|
592
669
|
* `session_end` y envía el último lote con `completed:true`.
|
|
@@ -597,6 +674,13 @@ declare class DeepdotsPopups {
|
|
|
597
674
|
* anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
|
|
598
675
|
* identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
|
|
599
676
|
*
|
|
677
|
+
* Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
|
|
678
|
+
* persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
|
|
679
|
+
* `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
|
|
680
|
+
* cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
|
|
681
|
+
* respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
|
|
682
|
+
* contaba dos veces: una que "abandona" en el login y otra registrada nueva.
|
|
683
|
+
*
|
|
600
684
|
* Equivale a llamar a `init()` otra vez con otro `userId`.
|
|
601
685
|
*/
|
|
602
686
|
setUserId(userId?: string): void;
|
|
@@ -706,11 +790,28 @@ declare class DeepdotsPopups {
|
|
|
706
790
|
configureTriggers(triggers: TriggerConfig[]): void;
|
|
707
791
|
/** Deriva triggers desde las definiciones de popup */
|
|
708
792
|
private configureTriggersFromDefinitions;
|
|
709
|
-
/**
|
|
710
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Lógica para evaluar condiciones antes de mostrar una encuesta. `options.delaySeconds`
|
|
795
|
+
* (lo pasan los triggers time/scroll/click con el "Delay" del Admin) espera ese tiempo y
|
|
796
|
+
* vuelve a evaluar antes de mostrar; sin él, al momento como siempre.
|
|
797
|
+
*/
|
|
798
|
+
triggerSurvey(surveyId: string, popupId?: string, options?: {
|
|
799
|
+
delaySeconds?: number;
|
|
800
|
+
}): void;
|
|
711
801
|
/** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
|
|
712
802
|
triggerEvent(eventName: string): void;
|
|
713
803
|
private evaluateEvent;
|
|
804
|
+
/**
|
|
805
|
+
* Muestra `def` ya, o tras su "Delay (seconds)" del Admin. Mientras espera:
|
|
806
|
+
* - el mismo popup no se programa dos veces (el primer vencimiento manda);
|
|
807
|
+
* - cambiar de ruta/pantalla o pasar a background lo cancela;
|
|
808
|
+
* y al vencer se vuelve a evaluar todo (segmentos, idioma, cooldowns) como un disparo nuevo.
|
|
809
|
+
* Si entonces hay otro popup abierto, `showDefinition` lo salta sin efectos, igual que hoy.
|
|
810
|
+
*/
|
|
811
|
+
private showAfterDelay;
|
|
812
|
+
private showDelayedPopup;
|
|
813
|
+
private cancelDelayedPopups;
|
|
814
|
+
private currentHref;
|
|
714
815
|
/**
|
|
715
816
|
* Guarda `trigger` si las definiciones aún no han llegado. Devuelve `true` si lo guardó (el
|
|
716
817
|
* llamador no debe evaluarlo ahora) y `false` si no hay carga en vuelo (se evalúa ya, como
|
|
@@ -851,6 +952,11 @@ interface ReactNativeSetupDeps {
|
|
|
851
952
|
renderer?: PopupRenderer;
|
|
852
953
|
/** `global.ErrorUtils` de RN (para capturar errores JS no manejados). Default: `globalThis.ErrorUtils`. */
|
|
853
954
|
errorUtils?: ReactNativeErrorUtils | null;
|
|
955
|
+
/**
|
|
956
|
+
* Background task nativa para los envíos (iOS, DD-55). Si `config.backgroundTask` viene, gana
|
|
957
|
+
* ese. Para `react-native-background-timer`: `backgroundTimerTask(BackgroundTimer)`.
|
|
958
|
+
*/
|
|
959
|
+
backgroundTask?: BackgroundTaskRunner | null;
|
|
854
960
|
}
|
|
855
961
|
/**
|
|
856
962
|
* Configura el SDK para React Native en una sola llamada: storage persistente (MMKV),
|
package/dist/react-native.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Tiempo de ejecución en segundo plano para los envíos de analytics (DD-55).
|
|
5
|
+
*
|
|
6
|
+
* En iOS la app se suspende pocos segundos después de pasar a background. Si el POST con el
|
|
7
|
+
* cierre de la sesión sigue en vuelo, no termina hasta que el usuario vuelve a abrir la app
|
|
8
|
+
* (medido en producción con React Native, nov 2026: una de cada tres sesiones iOS se cerraba tarde o nunca, frente
|
|
9
|
+
* a ~2 % en Android). iOS concede más tiempo si la app lo pide (`beginBackgroundTask`), pero
|
|
10
|
+
* eso es una API nativa: el SDK es JS puro, así que el host le pasa una función que la abre.
|
|
11
|
+
*
|
|
12
|
+
* Contrato (igual que `beginBackgroundTask` del SDK nativo): `begin(name)` abre una tarea y
|
|
13
|
+
* devuelve la función que la cierra. Puede llamarse varias veces a la vez.
|
|
14
|
+
*/
|
|
15
|
+
type BackgroundTaskRunner = (name: string) => () => void;
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* Identidad + sesión para el tracking de navegación (Fase 1).
|
|
5
19
|
* Implementa el "Contrato común Web+KMP".
|
|
@@ -71,6 +85,8 @@ interface AnalyticsEnvelope {
|
|
|
71
85
|
sessionId: string | null;
|
|
72
86
|
context: {
|
|
73
87
|
platform: string;
|
|
88
|
+
/** SDK que produce la analítica, `<plataforma>@<versión>` (`deepdots_sdk`). */
|
|
89
|
+
sdk?: string;
|
|
74
90
|
language?: string;
|
|
75
91
|
/** Info de dispositivo (Technology #11–13). */
|
|
76
92
|
device?: DeviceInfo;
|
|
@@ -93,7 +109,7 @@ interface AnalyticsEnvelope {
|
|
|
93
109
|
* `feedback.finished` se queda siempre en `false` (no es la señal de cierre acordada).
|
|
94
110
|
*
|
|
95
111
|
* Encoding:
|
|
96
|
-
* - todo va en `feedback.metadata`: contexto (user_id, session_id, platform…) + eventos
|
|
112
|
+
* - todo va en `feedback.metadata`: contexto (user_id, session_id, platform, sdk…) + eventos
|
|
97
113
|
* - cada entrada usa `value: string[]` (array de un elemento)
|
|
98
114
|
* - eventos: {key: nombre_evento, value: [JSON(timestamp + params)]}
|
|
99
115
|
* - identidad (user_id) → `profile` como `external-user-id`
|
|
@@ -107,10 +123,6 @@ interface AnalyticsKeys {
|
|
|
107
123
|
integration: string;
|
|
108
124
|
}
|
|
109
125
|
|
|
110
|
-
/**
|
|
111
|
-
* Configuration options for initializing the DeepdotsPopups SDK
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
126
|
/**
|
|
115
127
|
* Custom logger to receive the SDK's debug output instead of the console.
|
|
116
128
|
* Only `log` is required; `warn`/`error`/`info` fall back to `log` when omitted.
|
|
@@ -135,6 +147,17 @@ interface FeedbackSession {
|
|
|
135
147
|
sessionId: string;
|
|
136
148
|
status: 'open' | 'closed';
|
|
137
149
|
}
|
|
150
|
+
/** Signals the SDK detects on its own (see `DeepdotsInitParams.autoTrack`). */
|
|
151
|
+
interface AutoTrackOptions {
|
|
152
|
+
/** React Native: listen to `AppState` for session start/end. Default `true`. */
|
|
153
|
+
lifecycle?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Uncaught errors: `window` `error`/`unhandledrejection` (web), `ErrorUtils` and promise
|
|
156
|
+
* rejections without `catch` under Hermes (React Native). Default `true`. Handlers installed
|
|
157
|
+
* by other tools (Sentry, Crashlytics) keep receiving everything.
|
|
158
|
+
*/
|
|
159
|
+
errors?: boolean;
|
|
160
|
+
}
|
|
138
161
|
interface DeepdotsInitParams {
|
|
139
162
|
/** API key for authentication */
|
|
140
163
|
apiKey?: string;
|
|
@@ -164,6 +187,24 @@ interface DeepdotsInitParams {
|
|
|
164
187
|
language?: string;
|
|
165
188
|
/** Injectable device info (RN: from react-native-device-info). If missing, it is derived from the browser. */
|
|
166
189
|
device?: DeviceInfo;
|
|
190
|
+
/**
|
|
191
|
+
* React Native (iOS): opens a native background task while each analytics request is in
|
|
192
|
+
* flight, so the session's closing request finishes after the app goes to background
|
|
193
|
+
* instead of when the user opens the app again. `begin(name)` starts the task and returns
|
|
194
|
+
* the function that ends it (iOS `beginBackgroundTask` / `endBackgroundTask`). The SDK ends
|
|
195
|
+
* it when the request settles, or after 25 s. Use `backgroundTimerTask(BackgroundTimer)`
|
|
196
|
+
* for `react-native-background-timer`, iOS only. Without it, nothing changes: a closing
|
|
197
|
+
* request that does not finish is stored and sent on the next launch.
|
|
198
|
+
*/
|
|
199
|
+
backgroundTask?: BackgroundTaskRunner;
|
|
200
|
+
/**
|
|
201
|
+
* What the SDK detects on its own. Everything is on by default; set a signal to `false` to
|
|
202
|
+
* turn it off. `lifecycle` (React Native): the SDK listens to `AppState` itself
|
|
203
|
+
* (`active` → session start, `inactive` → send pending data, `background` → session end), so
|
|
204
|
+
* the host does not need to call `onForeground` / `onInactive` / `onBackground`. Calling them
|
|
205
|
+
* as well is harmless: nothing is sent twice.
|
|
206
|
+
*/
|
|
207
|
+
autoTrack?: AutoTrackOptions;
|
|
167
208
|
/**
|
|
168
209
|
* Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
|
|
169
210
|
* to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
|
|
@@ -239,6 +280,11 @@ interface TriggerConfig {
|
|
|
239
280
|
surveyId: string;
|
|
240
281
|
/** Optional popup definition id (used to disambiguate repeated survey ids) */
|
|
241
282
|
popupId?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Seconds to wait once the trigger fires before showing the popup ("Delay" in the Admin).
|
|
285
|
+
* For `exit` it is the wait on the next route. 0 or missing = at once.
|
|
286
|
+
*/
|
|
287
|
+
delaySeconds?: number;
|
|
242
288
|
}
|
|
243
289
|
/**
|
|
244
290
|
* Event types emitted by the SDK
|
|
@@ -335,6 +381,13 @@ interface PopupRenderOptions {
|
|
|
335
381
|
* la hoja del survey. No aplica a React Native (el survey vive en su propio WebView).
|
|
336
382
|
*/
|
|
337
383
|
cspNonce?: string;
|
|
384
|
+
/**
|
|
385
|
+
* `surveyFrontend.sdkVersion` del popup (DD-70): versión de `@magicfeedback/native` asignada
|
|
386
|
+
* al survey en el Admin. Se usa si está en el rango soportado y carga; si no, la empaquetada.
|
|
387
|
+
*/
|
|
388
|
+
surveySdkVersion?: string | null;
|
|
389
|
+
/** `init({debug})`, para el log de la versión de survey SDK elegida. */
|
|
390
|
+
debug?: boolean;
|
|
338
391
|
}
|
|
339
392
|
interface PopupRenderer {
|
|
340
393
|
/** Preparar recursos si aplica */
|
|
@@ -436,6 +489,10 @@ declare class DeepdotsPopups {
|
|
|
436
489
|
private lastShown;
|
|
437
490
|
private surveyToPopupId;
|
|
438
491
|
private deferredExitTimers;
|
|
492
|
+
/** Popups esperando su `delaySeconds` (uno por popup). */
|
|
493
|
+
private delayedPopups;
|
|
494
|
+
/** Última pantalla de `setScreen` (React Native). */
|
|
495
|
+
private currentScreen;
|
|
439
496
|
private baseUrl;
|
|
440
497
|
private env;
|
|
441
498
|
/** Si el SDK pinta el "modal" del popup (RN). Default true; false = el host lo envuelve. */
|
|
@@ -481,6 +538,10 @@ declare class DeepdotsPopups {
|
|
|
481
538
|
private lastEngagementAt;
|
|
482
539
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
483
540
|
private hiddenAt;
|
|
541
|
+
/** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
|
|
542
|
+
private autoTrackErrors;
|
|
543
|
+
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
544
|
+
private appStateSubscription;
|
|
484
545
|
/**
|
|
485
546
|
* Sesión suspendida por un `pagehide` (ms epoch y `deepdots_user_id`); null si no hay.
|
|
486
547
|
* `openSession` la reanuda si sigue a tiempo (ver ANALYTICS_RESUME_WINDOW_MS).
|
|
@@ -587,6 +648,22 @@ declare class DeepdotsPopups {
|
|
|
587
648
|
* Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
|
|
588
649
|
*/
|
|
589
650
|
onBackground(): void;
|
|
651
|
+
/**
|
|
652
|
+
* App a `inactive` (RN, iOS: centro de control, llamada, app switcher, y SIEMPRE justo antes
|
|
653
|
+
* de `background`). NO cierra la sesión (es transitorio), pero envía lo acumulado con un
|
|
654
|
+
* `user_engagement` que lleva la pantalla en curso, como web al ocultar la pestaña: si el
|
|
655
|
+
* lote de cierre de `background` no llega a salir (iOS suspende la app), el backend ya
|
|
656
|
+
* tiene el tiempo activo y la última pantalla. El contador sigue en marcha.
|
|
657
|
+
*/
|
|
658
|
+
onInactive(): void;
|
|
659
|
+
/**
|
|
660
|
+
* Ciclo de vida automático en React Native (contrato de detección automática): el SDK escucha
|
|
661
|
+
* AppState él mismo, así que el host no tiene que llamar a `onForeground`/`onInactive`/
|
|
662
|
+
* `onBackground`. Si el host los llama además (integraciones anteriores), no se duplica nada:
|
|
663
|
+
* abrir o cerrar una sesión ya abierta o cerrada no hace nada, y el engagement se consume.
|
|
664
|
+
* `autoTrack.lifecycle: false` lo apaga.
|
|
665
|
+
*/
|
|
666
|
+
private installAutoLifecycle;
|
|
590
667
|
/**
|
|
591
668
|
* Cierre EXPLÍCITO de la sesión por parte del host (logout, fin de flujo…): emite
|
|
592
669
|
* `session_end` y envía el último lote con `completed:true`.
|
|
@@ -597,6 +674,13 @@ declare class DeepdotsPopups {
|
|
|
597
674
|
* anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
|
|
598
675
|
* identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
|
|
599
676
|
*
|
|
677
|
+
* Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
|
|
678
|
+
* persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
|
|
679
|
+
* `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
|
|
680
|
+
* cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
|
|
681
|
+
* respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
|
|
682
|
+
* contaba dos veces: una que "abandona" en el login y otra registrada nueva.
|
|
683
|
+
*
|
|
600
684
|
* Equivale a llamar a `init()` otra vez con otro `userId`.
|
|
601
685
|
*/
|
|
602
686
|
setUserId(userId?: string): void;
|
|
@@ -706,11 +790,28 @@ declare class DeepdotsPopups {
|
|
|
706
790
|
configureTriggers(triggers: TriggerConfig[]): void;
|
|
707
791
|
/** Deriva triggers desde las definiciones de popup */
|
|
708
792
|
private configureTriggersFromDefinitions;
|
|
709
|
-
/**
|
|
710
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Lógica para evaluar condiciones antes de mostrar una encuesta. `options.delaySeconds`
|
|
795
|
+
* (lo pasan los triggers time/scroll/click con el "Delay" del Admin) espera ese tiempo y
|
|
796
|
+
* vuelve a evaluar antes de mostrar; sin él, al momento como siempre.
|
|
797
|
+
*/
|
|
798
|
+
triggerSurvey(surveyId: string, popupId?: string, options?: {
|
|
799
|
+
delaySeconds?: number;
|
|
800
|
+
}): void;
|
|
711
801
|
/** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
|
|
712
802
|
triggerEvent(eventName: string): void;
|
|
713
803
|
private evaluateEvent;
|
|
804
|
+
/**
|
|
805
|
+
* Muestra `def` ya, o tras su "Delay (seconds)" del Admin. Mientras espera:
|
|
806
|
+
* - el mismo popup no se programa dos veces (el primer vencimiento manda);
|
|
807
|
+
* - cambiar de ruta/pantalla o pasar a background lo cancela;
|
|
808
|
+
* y al vencer se vuelve a evaluar todo (segmentos, idioma, cooldowns) como un disparo nuevo.
|
|
809
|
+
* Si entonces hay otro popup abierto, `showDefinition` lo salta sin efectos, igual que hoy.
|
|
810
|
+
*/
|
|
811
|
+
private showAfterDelay;
|
|
812
|
+
private showDelayedPopup;
|
|
813
|
+
private cancelDelayedPopups;
|
|
814
|
+
private currentHref;
|
|
714
815
|
/**
|
|
715
816
|
* Guarda `trigger` si las definiciones aún no han llegado. Devuelve `true` si lo guardó (el
|
|
716
817
|
* llamador no debe evaluarlo ahora) y `false` si no hay carga en vuelo (se evalúa ya, como
|
|
@@ -851,6 +952,11 @@ interface ReactNativeSetupDeps {
|
|
|
851
952
|
renderer?: PopupRenderer;
|
|
852
953
|
/** `global.ErrorUtils` de RN (para capturar errores JS no manejados). Default: `globalThis.ErrorUtils`. */
|
|
853
954
|
errorUtils?: ReactNativeErrorUtils | null;
|
|
955
|
+
/**
|
|
956
|
+
* Background task nativa para los envíos (iOS, DD-55). Si `config.backgroundTask` viene, gana
|
|
957
|
+
* ese. Para `react-native-background-timer`: `backgroundTimerTask(BackgroundTimer)`.
|
|
958
|
+
*/
|
|
959
|
+
backgroundTask?: BackgroundTaskRunner | null;
|
|
854
960
|
}
|
|
855
961
|
/**
|
|
856
962
|
* Configura el SDK para React Native en una sola llamada: storage persistente (MMKV),
|