@magicfeedback/popup-sdk 1.17.2 → 1.19.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 +33 -1
- 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 +165 -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-7ZQOAKXR.mjs +3335 -0
- package/dist/chunk-7ZQOAKXR.mjs.map +1 -0
- package/dist/chunk-BJTO5JO5.mjs +11 -0
- package/dist/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/{chunk-AFRHPS3K.mjs → chunk-EW2ARDEY.mjs} +591 -51
- package/dist/chunk-EW2ARDEY.mjs.map +1 -0
- package/dist/{chunk-VHTN5UXD.mjs → chunk-XOEEBDBJ.mjs} +630 -10
- package/dist/chunk-XOEEBDBJ.mjs.map +1 -0
- package/dist/index.d.mts +159 -10
- package/dist/index.d.ts +159 -10
- package/dist/index.js +7275 -1466
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -41
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +1616 -0
- package/dist/index.native.d.ts +1616 -0
- package/dist/index.native.js +15853 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.native.mjs +3914 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/react-native.d.mts +105 -8
- package/dist/react-native.d.ts +105 -8
- package/dist/react-native.js +5827 -132
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +313 -43
- package/dist/react-native.mjs.map +1 -1
- package/dist/renderPopup-2Y4QMWR7.mjs +3847 -0
- package/dist/renderPopup-2Y4QMWR7.mjs.map +1 -0
- package/dist/renderPopup-YDJUON42.mjs +3847 -0
- package/dist/renderPopup-YDJUON42.mjs.map +1 -0
- package/dist/{renderPopup-L2Q3KJAZ.mjs → renderPopup-ZHTRMFO2.mjs} +142 -9
- package/dist/renderPopup-ZHTRMFO2.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-AFRHPS3K.mjs.map +0 -1
- package/dist/chunk-VHTN5UXD.mjs.map +0 -1
- package/dist/renderPopup-L2Q3KJAZ.mjs.map +0 -1
- package/dist/renderPopup-PQWJSBOY.mjs +0 -3622
- package/dist/renderPopup-PQWJSBOY.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,11 @@ 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
|
+
}
|
|
138
155
|
interface DeepdotsInitParams {
|
|
139
156
|
/** API key for authentication */
|
|
140
157
|
apiKey?: string;
|
|
@@ -164,6 +181,24 @@ interface DeepdotsInitParams {
|
|
|
164
181
|
language?: string;
|
|
165
182
|
/** Injectable device info (RN: from react-native-device-info). If missing, it is derived from the browser. */
|
|
166
183
|
device?: DeviceInfo;
|
|
184
|
+
/**
|
|
185
|
+
* React Native (iOS): opens a native background task while each analytics request is in
|
|
186
|
+
* flight, so the session's closing request finishes after the app goes to background
|
|
187
|
+
* instead of when the user opens the app again. `begin(name)` starts the task and returns
|
|
188
|
+
* the function that ends it (iOS `beginBackgroundTask` / `endBackgroundTask`). The SDK ends
|
|
189
|
+
* it when the request settles, or after 25 s. Use `backgroundTimerTask(BackgroundTimer)`
|
|
190
|
+
* for `react-native-background-timer`, iOS only. Without it, nothing changes: a closing
|
|
191
|
+
* request that does not finish is stored and sent on the next launch.
|
|
192
|
+
*/
|
|
193
|
+
backgroundTask?: BackgroundTaskRunner;
|
|
194
|
+
/**
|
|
195
|
+
* What the SDK detects on its own. Everything is on by default; set a signal to `false` to
|
|
196
|
+
* turn it off. `lifecycle` (React Native): the SDK listens to `AppState` itself
|
|
197
|
+
* (`active` → session start, `inactive` → send pending data, `background` → session end), so
|
|
198
|
+
* the host does not need to call `onForeground` / `onInactive` / `onBackground`. Calling them
|
|
199
|
+
* as well is harmless: nothing is sent twice.
|
|
200
|
+
*/
|
|
201
|
+
autoTrack?: AutoTrackOptions;
|
|
167
202
|
/**
|
|
168
203
|
* Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
|
|
169
204
|
* to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
|
|
@@ -239,11 +274,22 @@ interface TriggerConfig {
|
|
|
239
274
|
surveyId: string;
|
|
240
275
|
/** Optional popup definition id (used to disambiguate repeated survey ids) */
|
|
241
276
|
popupId?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Seconds to wait once the trigger fires before showing the popup ("Delay" in the Admin).
|
|
279
|
+
* For `exit` it is the wait on the next route. 0 or missing = at once.
|
|
280
|
+
*/
|
|
281
|
+
delaySeconds?: number;
|
|
242
282
|
}
|
|
243
283
|
/**
|
|
244
284
|
* Event types emitted by the SDK
|
|
245
285
|
*/
|
|
246
|
-
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
286
|
+
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
287
|
+
/**
|
|
288
|
+
* Fallo al enviar una página del survey (el popup enseña `errorSubmit`). `data`:
|
|
289
|
+
* `{reason: 'send_failed' | 'no_page' | 'unknown', message}`. No es interacción del
|
|
290
|
+
* usuario: no marca el popup como PARTIAL. También va a analítica como `deepdots_survey_error`.
|
|
291
|
+
*/
|
|
292
|
+
| 'survey_error';
|
|
247
293
|
/**
|
|
248
294
|
* Event payload structure
|
|
249
295
|
*/
|
|
@@ -329,6 +375,13 @@ interface PopupRenderOptions {
|
|
|
329
375
|
* la hoja del survey. No aplica a React Native (el survey vive en su propio WebView).
|
|
330
376
|
*/
|
|
331
377
|
cspNonce?: string;
|
|
378
|
+
/**
|
|
379
|
+
* `surveyFrontend.sdkVersion` del popup (DD-70): versión de `@magicfeedback/native` asignada
|
|
380
|
+
* al survey en el Admin. Se usa si está en el rango soportado y carga; si no, la empaquetada.
|
|
381
|
+
*/
|
|
382
|
+
surveySdkVersion?: string | null;
|
|
383
|
+
/** `init({debug})`, para el log de la versión de survey SDK elegida. */
|
|
384
|
+
debug?: boolean;
|
|
332
385
|
}
|
|
333
386
|
interface PopupRenderer {
|
|
334
387
|
/** Preparar recursos si aplica */
|
|
@@ -430,6 +483,10 @@ declare class DeepdotsPopups {
|
|
|
430
483
|
private lastShown;
|
|
431
484
|
private surveyToPopupId;
|
|
432
485
|
private deferredExitTimers;
|
|
486
|
+
/** Popups esperando su `delaySeconds` (uno por popup). */
|
|
487
|
+
private delayedPopups;
|
|
488
|
+
/** Última pantalla de `setScreen` (React Native). */
|
|
489
|
+
private currentScreen;
|
|
433
490
|
private baseUrl;
|
|
434
491
|
private env;
|
|
435
492
|
/** Si el SDK pinta el "modal" del popup (RN). Default true; false = el host lo envuelve. */
|
|
@@ -475,6 +532,8 @@ declare class DeepdotsPopups {
|
|
|
475
532
|
private lastEngagementAt;
|
|
476
533
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
477
534
|
private hiddenAt;
|
|
535
|
+
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
536
|
+
private appStateSubscription;
|
|
478
537
|
/**
|
|
479
538
|
* Sesión suspendida por un `pagehide` (ms epoch y `deepdots_user_id`); null si no hay.
|
|
480
539
|
* `openSession` la reanuda si sigue a tiempo (ver ANALYTICS_RESUME_WINDOW_MS).
|
|
@@ -581,6 +640,22 @@ declare class DeepdotsPopups {
|
|
|
581
640
|
* Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
|
|
582
641
|
*/
|
|
583
642
|
onBackground(): void;
|
|
643
|
+
/**
|
|
644
|
+
* App a `inactive` (RN, iOS: centro de control, llamada, app switcher, y SIEMPRE justo antes
|
|
645
|
+
* de `background`). NO cierra la sesión (es transitorio), pero envía lo acumulado con un
|
|
646
|
+
* `user_engagement` que lleva la pantalla en curso, como web al ocultar la pestaña: si el
|
|
647
|
+
* lote de cierre de `background` no llega a salir (iOS suspende la app), el backend ya
|
|
648
|
+
* tiene el tiempo activo y la última pantalla. El contador sigue en marcha.
|
|
649
|
+
*/
|
|
650
|
+
onInactive(): void;
|
|
651
|
+
/**
|
|
652
|
+
* Ciclo de vida automático en React Native (contrato de detección automática): el SDK escucha
|
|
653
|
+
* AppState él mismo, así que el host no tiene que llamar a `onForeground`/`onInactive`/
|
|
654
|
+
* `onBackground`. Si el host los llama además (integraciones anteriores), no se duplica nada:
|
|
655
|
+
* abrir o cerrar una sesión ya abierta o cerrada no hace nada, y el engagement se consume.
|
|
656
|
+
* `autoTrack.lifecycle: false` lo apaga.
|
|
657
|
+
*/
|
|
658
|
+
private installAutoLifecycle;
|
|
584
659
|
/**
|
|
585
660
|
* Cierre EXPLÍCITO de la sesión por parte del host (logout, fin de flujo…): emite
|
|
586
661
|
* `session_end` y envía el último lote con `completed:true`.
|
|
@@ -700,11 +775,28 @@ declare class DeepdotsPopups {
|
|
|
700
775
|
configureTriggers(triggers: TriggerConfig[]): void;
|
|
701
776
|
/** Deriva triggers desde las definiciones de popup */
|
|
702
777
|
private configureTriggersFromDefinitions;
|
|
703
|
-
/**
|
|
704
|
-
|
|
778
|
+
/**
|
|
779
|
+
* Lógica para evaluar condiciones antes de mostrar una encuesta. `options.delaySeconds`
|
|
780
|
+
* (lo pasan los triggers time/scroll/click con el "Delay" del Admin) espera ese tiempo y
|
|
781
|
+
* vuelve a evaluar antes de mostrar; sin él, al momento como siempre.
|
|
782
|
+
*/
|
|
783
|
+
triggerSurvey(surveyId: string, popupId?: string, options?: {
|
|
784
|
+
delaySeconds?: number;
|
|
785
|
+
}): void;
|
|
705
786
|
/** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
|
|
706
787
|
triggerEvent(eventName: string): void;
|
|
707
788
|
private evaluateEvent;
|
|
789
|
+
/**
|
|
790
|
+
* Muestra `def` ya, o tras su "Delay (seconds)" del Admin. Mientras espera:
|
|
791
|
+
* - el mismo popup no se programa dos veces (el primer vencimiento manda);
|
|
792
|
+
* - cambiar de ruta/pantalla o pasar a background lo cancela;
|
|
793
|
+
* y al vencer se vuelve a evaluar todo (segmentos, idioma, cooldowns) como un disparo nuevo.
|
|
794
|
+
* Si entonces hay otro popup abierto, `showDefinition` lo salta sin efectos, igual que hoy.
|
|
795
|
+
*/
|
|
796
|
+
private showAfterDelay;
|
|
797
|
+
private showDelayedPopup;
|
|
798
|
+
private cancelDelayedPopups;
|
|
799
|
+
private currentHref;
|
|
708
800
|
/**
|
|
709
801
|
* Guarda `trigger` si las definiciones aún no han llegado. Devuelve `true` si lo guardó (el
|
|
710
802
|
* llamador no debe evaluarlo ahora) y `false` si no hay carga en vuelo (se evalúa ya, como
|
|
@@ -845,6 +937,11 @@ interface ReactNativeSetupDeps {
|
|
|
845
937
|
renderer?: PopupRenderer;
|
|
846
938
|
/** `global.ErrorUtils` de RN (para capturar errores JS no manejados). Default: `globalThis.ErrorUtils`. */
|
|
847
939
|
errorUtils?: ReactNativeErrorUtils | null;
|
|
940
|
+
/**
|
|
941
|
+
* Background task nativa para los envíos (iOS, DD-55). Si `config.backgroundTask` viene, gana
|
|
942
|
+
* ese. Para `react-native-background-timer`: `backgroundTimerTask(BackgroundTimer)`.
|
|
943
|
+
*/
|
|
944
|
+
backgroundTask?: BackgroundTaskRunner | null;
|
|
848
945
|
}
|
|
849
946
|
/**
|
|
850
947
|
* 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,11 @@ 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
|
+
}
|
|
138
155
|
interface DeepdotsInitParams {
|
|
139
156
|
/** API key for authentication */
|
|
140
157
|
apiKey?: string;
|
|
@@ -164,6 +181,24 @@ interface DeepdotsInitParams {
|
|
|
164
181
|
language?: string;
|
|
165
182
|
/** Injectable device info (RN: from react-native-device-info). If missing, it is derived from the browser. */
|
|
166
183
|
device?: DeviceInfo;
|
|
184
|
+
/**
|
|
185
|
+
* React Native (iOS): opens a native background task while each analytics request is in
|
|
186
|
+
* flight, so the session's closing request finishes after the app goes to background
|
|
187
|
+
* instead of when the user opens the app again. `begin(name)` starts the task and returns
|
|
188
|
+
* the function that ends it (iOS `beginBackgroundTask` / `endBackgroundTask`). The SDK ends
|
|
189
|
+
* it when the request settles, or after 25 s. Use `backgroundTimerTask(BackgroundTimer)`
|
|
190
|
+
* for `react-native-background-timer`, iOS only. Without it, nothing changes: a closing
|
|
191
|
+
* request that does not finish is stored and sent on the next launch.
|
|
192
|
+
*/
|
|
193
|
+
backgroundTask?: BackgroundTaskRunner;
|
|
194
|
+
/**
|
|
195
|
+
* What the SDK detects on its own. Everything is on by default; set a signal to `false` to
|
|
196
|
+
* turn it off. `lifecycle` (React Native): the SDK listens to `AppState` itself
|
|
197
|
+
* (`active` → session start, `inactive` → send pending data, `background` → session end), so
|
|
198
|
+
* the host does not need to call `onForeground` / `onInactive` / `onBackground`. Calling them
|
|
199
|
+
* as well is harmless: nothing is sent twice.
|
|
200
|
+
*/
|
|
201
|
+
autoTrack?: AutoTrackOptions;
|
|
167
202
|
/**
|
|
168
203
|
* Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
|
|
169
204
|
* to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
|
|
@@ -239,11 +274,22 @@ interface TriggerConfig {
|
|
|
239
274
|
surveyId: string;
|
|
240
275
|
/** Optional popup definition id (used to disambiguate repeated survey ids) */
|
|
241
276
|
popupId?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Seconds to wait once the trigger fires before showing the popup ("Delay" in the Admin).
|
|
279
|
+
* For `exit` it is the wait on the next route. 0 or missing = at once.
|
|
280
|
+
*/
|
|
281
|
+
delaySeconds?: number;
|
|
242
282
|
}
|
|
243
283
|
/**
|
|
244
284
|
* Event types emitted by the SDK
|
|
245
285
|
*/
|
|
246
|
-
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
286
|
+
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
287
|
+
/**
|
|
288
|
+
* Fallo al enviar una página del survey (el popup enseña `errorSubmit`). `data`:
|
|
289
|
+
* `{reason: 'send_failed' | 'no_page' | 'unknown', message}`. No es interacción del
|
|
290
|
+
* usuario: no marca el popup como PARTIAL. También va a analítica como `deepdots_survey_error`.
|
|
291
|
+
*/
|
|
292
|
+
| 'survey_error';
|
|
247
293
|
/**
|
|
248
294
|
* Event payload structure
|
|
249
295
|
*/
|
|
@@ -329,6 +375,13 @@ interface PopupRenderOptions {
|
|
|
329
375
|
* la hoja del survey. No aplica a React Native (el survey vive en su propio WebView).
|
|
330
376
|
*/
|
|
331
377
|
cspNonce?: string;
|
|
378
|
+
/**
|
|
379
|
+
* `surveyFrontend.sdkVersion` del popup (DD-70): versión de `@magicfeedback/native` asignada
|
|
380
|
+
* al survey en el Admin. Se usa si está en el rango soportado y carga; si no, la empaquetada.
|
|
381
|
+
*/
|
|
382
|
+
surveySdkVersion?: string | null;
|
|
383
|
+
/** `init({debug})`, para el log de la versión de survey SDK elegida. */
|
|
384
|
+
debug?: boolean;
|
|
332
385
|
}
|
|
333
386
|
interface PopupRenderer {
|
|
334
387
|
/** Preparar recursos si aplica */
|
|
@@ -430,6 +483,10 @@ declare class DeepdotsPopups {
|
|
|
430
483
|
private lastShown;
|
|
431
484
|
private surveyToPopupId;
|
|
432
485
|
private deferredExitTimers;
|
|
486
|
+
/** Popups esperando su `delaySeconds` (uno por popup). */
|
|
487
|
+
private delayedPopups;
|
|
488
|
+
/** Última pantalla de `setScreen` (React Native). */
|
|
489
|
+
private currentScreen;
|
|
433
490
|
private baseUrl;
|
|
434
491
|
private env;
|
|
435
492
|
/** Si el SDK pinta el "modal" del popup (RN). Default true; false = el host lo envuelve. */
|
|
@@ -475,6 +532,8 @@ declare class DeepdotsPopups {
|
|
|
475
532
|
private lastEngagementAt;
|
|
476
533
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
477
534
|
private hiddenAt;
|
|
535
|
+
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
536
|
+
private appStateSubscription;
|
|
478
537
|
/**
|
|
479
538
|
* Sesión suspendida por un `pagehide` (ms epoch y `deepdots_user_id`); null si no hay.
|
|
480
539
|
* `openSession` la reanuda si sigue a tiempo (ver ANALYTICS_RESUME_WINDOW_MS).
|
|
@@ -581,6 +640,22 @@ declare class DeepdotsPopups {
|
|
|
581
640
|
* Es la única señal disponible en móvil: el kill de la app (swipe) NO da callback.
|
|
582
641
|
*/
|
|
583
642
|
onBackground(): void;
|
|
643
|
+
/**
|
|
644
|
+
* App a `inactive` (RN, iOS: centro de control, llamada, app switcher, y SIEMPRE justo antes
|
|
645
|
+
* de `background`). NO cierra la sesión (es transitorio), pero envía lo acumulado con un
|
|
646
|
+
* `user_engagement` que lleva la pantalla en curso, como web al ocultar la pestaña: si el
|
|
647
|
+
* lote de cierre de `background` no llega a salir (iOS suspende la app), el backend ya
|
|
648
|
+
* tiene el tiempo activo y la última pantalla. El contador sigue en marcha.
|
|
649
|
+
*/
|
|
650
|
+
onInactive(): void;
|
|
651
|
+
/**
|
|
652
|
+
* Ciclo de vida automático en React Native (contrato de detección automática): el SDK escucha
|
|
653
|
+
* AppState él mismo, así que el host no tiene que llamar a `onForeground`/`onInactive`/
|
|
654
|
+
* `onBackground`. Si el host los llama además (integraciones anteriores), no se duplica nada:
|
|
655
|
+
* abrir o cerrar una sesión ya abierta o cerrada no hace nada, y el engagement se consume.
|
|
656
|
+
* `autoTrack.lifecycle: false` lo apaga.
|
|
657
|
+
*/
|
|
658
|
+
private installAutoLifecycle;
|
|
584
659
|
/**
|
|
585
660
|
* Cierre EXPLÍCITO de la sesión por parte del host (logout, fin de flujo…): emite
|
|
586
661
|
* `session_end` y envía el último lote con `completed:true`.
|
|
@@ -700,11 +775,28 @@ declare class DeepdotsPopups {
|
|
|
700
775
|
configureTriggers(triggers: TriggerConfig[]): void;
|
|
701
776
|
/** Deriva triggers desde las definiciones de popup */
|
|
702
777
|
private configureTriggersFromDefinitions;
|
|
703
|
-
/**
|
|
704
|
-
|
|
778
|
+
/**
|
|
779
|
+
* Lógica para evaluar condiciones antes de mostrar una encuesta. `options.delaySeconds`
|
|
780
|
+
* (lo pasan los triggers time/scroll/click con el "Delay" del Admin) espera ese tiempo y
|
|
781
|
+
* vuelve a evaluar antes de mostrar; sin él, al momento como siempre.
|
|
782
|
+
*/
|
|
783
|
+
triggerSurvey(surveyId: string, popupId?: string, options?: {
|
|
784
|
+
delaySeconds?: number;
|
|
785
|
+
}): void;
|
|
705
786
|
/** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
|
|
706
787
|
triggerEvent(eventName: string): void;
|
|
707
788
|
private evaluateEvent;
|
|
789
|
+
/**
|
|
790
|
+
* Muestra `def` ya, o tras su "Delay (seconds)" del Admin. Mientras espera:
|
|
791
|
+
* - el mismo popup no se programa dos veces (el primer vencimiento manda);
|
|
792
|
+
* - cambiar de ruta/pantalla o pasar a background lo cancela;
|
|
793
|
+
* y al vencer se vuelve a evaluar todo (segmentos, idioma, cooldowns) como un disparo nuevo.
|
|
794
|
+
* Si entonces hay otro popup abierto, `showDefinition` lo salta sin efectos, igual que hoy.
|
|
795
|
+
*/
|
|
796
|
+
private showAfterDelay;
|
|
797
|
+
private showDelayedPopup;
|
|
798
|
+
private cancelDelayedPopups;
|
|
799
|
+
private currentHref;
|
|
708
800
|
/**
|
|
709
801
|
* Guarda `trigger` si las definiciones aún no han llegado. Devuelve `true` si lo guardó (el
|
|
710
802
|
* llamador no debe evaluarlo ahora) y `false` si no hay carga en vuelo (se evalúa ya, como
|
|
@@ -845,6 +937,11 @@ interface ReactNativeSetupDeps {
|
|
|
845
937
|
renderer?: PopupRenderer;
|
|
846
938
|
/** `global.ErrorUtils` de RN (para capturar errores JS no manejados). Default: `globalThis.ErrorUtils`. */
|
|
847
939
|
errorUtils?: ReactNativeErrorUtils | null;
|
|
940
|
+
/**
|
|
941
|
+
* Background task nativa para los envíos (iOS, DD-55). Si `config.backgroundTask` viene, gana
|
|
942
|
+
* ese. Para `react-native-background-timer`: `backgroundTimerTask(BackgroundTimer)`.
|
|
943
|
+
*/
|
|
944
|
+
backgroundTask?: BackgroundTaskRunner | null;
|
|
848
945
|
}
|
|
849
946
|
/**
|
|
850
947
|
* Configura el SDK para React Native en una sola llamada: storage persistente (MMKV),
|