@magicfeedback/popup-sdk 1.1.4 → 1.1.6
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/assets/assets/style.css +10 -1
- package/dist/{chunk-IOAZQPZE.mjs → chunk-4UXOEIAB.mjs} +54 -2
- package/dist/chunk-4UXOEIAB.mjs.map +1 -0
- package/dist/{chunk-6WTOQGET.mjs → chunk-XOTM5CHX.mjs} +54 -2
- package/dist/chunk-XOTM5CHX.mjs.map +1 -0
- package/dist/index.d.mts +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.js +118 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -15
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +25 -1
- package/dist/react-native.d.ts +25 -1
- package/dist/react-native.js +118 -16
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +27 -15
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-YLFRGPQN.mjs → renderPopup-EZKDMLVZ.mjs} +42 -8
- package/dist/renderPopup-EZKDMLVZ.mjs.map +1 -0
- package/dist/{renderPopup-KBDWWSUU.mjs → renderPopup-PS3NJDUR.mjs} +42 -8
- package/dist/renderPopup-PS3NJDUR.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-6WTOQGET.mjs.map +0 -1
- package/dist/chunk-IOAZQPZE.mjs.map +0 -1
- package/dist/renderPopup-KBDWWSUU.mjs.map +0 -1
- package/dist/renderPopup-YLFRGPQN.mjs.map +0 -1
package/dist/react-native.mjs
CHANGED
|
@@ -2,9 +2,13 @@ import {
|
|
|
2
2
|
STORAGE_KEYS,
|
|
3
3
|
TrackingManager,
|
|
4
4
|
__require,
|
|
5
|
+
buildFontFaceCss,
|
|
6
|
+
buildFontFamilyValue,
|
|
5
7
|
buildSurveyIdentity,
|
|
6
|
-
createDefaultStorage
|
|
7
|
-
|
|
8
|
+
createDefaultStorage,
|
|
9
|
+
sdkWarn,
|
|
10
|
+
setLogger
|
|
11
|
+
} from "./chunk-4UXOEIAB.mjs";
|
|
8
12
|
|
|
9
13
|
// src/react-native/index.tsx
|
|
10
14
|
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
@@ -204,10 +208,12 @@ function buildSurveyHtml(opts) {
|
|
|
204
208
|
const pid = JSON.stringify(opts.productId);
|
|
205
209
|
const profileJson = JSON.stringify(opts.profile ?? []);
|
|
206
210
|
const metaJson = JSON.stringify(opts.metadata ?? []);
|
|
211
|
+
const fontFaceCss = opts.font ? buildFontFaceCss(opts.font.family, opts.font.url) : "";
|
|
212
|
+
const fontFamilyValue = opts.font ? buildFontFamilyValue(opts.font.family) : "-apple-system,system-ui,sans-serif";
|
|
207
213
|
return `<!DOCTYPE html><html><head>
|
|
208
214
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
209
215
|
<meta name="color-scheme" content="light"/>
|
|
210
|
-
<style
|
|
216
|
+
<style>${fontFaceCss}html,body{margin:0;padding:0;background:transparent;font-family:${fontFamilyValue}}#mf{width:100%;box-sizing:border-box}#mf *{max-width:100%;box-sizing:border-box}</style>
|
|
211
217
|
</head><body>
|
|
212
218
|
<div id="mf"></div>
|
|
213
219
|
<script>
|
|
@@ -258,17 +264,17 @@ var ReactNativePopupRenderer = class {
|
|
|
258
264
|
}
|
|
259
265
|
init() {
|
|
260
266
|
}
|
|
261
|
-
show(surveyId, productId, _actions, emit, onClose, env = "production", userId,
|
|
267
|
+
show(surveyId, productId, _actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
|
|
262
268
|
this.emitFn = emit;
|
|
263
269
|
this.onCloseFn = onClose;
|
|
264
270
|
this.currentSurveyId = surveyId;
|
|
265
271
|
this.partialEmitted = false;
|
|
266
272
|
const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
|
|
267
|
-
const html = buildSurveyHtml({ surveyId, productId, env, profile, metadata });
|
|
273
|
+
const html = buildSurveyHtml({ surveyId, productId, env, profile, metadata, font: style?.font });
|
|
268
274
|
if (this.options.onShow) {
|
|
269
275
|
this.options.onShow({ surveyId, productId, html });
|
|
270
276
|
} else {
|
|
271
|
-
|
|
277
|
+
sdkWarn(
|
|
272
278
|
"[Deepdots] ReactNativePopupRenderer sin onShow: pasa { onShow } a new ReactNativePopupRenderer({...}) para montar el WebView del survey."
|
|
273
279
|
);
|
|
274
280
|
}
|
|
@@ -360,7 +366,7 @@ var BrowserPopupRenderer = class {
|
|
|
360
366
|
if (!this.container) return;
|
|
361
367
|
this.visible = true;
|
|
362
368
|
const container = this.container;
|
|
363
|
-
void import("./renderPopup-
|
|
369
|
+
void import("./renderPopup-PS3NJDUR.mjs").then(({ renderPopup }) => {
|
|
364
370
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
|
|
365
371
|
});
|
|
366
372
|
}
|
|
@@ -382,12 +388,13 @@ function createDefaultRenderer() {
|
|
|
382
388
|
}
|
|
383
389
|
|
|
384
390
|
// src/analytics/analytics-manager.ts
|
|
385
|
-
|
|
386
|
-
|
|
391
|
+
function createDryRunSink(log = console.log) {
|
|
392
|
+
return (payload) => log(
|
|
387
393
|
"[DeepdotsAnalytics] (dry-run \xB7 NO enviado \xB7 sin init.analytics) POST /sdk/feedback \u2192",
|
|
388
394
|
JSON.stringify(payload, null, 2)
|
|
389
395
|
);
|
|
390
|
-
}
|
|
396
|
+
}
|
|
397
|
+
var dryRunSink = createDryRunSink();
|
|
391
398
|
var AnalyticsManager = class {
|
|
392
399
|
constructor(options = {}) {
|
|
393
400
|
this.events = [];
|
|
@@ -902,7 +909,7 @@ var CrashReporter = class {
|
|
|
902
909
|
}
|
|
903
910
|
/** Instala los handlers globales de errores no capturados (no-op sin `window`). */
|
|
904
911
|
install() {
|
|
905
|
-
if (typeof window === "undefined") return;
|
|
912
|
+
if (typeof window === "undefined" || typeof window.addEventListener !== "function") return;
|
|
906
913
|
window.addEventListener("error", (e) => {
|
|
907
914
|
if (!this.isEnabled()) return;
|
|
908
915
|
this.captureUnhandled(e.error ?? e.message ?? "error");
|
|
@@ -954,6 +961,8 @@ var DeepdotsPopups = class {
|
|
|
954
961
|
this.triggers = [];
|
|
955
962
|
this.initialized = false;
|
|
956
963
|
this.renderer = createDefaultRenderer();
|
|
964
|
+
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
965
|
+
this.logger = console;
|
|
957
966
|
this.popupContainer = null;
|
|
958
967
|
// deprecated: mantenido para compatibilidad interna
|
|
959
968
|
this.popupDefinitions = [];
|
|
@@ -989,6 +998,8 @@ var DeepdotsPopups = class {
|
|
|
989
998
|
}
|
|
990
999
|
/** Initialize the SDK with configuration */
|
|
991
1000
|
init(config) {
|
|
1001
|
+
this.logger = config.logger ?? console;
|
|
1002
|
+
setLogger(this.logger);
|
|
992
1003
|
if (this.initialized) {
|
|
993
1004
|
this.log("SDK already initialized");
|
|
994
1005
|
return;
|
|
@@ -1028,7 +1039,7 @@ var DeepdotsPopups = class {
|
|
|
1028
1039
|
onSessionId: (id) => {
|
|
1029
1040
|
this.analyticsFeedbackSessionId = id;
|
|
1030
1041
|
}
|
|
1031
|
-
}) :
|
|
1042
|
+
}) : createDryRunSink((...a) => this.logger.log(...a));
|
|
1032
1043
|
const device = config.device ?? collectDeviceInfo(config.appVersion);
|
|
1033
1044
|
this.analytics = new AnalyticsManager({
|
|
1034
1045
|
sink: analyticsSink,
|
|
@@ -1681,7 +1692,7 @@ var DeepdotsPopups = class {
|
|
|
1681
1692
|
}
|
|
1682
1693
|
if (!this.popupContainer) return;
|
|
1683
1694
|
const container = this.popupContainer;
|
|
1684
|
-
void import("./renderPopup-
|
|
1695
|
+
void import("./renderPopup-PS3NJDUR.mjs").then(({ renderPopup }) => {
|
|
1685
1696
|
renderPopup(
|
|
1686
1697
|
container,
|
|
1687
1698
|
surveyId,
|
|
@@ -1737,7 +1748,8 @@ var DeepdotsPopups = class {
|
|
|
1737
1748
|
try {
|
|
1738
1749
|
listener(event);
|
|
1739
1750
|
} catch (error) {
|
|
1740
|
-
|
|
1751
|
+
if (this.logger.error) this.logger.error("Error in event listener:", error);
|
|
1752
|
+
else this.logger.log("Error in event listener:", error);
|
|
1741
1753
|
}
|
|
1742
1754
|
});
|
|
1743
1755
|
}
|
|
@@ -1745,7 +1757,7 @@ var DeepdotsPopups = class {
|
|
|
1745
1757
|
/** Log debug messages */
|
|
1746
1758
|
log(...args) {
|
|
1747
1759
|
if (this.config?.debug) {
|
|
1748
|
-
|
|
1760
|
+
this.logger.log("[DeepdotsPopups]", ...args);
|
|
1749
1761
|
}
|
|
1750
1762
|
}
|
|
1751
1763
|
/** External debug method for triggers */
|