@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/index.mjs
CHANGED
|
@@ -2,9 +2,13 @@ import {
|
|
|
2
2
|
InMemoryStorage,
|
|
3
3
|
STORAGE_KEYS,
|
|
4
4
|
TrackingManager,
|
|
5
|
+
buildFontFaceCss,
|
|
6
|
+
buildFontFamilyValue,
|
|
5
7
|
buildSurveyIdentity,
|
|
6
|
-
createDefaultStorage
|
|
7
|
-
|
|
8
|
+
createDefaultStorage,
|
|
9
|
+
sdkWarn,
|
|
10
|
+
setLogger
|
|
11
|
+
} from "./chunk-XOTM5CHX.mjs";
|
|
8
12
|
|
|
9
13
|
// src/types/index.ts
|
|
10
14
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
@@ -199,10 +203,12 @@ function buildSurveyHtml(opts) {
|
|
|
199
203
|
const pid = JSON.stringify(opts.productId);
|
|
200
204
|
const profileJson = JSON.stringify(opts.profile ?? []);
|
|
201
205
|
const metaJson = JSON.stringify(opts.metadata ?? []);
|
|
206
|
+
const fontFaceCss = opts.font ? buildFontFaceCss(opts.font.family, opts.font.url) : "";
|
|
207
|
+
const fontFamilyValue = opts.font ? buildFontFamilyValue(opts.font.family) : "-apple-system,system-ui,sans-serif";
|
|
202
208
|
return `<!DOCTYPE html><html><head>
|
|
203
209
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
204
210
|
<meta name="color-scheme" content="light"/>
|
|
205
|
-
<style
|
|
211
|
+
<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>
|
|
206
212
|
</head><body>
|
|
207
213
|
<div id="mf"></div>
|
|
208
214
|
<script>
|
|
@@ -253,17 +259,17 @@ var ReactNativePopupRenderer = class {
|
|
|
253
259
|
}
|
|
254
260
|
init() {
|
|
255
261
|
}
|
|
256
|
-
show(surveyId, productId, _actions, emit, onClose, env = "production", userId,
|
|
262
|
+
show(surveyId, productId, _actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
|
|
257
263
|
this.emitFn = emit;
|
|
258
264
|
this.onCloseFn = onClose;
|
|
259
265
|
this.currentSurveyId = surveyId;
|
|
260
266
|
this.partialEmitted = false;
|
|
261
267
|
const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
|
|
262
|
-
const html = buildSurveyHtml({ surveyId, productId, env, profile, metadata });
|
|
268
|
+
const html = buildSurveyHtml({ surveyId, productId, env, profile, metadata, font: style?.font });
|
|
263
269
|
if (this.options.onShow) {
|
|
264
270
|
this.options.onShow({ surveyId, productId, html });
|
|
265
271
|
} else {
|
|
266
|
-
|
|
272
|
+
sdkWarn(
|
|
267
273
|
"[Deepdots] ReactNativePopupRenderer sin onShow: pasa { onShow } a new ReactNativePopupRenderer({...}) para montar el WebView del survey."
|
|
268
274
|
);
|
|
269
275
|
}
|
|
@@ -355,7 +361,7 @@ var BrowserPopupRenderer = class {
|
|
|
355
361
|
if (!this.container) return;
|
|
356
362
|
this.visible = true;
|
|
357
363
|
const container = this.container;
|
|
358
|
-
void import("./renderPopup-
|
|
364
|
+
void import("./renderPopup-EZKDMLVZ.mjs").then(({ renderPopup }) => {
|
|
359
365
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
|
|
360
366
|
});
|
|
361
367
|
}
|
|
@@ -377,12 +383,13 @@ function createDefaultRenderer() {
|
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
// src/analytics/analytics-manager.ts
|
|
380
|
-
|
|
381
|
-
|
|
386
|
+
function createDryRunSink(log = console.log) {
|
|
387
|
+
return (payload) => log(
|
|
382
388
|
"[DeepdotsAnalytics] (dry-run \xB7 NO enviado \xB7 sin init.analytics) POST /sdk/feedback \u2192",
|
|
383
389
|
JSON.stringify(payload, null, 2)
|
|
384
390
|
);
|
|
385
|
-
}
|
|
391
|
+
}
|
|
392
|
+
var dryRunSink = createDryRunSink();
|
|
386
393
|
var AnalyticsManager = class {
|
|
387
394
|
constructor(options = {}) {
|
|
388
395
|
this.events = [];
|
|
@@ -897,7 +904,7 @@ var CrashReporter = class {
|
|
|
897
904
|
}
|
|
898
905
|
/** Instala los handlers globales de errores no capturados (no-op sin `window`). */
|
|
899
906
|
install() {
|
|
900
|
-
if (typeof window === "undefined") return;
|
|
907
|
+
if (typeof window === "undefined" || typeof window.addEventListener !== "function") return;
|
|
901
908
|
window.addEventListener("error", (e) => {
|
|
902
909
|
if (!this.isEnabled()) return;
|
|
903
910
|
this.captureUnhandled(e.error ?? e.message ?? "error");
|
|
@@ -949,6 +956,8 @@ var DeepdotsPopups = class {
|
|
|
949
956
|
this.triggers = [];
|
|
950
957
|
this.initialized = false;
|
|
951
958
|
this.renderer = createDefaultRenderer();
|
|
959
|
+
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
960
|
+
this.logger = console;
|
|
952
961
|
this.popupContainer = null;
|
|
953
962
|
// deprecated: mantenido para compatibilidad interna
|
|
954
963
|
this.popupDefinitions = [];
|
|
@@ -984,6 +993,8 @@ var DeepdotsPopups = class {
|
|
|
984
993
|
}
|
|
985
994
|
/** Initialize the SDK with configuration */
|
|
986
995
|
init(config) {
|
|
996
|
+
this.logger = config.logger ?? console;
|
|
997
|
+
setLogger(this.logger);
|
|
987
998
|
if (this.initialized) {
|
|
988
999
|
this.log("SDK already initialized");
|
|
989
1000
|
return;
|
|
@@ -1023,7 +1034,7 @@ var DeepdotsPopups = class {
|
|
|
1023
1034
|
onSessionId: (id) => {
|
|
1024
1035
|
this.analyticsFeedbackSessionId = id;
|
|
1025
1036
|
}
|
|
1026
|
-
}) :
|
|
1037
|
+
}) : createDryRunSink((...a) => this.logger.log(...a));
|
|
1027
1038
|
const device = config.device ?? collectDeviceInfo(config.appVersion);
|
|
1028
1039
|
this.analytics = new AnalyticsManager({
|
|
1029
1040
|
sink: analyticsSink,
|
|
@@ -1676,7 +1687,7 @@ var DeepdotsPopups = class {
|
|
|
1676
1687
|
}
|
|
1677
1688
|
if (!this.popupContainer) return;
|
|
1678
1689
|
const container = this.popupContainer;
|
|
1679
|
-
void import("./renderPopup-
|
|
1690
|
+
void import("./renderPopup-EZKDMLVZ.mjs").then(({ renderPopup }) => {
|
|
1680
1691
|
renderPopup(
|
|
1681
1692
|
container,
|
|
1682
1693
|
surveyId,
|
|
@@ -1732,7 +1743,8 @@ var DeepdotsPopups = class {
|
|
|
1732
1743
|
try {
|
|
1733
1744
|
listener(event);
|
|
1734
1745
|
} catch (error) {
|
|
1735
|
-
|
|
1746
|
+
if (this.logger.error) this.logger.error("Error in event listener:", error);
|
|
1747
|
+
else this.logger.log("Error in event listener:", error);
|
|
1736
1748
|
}
|
|
1737
1749
|
});
|
|
1738
1750
|
}
|
|
@@ -1740,7 +1752,7 @@ var DeepdotsPopups = class {
|
|
|
1740
1752
|
/** Log debug messages */
|
|
1741
1753
|
log(...args) {
|
|
1742
1754
|
if (this.config?.debug) {
|
|
1743
|
-
|
|
1755
|
+
this.logger.log("[DeepdotsPopups]", ...args);
|
|
1744
1756
|
}
|
|
1745
1757
|
}
|
|
1746
1758
|
/** External debug method for triggers */
|