@magicfeedback/popup-sdk 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EW2ARDEY.mjs → chunk-FROREHRG.mjs} +23 -3
- package/dist/chunk-FROREHRG.mjs.map +1 -0
- package/dist/{chunk-XOEEBDBJ.mjs → chunk-OPR5I7WO.mjs} +26 -4
- package/dist/chunk-OPR5I7WO.mjs.map +1 -0
- package/dist/{chunk-7ZQOAKXR.mjs → chunk-ZJ5HG3QF.mjs} +26 -4
- package/dist/chunk-ZJ5HG3QF.mjs.map +1 -0
- package/dist/index.d.mts +67 -2
- package/dist/index.d.ts +67 -2
- package/dist/index.js +121 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -14
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +67 -2
- package/dist/index.native.d.ts +67 -2
- package/dist/index.native.js +139 -20
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +116 -19
- package/dist/index.native.mjs.map +1 -1
- package/dist/react-native.d.mts +15 -0
- package/dist/react-native.d.ts +15 -0
- package/dist/react-native.js +135 -19
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +115 -19
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-ZHTRMFO2.mjs → renderPopup-I6CPIR75.mjs} +2 -2
- package/dist/{renderPopup-2Y4QMWR7.mjs → renderPopup-RUY3OBYV.mjs} +2 -2
- package/dist/{renderPopup-YDJUON42.mjs → renderPopup-XNVNP2ZU.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-ZHTRMFO2.mjs.map → renderPopup-I6CPIR75.mjs.map} +0 -0
- /package/dist/{renderPopup-2Y4QMWR7.mjs.map → renderPopup-RUY3OBYV.mjs.map} +0 -0
- /package/dist/{renderPopup-YDJUON42.mjs.map → renderPopup-XNVNP2ZU.mjs.map} +0 -0
package/dist/react-native.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
style_default,
|
|
26
26
|
surveySdkCssUrls,
|
|
27
27
|
surveySdkUrls
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FROREHRG.mjs";
|
|
29
29
|
import {
|
|
30
30
|
__require
|
|
31
31
|
} from "./chunk-BJTO5JO5.mjs";
|
|
@@ -1000,7 +1000,7 @@ function logRnSurveySdkChoice(choice, debug) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
1002
1002
|
// src/ui/preload.ts
|
|
1003
|
-
var defaultLoader = () => import("./renderPopup-
|
|
1003
|
+
var defaultLoader = () => import("./renderPopup-I6CPIR75.mjs");
|
|
1004
1004
|
var pending = null;
|
|
1005
1005
|
function preloadRenderPopup(loader = defaultLoader) {
|
|
1006
1006
|
if (pending) return pending;
|
|
@@ -1073,7 +1073,7 @@ var BrowserPopupRenderer = class {
|
|
|
1073
1073
|
if (!this.container) return;
|
|
1074
1074
|
this.visible = true;
|
|
1075
1075
|
const container = this.container;
|
|
1076
|
-
void import("./renderPopup-
|
|
1076
|
+
void import("./renderPopup-I6CPIR75.mjs").then(
|
|
1077
1077
|
({ renderPopup }) => {
|
|
1078
1078
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
|
|
1079
1079
|
},
|
|
@@ -1970,6 +1970,8 @@ var CrashReporter = class {
|
|
|
1970
1970
|
this.windowInstalled = false;
|
|
1971
1971
|
/** ErrorUtils ya enganchados: engancharlos dos veces capturaría cada error dos veces. */
|
|
1972
1972
|
this.hookedErrorUtils = /* @__PURE__ */ new Set();
|
|
1973
|
+
/** Fuentes de rejections ya enganchadas (idempotente, como ErrorUtils). */
|
|
1974
|
+
this.hookedRejections = /* @__PURE__ */ new Set();
|
|
1973
1975
|
this.options = options;
|
|
1974
1976
|
this.now = options.now ?? (() => Date.now());
|
|
1975
1977
|
}
|
|
@@ -2069,6 +2071,18 @@ var CrashReporter = class {
|
|
|
2069
2071
|
previous?.(error, isFatal);
|
|
2070
2072
|
});
|
|
2071
2073
|
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Promesas rechazadas sin `catch` en React Native: como el `unhandledrejection` de web, se
|
|
2076
|
+
* persisten y se reenvían en el arranque siguiente. La fuente encadena al tracker del host.
|
|
2077
|
+
* Idempotente por fuente.
|
|
2078
|
+
*/
|
|
2079
|
+
installPromiseRejections(source) {
|
|
2080
|
+
if (this.hookedRejections.has(source)) return;
|
|
2081
|
+
this.hookedRejections.add(source);
|
|
2082
|
+
source.addUnhandledListener((error) => {
|
|
2083
|
+
if (this.isEnabled()) this.captureUnhandled(error ?? "unhandledrejection");
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2072
2086
|
/** @internal Test seam: ejercita el camino de persistencia (window handlers no son testeables en vitest). */
|
|
2073
2087
|
_persistForTest(error) {
|
|
2074
2088
|
this.captureUnhandled(error);
|
|
@@ -2173,6 +2187,51 @@ function resolveBackgroundTask(explicit, platform) {
|
|
|
2173
2187
|
}
|
|
2174
2188
|
return void 0;
|
|
2175
2189
|
}
|
|
2190
|
+
var DEFAULT_REJECTION_WHITELIST = [ReferenceError, TypeError, RangeError];
|
|
2191
|
+
function createHermesRejectionHub(hermes, options) {
|
|
2192
|
+
if (!hermes || typeof hermes.enablePromiseRejectionTracker !== "function") return null;
|
|
2193
|
+
const original = hermes.enablePromiseRejectionTracker.bind(hermes);
|
|
2194
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2195
|
+
let hostOptions = null;
|
|
2196
|
+
let active = false;
|
|
2197
|
+
const forwardsToHost = (error) => !!hostOptions?.onUnhandled && (hostOptions.allRejections === true || DEFAULT_REJECTION_WHITELIST.some((type) => error instanceof type));
|
|
2198
|
+
const apply = () => {
|
|
2199
|
+
original({
|
|
2200
|
+
allRejections: true,
|
|
2201
|
+
onUnhandled: (id, error) => {
|
|
2202
|
+
listeners.forEach((listener) => {
|
|
2203
|
+
try {
|
|
2204
|
+
listener(error);
|
|
2205
|
+
} catch {
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
if (hostOptions?.onUnhandled) {
|
|
2209
|
+
if (forwardsToHost(error)) hostOptions.onUnhandled(id, error);
|
|
2210
|
+
} else if (options.dev) {
|
|
2211
|
+
console.warn(`Possible unhandled promise rejection (id: ${id}):`, error);
|
|
2212
|
+
}
|
|
2213
|
+
},
|
|
2214
|
+
onHandled: (id, error) => hostOptions?.onHandled?.(id, error)
|
|
2215
|
+
});
|
|
2216
|
+
};
|
|
2217
|
+
hermes.enablePromiseRejectionTracker = (next) => {
|
|
2218
|
+
hostOptions = next ?? null;
|
|
2219
|
+
if (active) apply();
|
|
2220
|
+
else original(next);
|
|
2221
|
+
};
|
|
2222
|
+
return {
|
|
2223
|
+
addUnhandledListener(listener) {
|
|
2224
|
+
listeners.add(listener);
|
|
2225
|
+
if (!active) {
|
|
2226
|
+
active = true;
|
|
2227
|
+
apply();
|
|
2228
|
+
}
|
|
2229
|
+
return () => {
|
|
2230
|
+
listeners.delete(listener);
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2176
2235
|
|
|
2177
2236
|
// src/analytics/messaging.ts
|
|
2178
2237
|
var MESSAGE_CHANNELS = ["push", "in_app"];
|
|
@@ -2337,6 +2396,8 @@ var DeepdotsPopups = class {
|
|
|
2337
2396
|
this.lastEngagementAt = 0;
|
|
2338
2397
|
/** Cuándo se ocultó la pestaña por última vez (ms epoch); null si está visible. */
|
|
2339
2398
|
this.hiddenAt = null;
|
|
2399
|
+
/** `init({ autoTrack: { errors } })`: captura automática de errores. Activa por defecto. */
|
|
2400
|
+
this.autoTrackErrors = true;
|
|
2340
2401
|
/** Suscripción automática a AppState (React Native, `autoTrack.lifecycle`). */
|
|
2341
2402
|
this.appStateSubscription = void 0;
|
|
2342
2403
|
/**
|
|
@@ -2383,6 +2444,7 @@ var DeepdotsPopups = class {
|
|
|
2383
2444
|
this.surveyCss = config.surveyCss;
|
|
2384
2445
|
this.cspNonce = config.cspNonce;
|
|
2385
2446
|
this.onFeedbackSession = config.onFeedbackSession;
|
|
2447
|
+
this.autoTrackErrors = config.autoTrack?.errors !== false;
|
|
2386
2448
|
this.config = {
|
|
2387
2449
|
apiKey: config.apiKey || void 0,
|
|
2388
2450
|
debug: config.debug || false,
|
|
@@ -2581,11 +2643,14 @@ var DeepdotsPopups = class {
|
|
|
2581
2643
|
*/
|
|
2582
2644
|
installCrashHandlers() {
|
|
2583
2645
|
if (!this.crashReporter || !this.tracking?.isTrackingEnabled()) return;
|
|
2584
|
-
this.
|
|
2585
|
-
|
|
2646
|
+
const auto = this.autoTrackErrors;
|
|
2647
|
+
if (auto) this.crashReporter.install();
|
|
2648
|
+
const errorUtils = this.rnErrorUtils ?? (auto ? globalThis.ErrorUtils : void 0);
|
|
2586
2649
|
if (errorUtils && typeof errorUtils.setGlobalHandler === "function") {
|
|
2587
2650
|
this.crashReporter.installReactNative(errorUtils);
|
|
2588
2651
|
}
|
|
2652
|
+
const rejections = auto ? getReactNativePlatform()?.promiseRejections : null;
|
|
2653
|
+
if (rejections) this.crashReporter.installPromiseRejections(rejections);
|
|
2589
2654
|
}
|
|
2590
2655
|
/**
|
|
2591
2656
|
* Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
|
|
@@ -2731,11 +2796,24 @@ var DeepdotsPopups = class {
|
|
|
2731
2796
|
* anterior (`session_end` con `reason: 'user_change'` + `completed:true`), cambia la
|
|
2732
2797
|
* identidad y abre una sesión nueva. Sin `userId` vuelve al id anónimo del SDK.
|
|
2733
2798
|
*
|
|
2799
|
+
* Anónimo → identificado (la app arranca sin `userId` y lo pone al hacer login) es la MISMA
|
|
2800
|
+
* persona, no otra: el `session_start` de la sesión nueva lleva `identified: true`,
|
|
2801
|
+
* `previous_user_id` (el id anónimo) y `previous_session_id` (el registro que se acaba de
|
|
2802
|
+
* cerrar), para que el backend una las dos sin adivinar; y el estado de popups (mostrados,
|
|
2803
|
+
* respondidos, protecciones de mensajes) se conserva. Sin esto, cada persona que se registra
|
|
2804
|
+
* contaba dos veces: una que "abandona" en el login y otra registrada nueva.
|
|
2805
|
+
*
|
|
2734
2806
|
* Equivale a llamar a `init()` otra vez con otro `userId`.
|
|
2735
2807
|
*/
|
|
2736
2808
|
setUserId(userId) {
|
|
2737
2809
|
const next = userId || void 0;
|
|
2738
2810
|
if (!this.initialized || !this.config || next === this.config.userId) return;
|
|
2811
|
+
const identifying = !this.config.userId && !!next;
|
|
2812
|
+
const previous = identifying ? {
|
|
2813
|
+
identified: true,
|
|
2814
|
+
previous_user_id: this.tracking?.getUserId() ?? void 0,
|
|
2815
|
+
previous_session_id: this.analyticsFeedbackSessionId
|
|
2816
|
+
} : void 0;
|
|
2739
2817
|
this.closeSession("user_change");
|
|
2740
2818
|
const enabled = this.tracking?.isTrackingEnabled() ?? true;
|
|
2741
2819
|
const storage = this.storage ?? createDefaultStorage();
|
|
@@ -2748,13 +2826,18 @@ var DeepdotsPopups = class {
|
|
|
2748
2826
|
post: (body) => this.postContact(body)
|
|
2749
2827
|
}) : null;
|
|
2750
2828
|
this.analytics?.resetUserScope();
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2829
|
+
if (!identifying) {
|
|
2830
|
+
this.messageGuard.reset();
|
|
2831
|
+
this.lastShown.clear();
|
|
2832
|
+
this.surveyProgress.clear();
|
|
2833
|
+
this.answeredSurveys.clear();
|
|
2834
|
+
clearPopupState(storage);
|
|
2835
|
+
}
|
|
2836
|
+
this.log(
|
|
2837
|
+
identifying ? "tracking \xB7 user identified \xB7 user_id:" : "tracking \xB7 user_change \xB7 user_id:",
|
|
2838
|
+
this.tracking.getUserId()
|
|
2839
|
+
);
|
|
2840
|
+
this.openSession("user_change", previous);
|
|
2758
2841
|
}
|
|
2759
2842
|
/**
|
|
2760
2843
|
* Cierra la sesión actual: vuelca todo lo que quedaba abierto y envía el último lote
|
|
@@ -2790,14 +2873,14 @@ var DeepdotsPopups = class {
|
|
|
2790
2873
|
* - `bfcache_restore`: vuelta desde la bfcache fuera de la ventana de reanudación.
|
|
2791
2874
|
* Si hay una sesión suspendida a tiempo emite `deepdots_session_resume` en su lugar, sin reason.
|
|
2792
2875
|
*/
|
|
2793
|
-
openSession(reason) {
|
|
2876
|
+
openSession(reason, extra) {
|
|
2794
2877
|
if (this.sessionOpen) return;
|
|
2795
2878
|
if (!this.tracking?.isTrackingEnabled()) return;
|
|
2796
2879
|
const suspendedMs = this.takeSuspendedSession();
|
|
2797
2880
|
this.sessionOpen = true;
|
|
2798
2881
|
this.lastEngagementAt = Date.now();
|
|
2799
2882
|
if (suspendedMs === null) {
|
|
2800
|
-
this.track("deepdots_session_start", { reason });
|
|
2883
|
+
this.track("deepdots_session_start", { reason, ...extra });
|
|
2801
2884
|
} else {
|
|
2802
2885
|
this.track("deepdots_session_resume", { suspended_ms: suspendedMs });
|
|
2803
2886
|
this.log("tracking \xB7 session resumed after", suspendedMs, "ms:", this.analyticsFeedbackSessionId);
|
|
@@ -3857,13 +3940,26 @@ function setupReactNative(sdk2, config, deps = {}) {
|
|
|
3857
3940
|
};
|
|
3858
3941
|
}
|
|
3859
3942
|
|
|
3943
|
+
// src/platform/react-native-defaults.ts
|
|
3944
|
+
var hub;
|
|
3945
|
+
function registerReactNativeDefaults(rn) {
|
|
3946
|
+
if (hub === void 0) {
|
|
3947
|
+
hub = getReactNativePlatform()?.promiseRejections ?? createHermesRejectionHub(
|
|
3948
|
+
globalThis.HermesInternal,
|
|
3949
|
+
{ dev: typeof __DEV__ !== "undefined" && !!__DEV__ }
|
|
3950
|
+
);
|
|
3951
|
+
}
|
|
3952
|
+
registerReactNativePlatform({
|
|
3953
|
+
os: rn.Platform.OS,
|
|
3954
|
+
appState: rn.AppState,
|
|
3955
|
+
backgroundTaskModule: rn.NativeModules?.DeepdotsBackgroundTask ?? null,
|
|
3956
|
+
promiseRejections: hub
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3860
3960
|
// src/react-native/index.tsx
|
|
3861
3961
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3862
|
-
|
|
3863
|
-
os: Platform.OS,
|
|
3864
|
-
appState: AppState,
|
|
3865
|
-
backgroundTaskModule: NativeModules?.DeepdotsBackgroundTask ?? null
|
|
3866
|
-
});
|
|
3962
|
+
registerReactNativeDefaults({ AppState, NativeModules, Platform });
|
|
3867
3963
|
var sdk = new DeepdotsPopups();
|
|
3868
3964
|
var DeepdotsContext = createContext(sdk);
|
|
3869
3965
|
var useDeepdots = () => useContext(DeepdotsContext);
|