@magicfeedback/popup-sdk 1.20.0 → 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ZJ5HG3QF.mjs → chunk-4C3DSMUT.mjs} +2 -2
- package/dist/{chunk-OPR5I7WO.mjs → chunk-7KMBH25G.mjs} +2 -2
- package/dist/{chunk-FROREHRG.mjs → chunk-NNWYOG43.mjs} +2 -2
- package/dist/index.d.mts +38 -8
- package/dist/index.d.ts +38 -8
- package/dist/index.js +100 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -31
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +38 -8
- package/dist/index.native.d.ts +38 -8
- package/dist/index.native.js +117 -39
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +119 -41
- package/dist/index.native.mjs.map +1 -1
- package/dist/react-native.d.mts +32 -8
- package/dist/react-native.d.ts +32 -8
- package/dist/react-native.js +117 -39
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +119 -41
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-I6CPIR75.mjs → renderPopup-IKPXPDB7.mjs} +2 -2
- package/dist/{renderPopup-RUY3OBYV.mjs → renderPopup-M5ZIXNV6.mjs} +2 -2
- package/dist/{renderPopup-XNVNP2ZU.mjs → renderPopup-QVMBE4L4.mjs} +2 -2
- package/package.json +1 -1
- /package/dist/{chunk-ZJ5HG3QF.mjs.map → chunk-4C3DSMUT.mjs.map} +0 -0
- /package/dist/{chunk-OPR5I7WO.mjs.map → chunk-7KMBH25G.mjs.map} +0 -0
- /package/dist/{chunk-FROREHRG.mjs.map → chunk-NNWYOG43.mjs.map} +0 -0
- /package/dist/{renderPopup-I6CPIR75.mjs.map → renderPopup-IKPXPDB7.mjs.map} +0 -0
- /package/dist/{renderPopup-RUY3OBYV.mjs.map → renderPopup-M5ZIXNV6.mjs.map} +0 -0
- /package/dist/{renderPopup-XNVNP2ZU.mjs.map → renderPopup-QVMBE4L4.mjs.map} +0 -0
package/dist/react-native.d.mts
CHANGED
|
@@ -638,14 +638,21 @@ declare class DeepdotsPopups {
|
|
|
638
638
|
* El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
|
|
639
639
|
*/
|
|
640
640
|
setScreen(name: string): void;
|
|
641
|
-
/**
|
|
641
|
+
/**
|
|
642
|
+
* App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
|
|
643
|
+
* background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
|
|
644
|
+
* (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
|
|
645
|
+
*/
|
|
642
646
|
onForeground(): void;
|
|
643
647
|
/**
|
|
644
|
-
* App a background (RN: AppState 'background'):
|
|
645
|
-
* (page_view), mini-services (mini_service_exit)
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
648
|
+
* App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
|
|
649
|
+
* actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
|
|
650
|
+
* `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
|
|
651
|
+
* - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
|
|
652
|
+
* en el mismo registro;
|
|
653
|
+
* - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
|
|
654
|
+
* minutos con un `session_end` `background` a la hora de la suspensión.
|
|
655
|
+
* Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
|
|
649
656
|
*/
|
|
650
657
|
onBackground(): void;
|
|
651
658
|
/**
|
|
@@ -717,6 +724,7 @@ declare class DeepdotsPopups {
|
|
|
717
724
|
flushAnalytics(options?: {
|
|
718
725
|
final?: boolean;
|
|
719
726
|
sessionEnd?: boolean;
|
|
727
|
+
persist?: boolean;
|
|
720
728
|
}): void;
|
|
721
729
|
/**
|
|
722
730
|
* Emite un evento `user_engagement` con el tiempo activo acumulado (#8) y la pantalla en
|
|
@@ -752,8 +760,12 @@ declare class DeepdotsPopups {
|
|
|
752
760
|
* - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
|
|
753
761
|
* - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
|
|
754
762
|
*
|
|
763
|
+
* En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
|
|
764
|
+
* background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
|
|
765
|
+
*
|
|
755
766
|
* Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
|
|
756
|
-
* POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra
|
|
767
|
+
* POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
|
|
768
|
+
* como antes.
|
|
757
769
|
*/
|
|
758
770
|
private suspendSession;
|
|
759
771
|
/**
|
|
@@ -764,11 +776,23 @@ declare class DeepdotsPopups {
|
|
|
764
776
|
private readResumableSession;
|
|
765
777
|
/**
|
|
766
778
|
* Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
|
|
767
|
-
* ella (mismo usuario, dentro de
|
|
779
|
+
* ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
|
|
780
|
+
* ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
|
|
768
781
|
* En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
|
|
769
782
|
* se abre ahora va a uno nuevo.
|
|
770
783
|
*/
|
|
771
784
|
private takeSuspendedSession;
|
|
785
|
+
/**
|
|
786
|
+
* `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
|
|
787
|
+
* misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
|
|
788
|
+
* (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
|
|
789
|
+
* el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
|
|
790
|
+
* #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
|
|
791
|
+
* - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
|
|
792
|
+
* - Más: el backend ya la cerró → se descarta sin enviar nada.
|
|
793
|
+
* Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
|
|
794
|
+
*/
|
|
795
|
+
private closeStaleHiddenSession;
|
|
772
796
|
/** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
|
|
773
797
|
private discardSession;
|
|
774
798
|
/**
|
package/dist/react-native.d.ts
CHANGED
|
@@ -638,14 +638,21 @@ declare class DeepdotsPopups {
|
|
|
638
638
|
* El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
|
|
639
639
|
*/
|
|
640
640
|
setScreen(name: string): void;
|
|
641
|
-
/**
|
|
641
|
+
/**
|
|
642
|
+
* App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
|
|
643
|
+
* background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
|
|
644
|
+
* (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
|
|
645
|
+
*/
|
|
642
646
|
onForeground(): void;
|
|
643
647
|
/**
|
|
644
|
-
* App a background (RN: AppState 'background'):
|
|
645
|
-
* (page_view), mini-services (mini_service_exit)
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
648
|
+
* App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
|
|
649
|
+
* actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
|
|
650
|
+
* `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
|
|
651
|
+
* - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
|
|
652
|
+
* en el mismo registro;
|
|
653
|
+
* - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
|
|
654
|
+
* minutos con un `session_end` `background` a la hora de la suspensión.
|
|
655
|
+
* Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
|
|
649
656
|
*/
|
|
650
657
|
onBackground(): void;
|
|
651
658
|
/**
|
|
@@ -717,6 +724,7 @@ declare class DeepdotsPopups {
|
|
|
717
724
|
flushAnalytics(options?: {
|
|
718
725
|
final?: boolean;
|
|
719
726
|
sessionEnd?: boolean;
|
|
727
|
+
persist?: boolean;
|
|
720
728
|
}): void;
|
|
721
729
|
/**
|
|
722
730
|
* Emite un evento `user_engagement` con el tiempo activo acumulado (#8) y la pantalla en
|
|
@@ -752,8 +760,12 @@ declare class DeepdotsPopups {
|
|
|
752
760
|
* - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
|
|
753
761
|
* - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
|
|
754
762
|
*
|
|
763
|
+
* En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
|
|
764
|
+
* background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
|
|
765
|
+
*
|
|
755
766
|
* Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
|
|
756
|
-
* POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra
|
|
767
|
+
* POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
|
|
768
|
+
* como antes.
|
|
757
769
|
*/
|
|
758
770
|
private suspendSession;
|
|
759
771
|
/**
|
|
@@ -764,11 +776,23 @@ declare class DeepdotsPopups {
|
|
|
764
776
|
private readResumableSession;
|
|
765
777
|
/**
|
|
766
778
|
* Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
|
|
767
|
-
* ella (mismo usuario, dentro de
|
|
779
|
+
* ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
|
|
780
|
+
* ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
|
|
768
781
|
* En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
|
|
769
782
|
* se abre ahora va a uno nuevo.
|
|
770
783
|
*/
|
|
771
784
|
private takeSuspendedSession;
|
|
785
|
+
/**
|
|
786
|
+
* `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
|
|
787
|
+
* misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
|
|
788
|
+
* (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
|
|
789
|
+
* el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
|
|
790
|
+
* #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
|
|
791
|
+
* - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
|
|
792
|
+
* - Más: el backend ya la cerró → se descarta sin enviar nada.
|
|
793
|
+
* Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
|
|
794
|
+
*/
|
|
795
|
+
private closeStaleHiddenSession;
|
|
772
796
|
/** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
|
|
773
797
|
private discardSession;
|
|
774
798
|
/**
|
package/dist/react-native.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.
|
|
41
|
+
SDK_VERSION = "1.21.1";
|
|
42
42
|
SDK_IDENTIFIER = `${"react-native"}@${SDK_VERSION}`;
|
|
43
43
|
POPUP_CHANNEL = "popup";
|
|
44
44
|
}
|
|
@@ -10559,9 +10559,11 @@ function createFeedbackSink(options) {
|
|
|
10559
10559
|
const body = buildAnalyticsFeedbackBody(envelope, options.keys, feedbackSessionId, { sessionEnd });
|
|
10560
10560
|
options.log?.("[DeepdotsAnalytics] POST /sdk/feedback \u2192", body);
|
|
10561
10561
|
const batch = { body, at: now() };
|
|
10562
|
-
if (sessionEnd) {
|
|
10563
|
-
|
|
10564
|
-
|
|
10562
|
+
if (sessionEnd || meta?.persist) {
|
|
10563
|
+
if (sessionEnd) {
|
|
10564
|
+
feedbackSessionId = void 0;
|
|
10565
|
+
options.onSessionReset?.();
|
|
10566
|
+
}
|
|
10565
10567
|
addPending(batch);
|
|
10566
10568
|
await drain();
|
|
10567
10569
|
return;
|
|
@@ -11213,13 +11215,26 @@ function resolveBackgroundTask(explicit, platform) {
|
|
|
11213
11215
|
}
|
|
11214
11216
|
var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
|
|
11215
11217
|
function createHermesRejectionHub(hermes, options) {
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
+
let original;
|
|
11219
|
+
try {
|
|
11220
|
+
if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
|
|
11221
|
+
original = hermes.enablePromiseRejectionTracker.bind(hermes);
|
|
11222
|
+
} catch {
|
|
11223
|
+
return null;
|
|
11224
|
+
}
|
|
11218
11225
|
const listeners = /* @__PURE__ */ new Set();
|
|
11219
11226
|
let hostOptions = null;
|
|
11220
11227
|
let active2 = false;
|
|
11221
11228
|
const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
|
|
11222
11229
|
const apply = () => {
|
|
11230
|
+
try {
|
|
11231
|
+
install();
|
|
11232
|
+
return true;
|
|
11233
|
+
} catch {
|
|
11234
|
+
return false;
|
|
11235
|
+
}
|
|
11236
|
+
};
|
|
11237
|
+
const install = () => {
|
|
11223
11238
|
original({
|
|
11224
11239
|
allRejections: true,
|
|
11225
11240
|
onUnhandled: (id, error) => {
|
|
@@ -11238,17 +11253,17 @@ function createHermesRejectionHub(hermes, options) {
|
|
|
11238
11253
|
onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
|
|
11239
11254
|
});
|
|
11240
11255
|
};
|
|
11241
|
-
|
|
11256
|
+
const wrapper = (next) => {
|
|
11242
11257
|
hostOptions = next ?? null;
|
|
11243
|
-
if (active2)
|
|
11258
|
+
if (active2) install();
|
|
11244
11259
|
else original(next);
|
|
11245
11260
|
};
|
|
11261
|
+
if (!replaceTracker(hermes, wrapper)) return null;
|
|
11246
11262
|
return {
|
|
11247
11263
|
addUnhandledListener(listener) {
|
|
11248
11264
|
listeners.add(listener);
|
|
11249
11265
|
if (!active2) {
|
|
11250
|
-
active2 =
|
|
11251
|
-
apply();
|
|
11266
|
+
active2 = apply();
|
|
11252
11267
|
}
|
|
11253
11268
|
return () => {
|
|
11254
11269
|
listeners.delete(listener);
|
|
@@ -11256,6 +11271,21 @@ function createHermesRejectionHub(hermes, options) {
|
|
|
11256
11271
|
}
|
|
11257
11272
|
};
|
|
11258
11273
|
}
|
|
11274
|
+
var TRACKER_KEY = "enablePromiseRejectionTracker";
|
|
11275
|
+
function replaceTracker(hermes, wrapper) {
|
|
11276
|
+
try {
|
|
11277
|
+
const own = Object.getOwnPropertyDescriptor(hermes, TRACKER_KEY);
|
|
11278
|
+
if (own && own.writable === false && !own.set) {
|
|
11279
|
+
if (!own.configurable) return false;
|
|
11280
|
+
Object.defineProperty(hermes, TRACKER_KEY, { ...own, value: wrapper });
|
|
11281
|
+
} else {
|
|
11282
|
+
hermes.enablePromiseRejectionTracker = wrapper;
|
|
11283
|
+
}
|
|
11284
|
+
return hermes.enablePromiseRejectionTracker === wrapper;
|
|
11285
|
+
} catch {
|
|
11286
|
+
return false;
|
|
11287
|
+
}
|
|
11288
|
+
}
|
|
11259
11289
|
|
|
11260
11290
|
// src/analytics/messaging.ts
|
|
11261
11291
|
var MESSAGE_CHANNELS = ["push", "in_app"];
|
|
@@ -11333,6 +11363,7 @@ var ANALYTICS_SESSION_TIMEOUT_MS = 30 * 6e4;
|
|
|
11333
11363
|
var ANALYTICS_SERVER_IDLE_MS = 60 * 6e4;
|
|
11334
11364
|
var ANALYTICS_SESSION_DISCARD_MS = ANALYTICS_SERVER_IDLE_MS - 10 * 6e4;
|
|
11335
11365
|
var ANALYTICS_RESUME_WINDOW_MS = 6e4;
|
|
11366
|
+
var ANALYTICS_BACKGROUND_RESUME_WINDOW_MS = 5 * 6e4;
|
|
11336
11367
|
var RESERVED_EVENT_PREFIX = "deepdots_";
|
|
11337
11368
|
var CUSTOM_EVENT_PREFIX = "deepdots_event_";
|
|
11338
11369
|
var MAX_PENDING_TRIGGERS = 20;
|
|
@@ -11500,7 +11531,7 @@ var DeepdotsPopups = class {
|
|
|
11500
11531
|
const resumable = this.readResumableSession();
|
|
11501
11532
|
if (resumable) {
|
|
11502
11533
|
this.analyticsFeedbackSessionId = resumable.sessionId;
|
|
11503
|
-
this.suspended = { at: resumable.at, userId: resumable.userId };
|
|
11534
|
+
this.suspended = { at: resumable.at, userId: resumable.userId, windowMs: ANALYTICS_RESUME_WINDOW_MS };
|
|
11504
11535
|
}
|
|
11505
11536
|
const analyticsSink = config.analytics ? createFeedbackSink({
|
|
11506
11537
|
baseUrl: this.baseUrl,
|
|
@@ -11759,21 +11790,28 @@ var DeepdotsPopups = class {
|
|
|
11759
11790
|
this.navObserver.visit(name);
|
|
11760
11791
|
}
|
|
11761
11792
|
}
|
|
11762
|
-
/**
|
|
11793
|
+
/**
|
|
11794
|
+
* App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
|
|
11795
|
+
* background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
|
|
11796
|
+
* (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
|
|
11797
|
+
*/
|
|
11763
11798
|
onForeground() {
|
|
11764
11799
|
this.engagement?.resume();
|
|
11765
11800
|
this.openSession("foreground");
|
|
11766
11801
|
}
|
|
11767
11802
|
/**
|
|
11768
|
-
* App a background (RN: AppState 'background'):
|
|
11769
|
-
* (page_view), mini-services (mini_service_exit)
|
|
11770
|
-
*
|
|
11771
|
-
*
|
|
11772
|
-
*
|
|
11803
|
+
* App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
|
|
11804
|
+
* actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
|
|
11805
|
+
* `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
|
|
11806
|
+
* - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
|
|
11807
|
+
* en el mismo registro;
|
|
11808
|
+
* - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
|
|
11809
|
+
* minutos con un `session_end` `background` a la hora de la suspensión.
|
|
11810
|
+
* Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
|
|
11773
11811
|
*/
|
|
11774
11812
|
onBackground() {
|
|
11775
11813
|
this.cancelDelayedPopups("app to background");
|
|
11776
|
-
this.closeSession("background");
|
|
11814
|
+
if (!this.suspendSession("background")) this.closeSession("background");
|
|
11777
11815
|
this.engagement?.pause();
|
|
11778
11816
|
}
|
|
11779
11817
|
/**
|
|
@@ -11998,27 +12036,37 @@ var DeepdotsPopups = class {
|
|
|
11998
12036
|
* - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
|
|
11999
12037
|
* - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
|
|
12000
12038
|
*
|
|
12039
|
+
* En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
|
|
12040
|
+
* background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
|
|
12041
|
+
*
|
|
12001
12042
|
* Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
|
|
12002
|
-
* POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra
|
|
12043
|
+
* POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
|
|
12044
|
+
* como antes.
|
|
12003
12045
|
*/
|
|
12004
|
-
suspendSession() {
|
|
12046
|
+
suspendSession(reason) {
|
|
12005
12047
|
if (!this.sessionOpen || !this.tracking?.isTrackingEnabled()) return false;
|
|
12006
12048
|
const sessionId = this.analyticsFeedbackSessionId;
|
|
12007
12049
|
const integration = this.analyticsIntegration;
|
|
12008
|
-
|
|
12009
|
-
if (!sessionId || !integration || !storage) return false;
|
|
12050
|
+
if (!sessionId || !integration) return false;
|
|
12010
12051
|
const at = Date.now();
|
|
12011
12052
|
const userId = this.tracking.getUserId();
|
|
12012
|
-
if (
|
|
12053
|
+
if (reason === "page_hide") {
|
|
12054
|
+
const storage = getSessionStorage();
|
|
12055
|
+
if (!storage || !writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
|
|
12056
|
+
}
|
|
12013
12057
|
this.sessionOpen = false;
|
|
12014
|
-
this.suspended = {
|
|
12058
|
+
this.suspended = {
|
|
12059
|
+
at,
|
|
12060
|
+
userId,
|
|
12061
|
+
windowMs: reason === "page_hide" ? ANALYTICS_RESUME_WINDOW_MS : ANALYTICS_BACKGROUND_RESUME_WINDOW_MS
|
|
12062
|
+
};
|
|
12015
12063
|
this.navObserver?.stop();
|
|
12016
12064
|
this.navStarted = false;
|
|
12017
12065
|
this.analytics?.exitAllMiniServices();
|
|
12018
12066
|
this.flushEngagement();
|
|
12019
12067
|
this.engagement?.pause();
|
|
12020
|
-
this.track("deepdots_session_suspend", { reason
|
|
12021
|
-
this.flushAnalytics({ final: true });
|
|
12068
|
+
this.track("deepdots_session_suspend", { reason });
|
|
12069
|
+
this.flushAnalytics(reason === "page_hide" ? { final: true } : { persist: true });
|
|
12022
12070
|
this.log("tracking \xB7 session suspended:", sessionId);
|
|
12023
12071
|
return true;
|
|
12024
12072
|
}
|
|
@@ -12040,7 +12088,8 @@ var DeepdotsPopups = class {
|
|
|
12040
12088
|
}
|
|
12041
12089
|
/**
|
|
12042
12090
|
* Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
|
|
12043
|
-
* ella (mismo usuario, dentro de
|
|
12091
|
+
* ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
|
|
12092
|
+
* ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
|
|
12044
12093
|
* En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
|
|
12045
12094
|
* se abre ahora va a uno nuevo.
|
|
12046
12095
|
*/
|
|
@@ -12051,7 +12100,7 @@ var DeepdotsPopups = class {
|
|
|
12051
12100
|
const storage = getSessionStorage();
|
|
12052
12101
|
if (storage) clearSuspendedSession(storage);
|
|
12053
12102
|
const suspendedMs = Math.max(0, Date.now() - suspended.at);
|
|
12054
|
-
if (this.analyticsFeedbackSessionId && suspendedMs <=
|
|
12103
|
+
if (this.analyticsFeedbackSessionId && suspendedMs <= suspended.windowMs && suspended.userId === (this.tracking?.getUserId() ?? null)) {
|
|
12055
12104
|
return suspendedMs;
|
|
12056
12105
|
}
|
|
12057
12106
|
this.analytics?.discardSession(this.analyticsIdentity());
|
|
@@ -12059,6 +12108,27 @@ var DeepdotsPopups = class {
|
|
|
12059
12108
|
this.tracking?.setSessionId(null);
|
|
12060
12109
|
return null;
|
|
12061
12110
|
}
|
|
12111
|
+
/**
|
|
12112
|
+
* `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
|
|
12113
|
+
* misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
|
|
12114
|
+
* (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
|
|
12115
|
+
* el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
|
|
12116
|
+
* #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
|
|
12117
|
+
* - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
|
|
12118
|
+
* - Más: el backend ya la cerró → se descarta sin enviar nada.
|
|
12119
|
+
* Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
|
|
12120
|
+
*/
|
|
12121
|
+
closeStaleHiddenSession() {
|
|
12122
|
+
if (!this.sessionOpen || this.hiddenAt === null) return false;
|
|
12123
|
+
const hiddenFor = Date.now() - this.hiddenAt;
|
|
12124
|
+
if (hiddenFor < ANALYTICS_SESSION_TIMEOUT_MS) return false;
|
|
12125
|
+
if (hiddenFor < ANALYTICS_SESSION_DISCARD_MS) {
|
|
12126
|
+
this.closeSession("idle_timeout");
|
|
12127
|
+
} else {
|
|
12128
|
+
this.discardSession();
|
|
12129
|
+
}
|
|
12130
|
+
return true;
|
|
12131
|
+
}
|
|
12062
12132
|
/** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
|
|
12063
12133
|
discardSession() {
|
|
12064
12134
|
this.sessionOpen = false;
|
|
@@ -12107,7 +12177,8 @@ var DeepdotsPopups = class {
|
|
|
12107
12177
|
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
12108
12178
|
window.addEventListener("pagehide", () => {
|
|
12109
12179
|
clearInterval(this.analyticsFlushTimer);
|
|
12110
|
-
if (
|
|
12180
|
+
if (this.closeStaleHiddenSession()) return;
|
|
12181
|
+
if (!this.suspendSession("page_hide")) this.closeSession("page_hide");
|
|
12111
12182
|
});
|
|
12112
12183
|
window.addEventListener("pageshow", (event) => {
|
|
12113
12184
|
if (!event.persisted) return;
|
|
@@ -12968,17 +13039,24 @@ function setupReactNative(sdk2, config, deps = {}) {
|
|
|
12968
13039
|
var hub;
|
|
12969
13040
|
function registerReactNativeDefaults(rn) {
|
|
12970
13041
|
if (hub === void 0) {
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
13042
|
+
try {
|
|
13043
|
+
hub = getReactNativePlatform()?.promiseRejections ?? createHermesRejectionHub(
|
|
13044
|
+
globalThis.HermesInternal,
|
|
13045
|
+
{ dev: typeof __DEV__ !== "undefined" && !!__DEV__ }
|
|
13046
|
+
);
|
|
13047
|
+
} catch {
|
|
13048
|
+
hub = null;
|
|
13049
|
+
}
|
|
13050
|
+
}
|
|
13051
|
+
try {
|
|
13052
|
+
registerReactNativePlatform({
|
|
13053
|
+
os: rn.Platform.OS,
|
|
13054
|
+
appState: rn.AppState,
|
|
13055
|
+
backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
|
|
13056
|
+
promiseRejections: hub
|
|
13057
|
+
});
|
|
13058
|
+
} catch {
|
|
12975
13059
|
}
|
|
12976
|
-
registerReactNativePlatform({
|
|
12977
|
-
os: rn.Platform.OS,
|
|
12978
|
-
appState: rn.AppState,
|
|
12979
|
-
backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
|
|
12980
|
-
promiseRejections: hub
|
|
12981
|
-
});
|
|
12982
13060
|
}
|
|
12983
13061
|
|
|
12984
13062
|
// src/react-native/index.tsx
|