@magicfeedback/popup-sdk 1.19.0 → 1.21.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/dist/{chunk-EW2ARDEY.mjs → chunk-BWYWXAIQ.mjs} +23 -3
- package/dist/chunk-BWYWXAIQ.mjs.map +1 -0
- package/dist/{chunk-7ZQOAKXR.mjs → chunk-H434NTBB.mjs} +26 -4
- package/dist/chunk-H434NTBB.mjs.map +1 -0
- package/dist/{chunk-XOEEBDBJ.mjs → chunk-UBUY6G6Z.mjs} +26 -4
- package/dist/chunk-UBUY6G6Z.mjs.map +1 -0
- package/dist/index.d.mts +105 -10
- package/dist/index.d.ts +105 -10
- package/dist/index.js +186 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -36
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +105 -10
- package/dist/index.native.d.ts +105 -10
- package/dist/index.native.js +204 -42
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +181 -41
- package/dist/index.native.mjs.map +1 -1
- package/dist/react-native.d.mts +47 -8
- package/dist/react-native.d.ts +47 -8
- package/dist/react-native.js +200 -41
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +180 -41
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-2Y4QMWR7.mjs → renderPopup-HNSFPFVT.mjs} +2 -2
- package/dist/{renderPopup-ZHTRMFO2.mjs → renderPopup-VXKWSZ4E.mjs} +2 -2
- package/dist/{renderPopup-YDJUON42.mjs → renderPopup-WNF67H5T.mjs} +2 -2
- package/package.json +1 -1
- package/dist/chunk-7ZQOAKXR.mjs.map +0 -1
- package/dist/chunk-EW2ARDEY.mjs.map +0 -1
- package/dist/chunk-XOEEBDBJ.mjs.map +0 -1
- /package/dist/{renderPopup-2Y4QMWR7.mjs.map → renderPopup-HNSFPFVT.mjs.map} +0 -0
- /package/dist/{renderPopup-ZHTRMFO2.mjs.map → renderPopup-VXKWSZ4E.mjs.map} +0 -0
- /package/dist/{renderPopup-YDJUON42.mjs.map → renderPopup-WNF67H5T.mjs.map} +0 -0
package/dist/index.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.0";
|
|
42
42
|
SDK_IDENTIFIER = `${"react-native"}@${SDK_VERSION}`;
|
|
43
43
|
POPUP_CHANNEL = "popup";
|
|
44
44
|
}
|
|
@@ -307,6 +307,8 @@ function resolveLocale(lang) {
|
|
|
307
307
|
return "sk";
|
|
308
308
|
case "sl":
|
|
309
309
|
return "sl";
|
|
310
|
+
case "ca":
|
|
311
|
+
return "ca";
|
|
310
312
|
default:
|
|
311
313
|
return "en";
|
|
312
314
|
}
|
|
@@ -334,7 +336,7 @@ function resolveActionLabels(actions, lang) {
|
|
|
334
336
|
back: pick(actions?.back?.label, labels.back)
|
|
335
337
|
};
|
|
336
338
|
}
|
|
337
|
-
var EN, ES, DA, NO, SV, FI, DE, FR, PT, AR, BN, ZH_CN, BG, CS, EL, ET, GA, HR, HU, IT, LT, LV, MT, NL, PL, RO, SK, SL, LABELS, SUPPORTED_LANGUAGES, RTL_LOCALES, RESOLVE_LOCALE_JS;
|
|
339
|
+
var EN, ES, DA, NO, SV, FI, DE, FR, PT, AR, BN, ZH_CN, BG, CS, EL, ET, GA, HR, HU, IT, LT, LV, MT, NL, PL, RO, SK, SL, CA, LABELS, SUPPORTED_LANGUAGES, RTL_LOCALES, RESOLVE_LOCALE_JS;
|
|
338
340
|
var init_labels = __esm({
|
|
339
341
|
"src/i18n/labels.ts"() {
|
|
340
342
|
"use strict";
|
|
@@ -786,6 +788,22 @@ var init_labels = __esm({
|
|
|
786
788
|
errorSubmit: "Pri po\u0161iljanju je pri\u0161lo do napake. Poskusite znova ali zaprite okno.",
|
|
787
789
|
errorLoad: "Ankete ni bilo mogo\u010De nalo\u017Eiti."
|
|
788
790
|
};
|
|
791
|
+
CA = {
|
|
792
|
+
accept: "Envia",
|
|
793
|
+
decline: "Cancel\xB7la",
|
|
794
|
+
start: "Comen\xE7a l'enquesta",
|
|
795
|
+
complete: "Completa l'enquesta",
|
|
796
|
+
back: "Enrere",
|
|
797
|
+
question: "Pregunta",
|
|
798
|
+
of: "de",
|
|
799
|
+
followUp: "Seguiment",
|
|
800
|
+
closeAria: "Tanca la finestra emergent",
|
|
801
|
+
loadingAria: "S'est\xE0 carregant l'enquesta",
|
|
802
|
+
errorRequired: "Respon la pregunta obligat\xF2ria per continuar.",
|
|
803
|
+
errorInvalidEmail: "Introdueix una adre\xE7a de correu electr\xF2nic v\xE0lida.",
|
|
804
|
+
errorSubmit: "S'ha produ\xEFt un error en enviar. Torna-ho a provar o tanca la finestra.",
|
|
805
|
+
errorLoad: "No s'ha pogut carregar l'enquesta."
|
|
806
|
+
};
|
|
789
807
|
LABELS = {
|
|
790
808
|
en: EN,
|
|
791
809
|
es: ES,
|
|
@@ -814,7 +832,8 @@ var init_labels = __esm({
|
|
|
814
832
|
pl: PL,
|
|
815
833
|
ro: RO,
|
|
816
834
|
sk: SK,
|
|
817
|
-
sl: SL
|
|
835
|
+
sl: SL,
|
|
836
|
+
ca: CA
|
|
818
837
|
};
|
|
819
838
|
SUPPORTED_LANGUAGES = [
|
|
820
839
|
// Los 11 idiomas que la plataforma ofrece para un survey, más zh-CN (que el SDK nativo ya
|
|
@@ -849,7 +868,9 @@ var init_labels = __esm({
|
|
|
849
868
|
"pl",
|
|
850
869
|
"ro",
|
|
851
870
|
"sk",
|
|
852
|
-
"sl"
|
|
871
|
+
"sl",
|
|
872
|
+
// Catalán (no oficial de la UE).
|
|
873
|
+
"ca"
|
|
853
874
|
];
|
|
854
875
|
RTL_LOCALES = ["ar"];
|
|
855
876
|
RESOLVE_LOCALE_JS = `function ddResolveLocale(lang){
|
|
@@ -885,6 +906,7 @@ var init_labels = __esm({
|
|
|
885
906
|
if(p==='ro') return 'ro';
|
|
886
907
|
if(p==='sk') return 'sk';
|
|
887
908
|
if(p==='sl') return 'sl';
|
|
909
|
+
if(p==='ca') return 'ca';
|
|
888
910
|
return 'en';
|
|
889
911
|
}`;
|
|
890
912
|
}
|
|
@@ -11969,6 +11991,7 @@ __export(index_native_exports, {
|
|
|
11969
11991
|
crashRecordToParams: () => crashRecordToParams,
|
|
11970
11992
|
createDefaultRenderer: () => createDefaultRenderer,
|
|
11971
11993
|
createFeedbackSink: () => createFeedbackSink,
|
|
11994
|
+
createHermesRejectionHub: () => createHermesRejectionHub,
|
|
11972
11995
|
directionFor: () => directionFor,
|
|
11973
11996
|
getLabels: () => getLabels,
|
|
11974
11997
|
isRtlLanguage: () => isRtlLanguage,
|
|
@@ -12009,6 +12032,68 @@ function resolveBackgroundTask(explicit, platform) {
|
|
|
12009
12032
|
}
|
|
12010
12033
|
return void 0;
|
|
12011
12034
|
}
|
|
12035
|
+
var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
|
|
12036
|
+
function createHermesRejectionHub(hermes, options) {
|
|
12037
|
+
if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
|
|
12038
|
+
const original = hermes.enablePromiseRejectionTracker.bind(hermes);
|
|
12039
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
12040
|
+
let hostOptions = null;
|
|
12041
|
+
let active2 = false;
|
|
12042
|
+
const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
|
|
12043
|
+
const apply = () => {
|
|
12044
|
+
original({
|
|
12045
|
+
allRejections: true,
|
|
12046
|
+
onUnhandled: (id, error) => {
|
|
12047
|
+
listeners.forEach((listener) => {
|
|
12048
|
+
try {
|
|
12049
|
+
listener(error);
|
|
12050
|
+
} catch {
|
|
12051
|
+
}
|
|
12052
|
+
});
|
|
12053
|
+
if (hostOptions?.onUnhandled) {
|
|
12054
|
+
if (forwardsToHost(error)) hostOptions.onUnhandled(id, error);
|
|
12055
|
+
} else if (options.dev) {
|
|
12056
|
+
console.warn(`Possible unhandled promise rejection (id: ${id}):`, error);
|
|
12057
|
+
}
|
|
12058
|
+
},
|
|
12059
|
+
onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
|
|
12060
|
+
});
|
|
12061
|
+
};
|
|
12062
|
+
hermes.enablePromiseRejectionTracker = (next) => {
|
|
12063
|
+
hostOptions = next ?? null;
|
|
12064
|
+
if (active2) apply();
|
|
12065
|
+
else original(next);
|
|
12066
|
+
};
|
|
12067
|
+
return {
|
|
12068
|
+
addUnhandledListener(listener) {
|
|
12069
|
+
listeners.add(listener);
|
|
12070
|
+
if (!active2) {
|
|
12071
|
+
active2 = true;
|
|
12072
|
+
apply();
|
|
12073
|
+
}
|
|
12074
|
+
return () => {
|
|
12075
|
+
listeners.delete(listener);
|
|
12076
|
+
};
|
|
12077
|
+
}
|
|
12078
|
+
};
|
|
12079
|
+
}
|
|
12080
|
+
|
|
12081
|
+
// src/platform/react-native-defaults.ts
|
|
12082
|
+
var hub;
|
|
12083
|
+
function registerReactNativeDefaults(rn) {
|
|
12084
|
+
if (hub === void 0) {
|
|
12085
|
+
hub = getReactNativePlatform()?.promiseRejections ?? createHermesRejectionHub(
|
|
12086
|
+
globalThis.HermesInternal,
|
|
12087
|
+
{ dev: typeof __DEV__ !== "undefined" && !!__DEV__ }
|
|
12088
|
+
);
|
|
12089
|
+
}
|
|
12090
|
+
registerReactNativePlatform({
|
|
12091
|
+
os: rn.Platform.OS,
|
|
12092
|
+
appState: rn.AppState,
|
|
12093
|
+
backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
|
|
12094
|
+
promiseRejections: hub
|
|
12095
|
+
});
|
|
12096
|
+
}
|
|
12012
12097
|
|
|
12013
12098
|
// src/types/index.ts
|
|
12014
12099
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
@@ -13547,9 +13632,11 @@ function createFeedbackSink(options) {
|
|
|
13547
13632
|
const body = buildAnalyticsFeedbackBody(envelope, options.keys, feedbackSessionId, { sessionEnd });
|
|
13548
13633
|
options.log?.("[DeepdotsAnalytics] POST /sdk/feedback \u2192", body);
|
|
13549
13634
|
const batch = { body, at: now() };
|
|
13550
|
-
if (sessionEnd) {
|
|
13551
|
-
|
|
13552
|
-
|
|
13635
|
+
if (sessionEnd || meta?.persist) {
|
|
13636
|
+
if (sessionEnd) {
|
|
13637
|
+
feedbackSessionId = void 0;
|
|
13638
|
+
options.onSessionReset?.();
|
|
13639
|
+
}
|
|
13553
13640
|
addPending(batch);
|
|
13554
13641
|
await drain();
|
|
13555
13642
|
return;
|
|
@@ -13979,6 +14066,8 @@ var CrashReporter = class {
|
|
|
13979
14066
|
this.windowInstalled = false;
|
|
13980
14067
|
/** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
|
|
13981
14068
|
this.hookedErrorUtils = /* @__PURE__ */ new Set();
|
|
14069
|
+
/** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
|
|
14070
|
+
this.hookedRejections = /* @__PURE__ */ new Set();
|
|
13982
14071
|
this.options = options;
|
|
13983
14072
|
this.now = options.now ?? (() => Date.now());
|
|
13984
14073
|
}
|
|
@@ -14078,6 +14167,18 @@ var CrashReporter = class {
|
|
|
14078
14167
|
previous?.(error, isFatal);
|
|
14079
14168
|
});
|
|
14080
14169
|
}
|
|
14170
|
+
/**
|
|
14171
|
+
* Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
|
|
14172
|
+
* persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
|
|
14173
|
+
* Idempotente por fuente.
|
|
14174
|
+
*/
|
|
14175
|
+
installPromiseRejections(source) {
|
|
14176
|
+
if (this.hookedRejections.has(source)) return;
|
|
14177
|
+
this.hookedRejections.add(source);
|
|
14178
|
+
source.addUnhandledListener((error) => {
|
|
14179
|
+
if (this.isEnabled()) this.captureUnhandled(error ?? "unhandledrejection");
|
|
14180
|
+
});
|
|
14181
|
+
}
|
|
14081
14182
|
/** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
|
|
14082
14183
|
_persistForTest(error) {
|
|
14083
14184
|
this.captureUnhandled(error);
|
|
@@ -14232,6 +14333,7 @@ var ANALYTICS_SESSION_TIMEOUT_MS = 30 * 6e4;
|
|
|
14232
14333
|
var ANALYTICS_SERVER_IDLE_MS = 60 * 6e4;
|
|
14233
14334
|
var ANALYTICS_SESSION_DISCARD_MS = ANALYTICS_SERVER_IDLE_MS - 10 * 6e4;
|
|
14234
14335
|
var ANALYTICS_RESUME_WINDOW_MS = 6e4;
|
|
14336
|
+
var ANALYTICS_BACKGROUND_RESUME_WINDOW_MS = 5 * 6e4;
|
|
14235
14337
|
var RESERVED_EVENT_PREFIX = "deepdots_";
|
|
14236
14338
|
var CUSTOM_EVENT_PREFIX = "deepdots_event_";
|
|
14237
14339
|
var MAX_PENDING_TRIGGERS = 20;
|
|
@@ -14319,6 +14421,8 @@ var DeepdotsPopups = class {
|
|
|
14319
14421
|
this.lastEngagementAt = 0;
|
|
14320
14422
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
14321
14423
|
this.hiddenAt = null;
|
|
14424
|
+
/** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
|
|
14425
|
+
this.autoTrackErrors = true;
|
|
14322
14426
|
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
14323
14427
|
this.appStateSubscription = void 0;
|
|
14324
14428
|
/**
|
|
@@ -14365,6 +14469,7 @@ var DeepdotsPopups = class {
|
|
|
14365
14469
|
this.surveyCss = config.surveyCss;
|
|
14366
14470
|
this.cspNonce = config.cspNonce;
|
|
14367
14471
|
this.onFeedbackSession = config.onFeedbackSession;
|
|
14472
|
+
this.autoTrackErrors = config.autoTrack?.errors !== false;
|
|
14368
14473
|
this.config = {
|
|
14369
14474
|
apiKey: config.apiKey || void 0,
|
|
14370
14475
|
debug: config.debug || false,
|
|
@@ -14396,7 +14501,7 @@ var DeepdotsPopups = class {
|
|
|
14396
14501
|
const resumable = this.readResumableSession();
|
|
14397
14502
|
if (resumable) {
|
|
14398
14503
|
this.analyticsFeedbackSessionId = resumable.sessionId;
|
|
14399
|
-
this.suspended = { at: resumable.at, userId: resumable.userId };
|
|
14504
|
+
this.suspended = { at: resumable.at, userId: resumable.userId, windowMs: ANALYTICS_RESUME_WINDOW_MS };
|
|
14400
14505
|
}
|
|
14401
14506
|
const analyticsSink = config.analytics ? createFeedbackSink({
|
|
14402
14507
|
baseUrl: this.baseUrl,
|
|
@@ -14563,11 +14668,14 @@ var DeepdotsPopups = class {
|
|
|
14563
14668
|
*/
|
|
14564
14669
|
installCrashHandlers() {
|
|
14565
14670
|
if (!this.crashReporter || !this.tracking?.isTrackingEnabled()) return;
|
|
14566
|
-
this.
|
|
14567
|
-
|
|
14671
|
+
const auto = this.autoTrackErrors;
|
|
14672
|
+
if (auto) this.crashReporter.install();
|
|
14673
|
+
const errorUtils = this.rnErrorUtils ?? (auto ? globalThis.ErrorUtils : void 0);
|
|
14568
14674
|
if (errorUtils && typeof errorUtils.setGlobalHandler === "function") {
|
|
14569
14675
|
this.crashReporter.installReactNative(errorUtils);
|
|
14570
14676
|
}
|
|
14677
|
+
const rejections = auto ? getReactNativePlatform()?.promiseRejections : null;
|
|
14678
|
+
if (rejections) this.crashReporter.installPromiseRejections(rejections);
|
|
14571
14679
|
}
|
|
14572
14680
|
/**
|
|
14573
14681
|
* Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
|
|
@@ -14652,21 +14760,28 @@ var DeepdotsPopups = class {
|
|
|
14652
14760
|
this.navObserver.visit(name);
|
|
14653
14761
|
}
|
|
14654
14762
|
}
|
|
14655
|
-
/**
|
|
14763
|
+
/**
|
|
14764
|
+
* App a foreground (RN: AppState 'active'): reanuda el engagement time. Si la app estuvo en
|
|
14765
|
+
* background menos de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS sigue en la misma sesión
|
|
14766
|
+
* (`deepdots_session_resume`); si no, abre una nueva (`session_start` `foreground`).
|
|
14767
|
+
*/
|
|
14656
14768
|
onForeground() {
|
|
14657
14769
|
this.engagement?.resume();
|
|
14658
14770
|
this.openSession("foreground");
|
|
14659
14771
|
}
|
|
14660
14772
|
/**
|
|
14661
|
-
* App a background (RN: AppState 'background'):
|
|
14662
|
-
* (page_view), mini-services (mini_service_exit)
|
|
14663
|
-
*
|
|
14664
|
-
*
|
|
14665
|
-
*
|
|
14773
|
+
* App a background (RN: AppState 'background'): SUSPENDE la sesión. Cierra la pantalla
|
|
14774
|
+
* actual (page_view), los mini-services (mini_service_exit) y envía lo acumulado con un
|
|
14775
|
+
* `deepdots_session_suspend` (`reason: background`) y SIN `completed`:
|
|
14776
|
+
* - si la app vuelve dentro de ANALYTICS_BACKGROUND_RESUME_WINDOW_MS, `onForeground` sigue
|
|
14777
|
+
* en el mismo registro;
|
|
14778
|
+
* - si no vuelve (o la matan: el swipe NO da callback), el backend la cierra pasados unos
|
|
14779
|
+
* minutos con un `session_end` `background` a la hora de la suspensión.
|
|
14780
|
+
* Si aún no se conoce el registro (el primer POST sigue en vuelo), FIN DE SESIÓN como antes.
|
|
14666
14781
|
*/
|
|
14667
14782
|
onBackground() {
|
|
14668
14783
|
this.cancelDelayedPopups("app to background");
|
|
14669
|
-
this.closeSession("background");
|
|
14784
|
+
if (!this.suspendSession("background")) this.closeSession("background");
|
|
14670
14785
|
this.engagement?.pause();
|
|
14671
14786
|
}
|
|
14672
14787
|
/**
|
|
@@ -14713,11 +14828,24 @@ var DeepdotsPopups = class {
|
|
|
14713
14828
|
* anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
|
|
14714
14829
|
* identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
|
|
14715
14830
|
*
|
|
14831
|
+
* Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
|
|
14832
|
+
* persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
|
|
14833
|
+
* `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
|
|
14834
|
+
* cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
|
|
14835
|
+
* respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
|
|
14836
|
+
* contaba dos veces: una que "abandona" en el login y otra registrada nueva.
|
|
14837
|
+
*
|
|
14716
14838
|
* Equivale a llamar a `init()` otra vez con otro `userId`.
|
|
14717
14839
|
*/
|
|
14718
14840
|
setUserId(userId) {
|
|
14719
14841
|
const next = userId || void 0;
|
|
14720
14842
|
if (!this.initialized || !this.config || next === this.config.userId) return;
|
|
14843
|
+
const identifying = !this.config.userId && !!next;
|
|
14844
|
+
const previous = identifying ? {
|
|
14845
|
+
identified: true,
|
|
14846
|
+
previous_user_id: this.tracking?.getUserId() ?? void 0,
|
|
14847
|
+
previous_session_id: this.analyticsFeedbackSessionId
|
|
14848
|
+
} : void 0;
|
|
14721
14849
|
this.closeSession("user_change");
|
|
14722
14850
|
const enabled = this.tracking?.isTrackingEnabled() ?? true;
|
|
14723
14851
|
const storage = this.storage ?? createDefaultStorage();
|
|
@@ -14730,13 +14858,18 @@ var DeepdotsPopups = class {
|
|
|
14730
14858
|
post: (body) => this.postContact(body)
|
|
14731
14859
|
}) : null;
|
|
14732
14860
|
this.analytics?.resetUserScope();
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14861
|
+
if (!identifying) {
|
|
14862
|
+
this.messageGuard.reset();
|
|
14863
|
+
this.lastShown.clear();
|
|
14864
|
+
this.surveyProgress.clear();
|
|
14865
|
+
this.answeredSurveys.clear();
|
|
14866
|
+
clearPopupState(storage);
|
|
14867
|
+
}
|
|
14868
|
+
this.log(
|
|
14869
|
+
identifying ? "tracking \xB7 user identified \xB7 user_id:" : "tracking \xB7 user_change \xB7 user_id:",
|
|
14870
|
+
this.tracking.getUserId()
|
|
14871
|
+
);
|
|
14872
|
+
this.openSession("user_change", previous);
|
|
14740
14873
|
}
|
|
14741
14874
|
/**
|
|
14742
14875
|
* Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
|
|
@@ -14772,14 +14905,14 @@ var DeepdotsPopups = class {
|
|
|
14772
14905
|
* - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
|
|
14773
14906
|
* Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
|
|
14774
14907
|
*/
|
|
14775
|
-
openSession(reason) {
|
|
14908
|
+
openSession(reason, extra) {
|
|
14776
14909
|
if (this.sessionOpen) return;
|
|
14777
14910
|
if (!this.tracking?.isTrackingEnabled()) return;
|
|
14778
14911
|
const suspendedMs = this.takeSuspendedSession();
|
|
14779
14912
|
this.sessionOpen = true;
|
|
14780
14913
|
this.lastEngagementAt = Date.now();
|
|
14781
14914
|
if (suspendedMs === null) {
|
|
14782
|
-
this.track("deepdots_session_start", { reason });
|
|
14915
|
+
this.track("deepdots_session_start", { reason, ...extra });
|
|
14783
14916
|
} else {
|
|
14784
14917
|
this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
|
|
14785
14918
|
this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
|
|
@@ -14873,27 +15006,37 @@ var DeepdotsPopups = class {
|
|
|
14873
15006
|
* - si la página vuelve a cargar en esta pestaña, `init()` sigue en el mismo registro;
|
|
14874
15007
|
* - si la pestaña se cerró, el backend lo cierra a los pocos minutos sin otro lote.
|
|
14875
15008
|
*
|
|
15009
|
+
* En React Native (`background`) la suspensión vive en memoria: la app sigue viva en
|
|
15010
|
+
* background y, si el SO la mata, el arranque siguiente es otra sesión (`cold_start`).
|
|
15011
|
+
*
|
|
14876
15012
|
* Devuelve false cuando no se puede suspender — aún no se conoce el registro (el primer
|
|
14877
|
-
* POST sigue en vuelo) o no hay `sessionStorage` — y entonces el caller cierra
|
|
15013
|
+
* POST sigue en vuelo) o, en web, no hay `sessionStorage` — y entonces el caller cierra
|
|
15014
|
+
* como antes.
|
|
14878
15015
|
*/
|
|
14879
|
-
suspendSession() {
|
|
15016
|
+
suspendSession(reason) {
|
|
14880
15017
|
if (!this.sessionOpen || !this.tracking?.isTrackingEnabled()) return false;
|
|
14881
15018
|
const sessionId = this.analyticsFeedbackSessionId;
|
|
14882
15019
|
const integration = this.analyticsIntegration;
|
|
14883
|
-
|
|
14884
|
-
if (!sessionId || !integration || !storage) return false;
|
|
15020
|
+
if (!sessionId || !integration) return false;
|
|
14885
15021
|
const at = Date.now();
|
|
14886
15022
|
const userId = this.tracking.getUserId();
|
|
14887
|
-
if (
|
|
15023
|
+
if (reason === "page_hide") {
|
|
15024
|
+
const storage = getSessionStorage();
|
|
15025
|
+
if (!storage || !writeSuspendedSession(storage, { sessionId, integration, userId, at })) return false;
|
|
15026
|
+
}
|
|
14888
15027
|
this.sessionOpen = false;
|
|
14889
|
-
this.suspended = {
|
|
15028
|
+
this.suspended = {
|
|
15029
|
+
at,
|
|
15030
|
+
userId,
|
|
15031
|
+
windowMs: reason === "page_hide" ? ANALYTICS_RESUME_WINDOW_MS : ANALYTICS_BACKGROUND_RESUME_WINDOW_MS
|
|
15032
|
+
};
|
|
14890
15033
|
this.navObserver?.stop();
|
|
14891
15034
|
this.navStarted = false;
|
|
14892
15035
|
this.analytics?.exitAllMiniServices();
|
|
14893
15036
|
this.flushEngagement();
|
|
14894
15037
|
this.engagement?.pause();
|
|
14895
|
-
this.track("deepdots_session_suspend", { reason
|
|
14896
|
-
this.flushAnalytics({ final: true });
|
|
15038
|
+
this.track("deepdots_session_suspend", { reason });
|
|
15039
|
+
this.flushAnalytics(reason === "page_hide" ? { final: true } : { persist: true });
|
|
14897
15040
|
this.log("tracking \xB7 session suspended:", sessionId);
|
|
14898
15041
|
return true;
|
|
14899
15042
|
}
|
|
@@ -14915,7 +15058,8 @@ var DeepdotsPopups = class {
|
|
|
14915
15058
|
}
|
|
14916
15059
|
/**
|
|
14917
15060
|
* Consume la sesión suspendida al abrir: los ms que estuvo suspendida si se puede seguir en
|
|
14918
|
-
* ella (mismo usuario, dentro de
|
|
15061
|
+
* ella (mismo usuario, dentro de su ventana: ANALYTICS_RESUME_WINDOW_MS tras un `pagehide`,
|
|
15062
|
+
* ANALYTICS_BACKGROUND_RESUME_WINDOW_MS tras un background); null si no había o ya no toca.
|
|
14919
15063
|
* En ese caso se olvida su registro sin enviar nada: lo cierra el backend, y la sesión que
|
|
14920
15064
|
* se abre ahora va a uno nuevo.
|
|
14921
15065
|
*/
|
|
@@ -14926,7 +15070,7 @@ var DeepdotsPopups = class {
|
|
|
14926
15070
|
const storage = getSessionStorage();
|
|
14927
15071
|
if (storage) clearSuspendedSession(storage);
|
|
14928
15072
|
const suspendedMs = Math.max(0, Date.now() - suspended.at);
|
|
14929
|
-
if (this.analyticsFeedbackSessionId && suspendedMs <=
|
|
15073
|
+
if (this.analyticsFeedbackSessionId && suspendedMs <= suspended.windowMs && suspended.userId === (this.tracking?.getUserId() ?? null)) {
|
|
14930
15074
|
return suspendedMs;
|
|
14931
15075
|
}
|
|
14932
15076
|
this.analytics?.discardSession(this.analyticsIdentity());
|
|
@@ -14934,6 +15078,27 @@ var DeepdotsPopups = class {
|
|
|
14934
15078
|
this.tracking?.setSessionId(null);
|
|
14935
15079
|
return null;
|
|
14936
15080
|
}
|
|
15081
|
+
/**
|
|
15082
|
+
* `pagehide` de una pestaña que llevaba oculta más de ANALYTICS_SESSION_TIMEOUT_MS: la
|
|
15083
|
+
* misma regla que `onDocumentVisible`. Suspenderla mandaba un lote más al registro viejo
|
|
15084
|
+
* (page_view + session_suspend) aunque el backend ya lo hubiera cerrado por inactividad:
|
|
15085
|
+
* el backend lo volvía a montar y las acciones de FEEDBACK_DONE (el aviso de Slack de
|
|
15086
|
+
* #platform-visitors) salían otra vez, horas después. Pasó con una pestaña oculta 7 h.
|
|
15087
|
+
* - Oculta menos de ANALYTICS_SESSION_DISCARD_MS: se cierra con `idle_timeout`.
|
|
15088
|
+
* - Más: el backend ya la cerró → se descarta sin enviar nada.
|
|
15089
|
+
* Devuelve false si la pestaña no llevaba tanto oculta (el caller suspende como siempre).
|
|
15090
|
+
*/
|
|
15091
|
+
closeStaleHiddenSession() {
|
|
15092
|
+
if (!this.sessionOpen || this.hiddenAt === null) return false;
|
|
15093
|
+
const hiddenFor = Date.now() - this.hiddenAt;
|
|
15094
|
+
if (hiddenFor < ANALYTICS_SESSION_TIMEOUT_MS) return false;
|
|
15095
|
+
if (hiddenFor < ANALYTICS_SESSION_DISCARD_MS) {
|
|
15096
|
+
this.closeSession("idle_timeout");
|
|
15097
|
+
} else {
|
|
15098
|
+
this.discardSession();
|
|
15099
|
+
}
|
|
15100
|
+
return true;
|
|
15101
|
+
}
|
|
14937
15102
|
/** Olvida la sesión abierta sin enviar nada (ver onDocumentVisible). */
|
|
14938
15103
|
discardSession() {
|
|
14939
15104
|
this.sessionOpen = false;
|
|
@@ -14982,7 +15147,8 @@ var DeepdotsPopups = class {
|
|
|
14982
15147
|
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
14983
15148
|
window.addEventListener("pagehide", () => {
|
|
14984
15149
|
clearInterval(this.analyticsFlushTimer);
|
|
14985
|
-
if (
|
|
15150
|
+
if (this.closeStaleHiddenSession()) return;
|
|
15151
|
+
if (!this.suspendSession("page_hide")) this.closeSession("page_hide");
|
|
14986
15152
|
});
|
|
14987
15153
|
window.addEventListener("pageshow", (event) => {
|
|
14988
15154
|
if (!event.persisted) return;
|
|
@@ -15845,9 +16011,5 @@ function setupReactNative(sdk, config, deps = {}) {
|
|
|
15845
16011
|
}
|
|
15846
16012
|
|
|
15847
16013
|
// src/index.native.ts
|
|
15848
|
-
|
|
15849
|
-
os: import_react_native.Platform.OS,
|
|
15850
|
-
appState: import_react_native.AppState,
|
|
15851
|
-
backgroundTaskModule: import_react_native.NativeModules?.DeepdotsBackgroundTask ?? null
|
|
15852
|
-
});
|
|
16014
|
+
registerReactNativeDefaults({ AppState: import_react_native.AppState, NativeModules: import_react_native.NativeModules, Platform: import_react_native.Platform });
|
|
15853
16015
|
//# sourceMappingURL=index.native.js.map
|