@magicfeedback/popup-sdk 1.1.5 → 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/{chunk-LSTKGFU7.mjs → chunk-4UXOEIAB.mjs} +21 -2
- package/dist/chunk-4UXOEIAB.mjs.map +1 -0
- package/dist/{chunk-7TOLYAFL.mjs → chunk-XOTM5CHX.mjs} +21 -2
- package/dist/chunk-XOTM5CHX.mjs.map +1 -0
- package/dist/index.d.mts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +44 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -12
- package/dist/index.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 +44 -12
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +20 -12
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-MES7IINW.mjs → renderPopup-EZKDMLVZ.mjs} +10 -7
- package/dist/renderPopup-EZKDMLVZ.mjs.map +1 -0
- package/dist/{renderPopup-YNH2TD3B.mjs → renderPopup-PS3NJDUR.mjs} +10 -7
- package/dist/renderPopup-PS3NJDUR.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-7TOLYAFL.mjs.map +0 -1
- package/dist/chunk-LSTKGFU7.mjs.map +0 -1
- package/dist/renderPopup-MES7IINW.mjs.map +0 -1
- package/dist/renderPopup-YNH2TD3B.mjs.map +0 -1
package/dist/react-native.d.mts
CHANGED
|
@@ -105,6 +105,17 @@ interface AnalyticsKeys {
|
|
|
105
105
|
* Configuration options for initializing the DeepdotsPopups SDK
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Custom logger to receive the SDK's debug output instead of the console.
|
|
110
|
+
* Only `log` is required; `warn`/`error`/`info` fall back to `log` when omitted.
|
|
111
|
+
* Lets the host pipe debug output to a file, Firebase, etc. `console` satisfies this shape.
|
|
112
|
+
*/
|
|
113
|
+
interface DeepdotsLogger {
|
|
114
|
+
log: (...args: unknown[]) => void;
|
|
115
|
+
warn?: (...args: unknown[]) => void;
|
|
116
|
+
error?: (...args: unknown[]) => void;
|
|
117
|
+
info?: (...args: unknown[]) => void;
|
|
118
|
+
}
|
|
108
119
|
interface DeepdotsInitParams {
|
|
109
120
|
/** API key for authentication */
|
|
110
121
|
apiKey?: string;
|
|
@@ -112,6 +123,8 @@ interface DeepdotsInitParams {
|
|
|
112
123
|
nodeEnv?: 'development' | 'production';
|
|
113
124
|
/** Enable debug logging */
|
|
114
125
|
debug?: boolean;
|
|
126
|
+
/** Custom logger for debug output. When set (and `debug` is true), the SDK routes its logs here instead of `console`. Default: `console`. */
|
|
127
|
+
logger?: DeepdotsLogger;
|
|
115
128
|
/** Optional user id to send with popup events */
|
|
116
129
|
userId?: string;
|
|
117
130
|
/** Starts tracking enabled (default) or disabled (e.g. until consent is granted). Equivalent to calling `setTrackingEnabled` after init. */
|
|
@@ -280,6 +293,8 @@ declare class DeepdotsPopups {
|
|
|
280
293
|
private triggers;
|
|
281
294
|
private initialized;
|
|
282
295
|
private renderer;
|
|
296
|
+
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
297
|
+
private logger;
|
|
283
298
|
private popupContainer;
|
|
284
299
|
private popupDefinitions;
|
|
285
300
|
private popupsLoaded;
|
package/dist/react-native.d.ts
CHANGED
|
@@ -105,6 +105,17 @@ interface AnalyticsKeys {
|
|
|
105
105
|
* Configuration options for initializing the DeepdotsPopups SDK
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Custom logger to receive the SDK's debug output instead of the console.
|
|
110
|
+
* Only `log` is required; `warn`/`error`/`info` fall back to `log` when omitted.
|
|
111
|
+
* Lets the host pipe debug output to a file, Firebase, etc. `console` satisfies this shape.
|
|
112
|
+
*/
|
|
113
|
+
interface DeepdotsLogger {
|
|
114
|
+
log: (...args: unknown[]) => void;
|
|
115
|
+
warn?: (...args: unknown[]) => void;
|
|
116
|
+
error?: (...args: unknown[]) => void;
|
|
117
|
+
info?: (...args: unknown[]) => void;
|
|
118
|
+
}
|
|
108
119
|
interface DeepdotsInitParams {
|
|
109
120
|
/** API key for authentication */
|
|
110
121
|
apiKey?: string;
|
|
@@ -112,6 +123,8 @@ interface DeepdotsInitParams {
|
|
|
112
123
|
nodeEnv?: 'development' | 'production';
|
|
113
124
|
/** Enable debug logging */
|
|
114
125
|
debug?: boolean;
|
|
126
|
+
/** Custom logger for debug output. When set (and `debug` is true), the SDK routes its logs here instead of `console`. Default: `console`. */
|
|
127
|
+
logger?: DeepdotsLogger;
|
|
115
128
|
/** Optional user id to send with popup events */
|
|
116
129
|
userId?: string;
|
|
117
130
|
/** Starts tracking enabled (default) or disabled (e.g. until consent is granted). Equivalent to calling `setTrackingEnabled` after init. */
|
|
@@ -280,6 +293,8 @@ declare class DeepdotsPopups {
|
|
|
280
293
|
private triggers;
|
|
281
294
|
private initialized;
|
|
282
295
|
private renderer;
|
|
296
|
+
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
297
|
+
private logger;
|
|
283
298
|
private popupContainer;
|
|
284
299
|
private popupDefinitions;
|
|
285
300
|
private popupsLoaded;
|
package/dist/react-native.js
CHANGED
|
@@ -178,6 +178,27 @@ var init_font = __esm({
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
+
// src/util/logger.ts
|
|
182
|
+
function setLogger(logger) {
|
|
183
|
+
active = logger ?? console;
|
|
184
|
+
}
|
|
185
|
+
function sdkLog(...args) {
|
|
186
|
+
active.log(...args);
|
|
187
|
+
}
|
|
188
|
+
function sdkWarn(...args) {
|
|
189
|
+
(active.warn ?? active.log)(...args);
|
|
190
|
+
}
|
|
191
|
+
function sdkError(...args) {
|
|
192
|
+
(active.error ?? active.log)(...args);
|
|
193
|
+
}
|
|
194
|
+
var active;
|
|
195
|
+
var init_logger = __esm({
|
|
196
|
+
"src/util/logger.ts"() {
|
|
197
|
+
"use strict";
|
|
198
|
+
active = console;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
181
202
|
// src/assets/style.css
|
|
182
203
|
var style_default;
|
|
183
204
|
var init_style = __esm({
|
|
@@ -1431,7 +1452,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1431
1452
|
let formInstance = null;
|
|
1432
1453
|
try {
|
|
1433
1454
|
if (!import_native.default || typeof import_native.default.form !== "function") {
|
|
1434
|
-
|
|
1455
|
+
sdkWarn("[MagicFeedback] form() no disponible. Fallback manual.");
|
|
1435
1456
|
setLoading(false);
|
|
1436
1457
|
return;
|
|
1437
1458
|
}
|
|
@@ -1518,7 +1539,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1518
1539
|
}
|
|
1519
1540
|
}
|
|
1520
1541
|
if (s.startMessage && s.startMessage !== "") {
|
|
1521
|
-
|
|
1542
|
+
sdkLog(s.startMessage);
|
|
1522
1543
|
updateButtons("start");
|
|
1523
1544
|
} else {
|
|
1524
1545
|
updateButtons("in_progress_first");
|
|
@@ -1573,11 +1594,11 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
1573
1594
|
}
|
|
1574
1595
|
};
|
|
1575
1596
|
formInstance.generate(formDivId, generateOptions).catch((err) => {
|
|
1576
|
-
|
|
1597
|
+
sdkError("[MagicFeedback] Error generating form:", err);
|
|
1577
1598
|
setLoading(false);
|
|
1578
1599
|
});
|
|
1579
1600
|
} catch (e) {
|
|
1580
|
-
|
|
1601
|
+
sdkError("[MagicFeedback] Exception initializing form:", e);
|
|
1581
1602
|
setLoading(false);
|
|
1582
1603
|
}
|
|
1583
1604
|
}
|
|
@@ -1587,6 +1608,7 @@ var init_renderPopup = __esm({
|
|
|
1587
1608
|
"use strict";
|
|
1588
1609
|
init_tracking_manager();
|
|
1589
1610
|
init_font();
|
|
1611
|
+
init_logger();
|
|
1590
1612
|
import_native = __toESM(require("@magicfeedback/native"));
|
|
1591
1613
|
init_style();
|
|
1592
1614
|
}
|
|
@@ -1848,6 +1870,7 @@ function buildSurveyHtml(opts) {
|
|
|
1848
1870
|
}
|
|
1849
1871
|
|
|
1850
1872
|
// src/platform/react-native-renderer.ts
|
|
1873
|
+
init_logger();
|
|
1851
1874
|
var ReactNativePopupRenderer = class {
|
|
1852
1875
|
constructor(options = {}) {
|
|
1853
1876
|
this.options = options;
|
|
@@ -1868,7 +1891,7 @@ var ReactNativePopupRenderer = class {
|
|
|
1868
1891
|
if (this.options.onShow) {
|
|
1869
1892
|
this.options.onShow({ surveyId, productId, html });
|
|
1870
1893
|
} else {
|
|
1871
|
-
|
|
1894
|
+
sdkWarn(
|
|
1872
1895
|
"[Deepdots] ReactNativePopupRenderer sin onShow: pasa { onShow } a new ReactNativePopupRenderer({...}) para montar el WebView del survey."
|
|
1873
1896
|
);
|
|
1874
1897
|
}
|
|
@@ -1985,12 +2008,13 @@ function createDefaultRenderer() {
|
|
|
1985
2008
|
init_tracking_manager();
|
|
1986
2009
|
|
|
1987
2010
|
// src/analytics/analytics-manager.ts
|
|
1988
|
-
|
|
1989
|
-
|
|
2011
|
+
function createDryRunSink(log = console.log) {
|
|
2012
|
+
return (payload) => log(
|
|
1990
2013
|
"[DeepdotsAnalytics] (dry-run \xB7 NO enviado \xB7 sin init.analytics) POST /sdk/feedback \u2192",
|
|
1991
2014
|
JSON.stringify(payload, null, 2)
|
|
1992
2015
|
);
|
|
1993
|
-
}
|
|
2016
|
+
}
|
|
2017
|
+
var dryRunSink = createDryRunSink();
|
|
1994
2018
|
var AnalyticsManager = class {
|
|
1995
2019
|
constructor(options = {}) {
|
|
1996
2020
|
this.events = [];
|
|
@@ -2506,7 +2530,7 @@ var CrashReporter = class {
|
|
|
2506
2530
|
}
|
|
2507
2531
|
/** Instala los handlers globales de errores no capturados (no-op sin `window`). */
|
|
2508
2532
|
install() {
|
|
2509
|
-
if (typeof window === "undefined") return;
|
|
2533
|
+
if (typeof window === "undefined" || typeof window.addEventListener !== "function") return;
|
|
2510
2534
|
window.addEventListener("error", (e) => {
|
|
2511
2535
|
if (!this.isEnabled()) return;
|
|
2512
2536
|
this.captureUnhandled(e.error ?? e.message ?? "error");
|
|
@@ -2530,6 +2554,9 @@ var CrashReporter = class {
|
|
|
2530
2554
|
}
|
|
2531
2555
|
};
|
|
2532
2556
|
|
|
2557
|
+
// src/core/deepdots-popups.ts
|
|
2558
|
+
init_logger();
|
|
2559
|
+
|
|
2533
2560
|
// src/analytics/messaging.ts
|
|
2534
2561
|
function buildMessageParams(stage, o) {
|
|
2535
2562
|
const p = {
|
|
@@ -2558,6 +2585,8 @@ var DeepdotsPopups = class {
|
|
|
2558
2585
|
this.triggers = [];
|
|
2559
2586
|
this.initialized = false;
|
|
2560
2587
|
this.renderer = createDefaultRenderer();
|
|
2588
|
+
/** Logger para el output de debug. Default `console`; el host puede inyectar el suyo en init(). */
|
|
2589
|
+
this.logger = console;
|
|
2561
2590
|
this.popupContainer = null;
|
|
2562
2591
|
// deprecated: mantenido para compatibilidad interna
|
|
2563
2592
|
this.popupDefinitions = [];
|
|
@@ -2593,6 +2622,8 @@ var DeepdotsPopups = class {
|
|
|
2593
2622
|
}
|
|
2594
2623
|
/** Initialize the SDK with configuration */
|
|
2595
2624
|
init(config) {
|
|
2625
|
+
this.logger = config.logger ?? console;
|
|
2626
|
+
setLogger(this.logger);
|
|
2596
2627
|
if (this.initialized) {
|
|
2597
2628
|
this.log("SDK already initialized");
|
|
2598
2629
|
return;
|
|
@@ -2632,7 +2663,7 @@ var DeepdotsPopups = class {
|
|
|
2632
2663
|
onSessionId: (id) => {
|
|
2633
2664
|
this.analyticsFeedbackSessionId = id;
|
|
2634
2665
|
}
|
|
2635
|
-
}) :
|
|
2666
|
+
}) : createDryRunSink((...a) => this.logger.log(...a));
|
|
2636
2667
|
const device = config.device ?? collectDeviceInfo(config.appVersion);
|
|
2637
2668
|
this.analytics = new AnalyticsManager({
|
|
2638
2669
|
sink: analyticsSink,
|
|
@@ -3341,7 +3372,8 @@ var DeepdotsPopups = class {
|
|
|
3341
3372
|
try {
|
|
3342
3373
|
listener(event);
|
|
3343
3374
|
} catch (error) {
|
|
3344
|
-
|
|
3375
|
+
if (this.logger.error) this.logger.error("Error in event listener:", error);
|
|
3376
|
+
else this.logger.log("Error in event listener:", error);
|
|
3345
3377
|
}
|
|
3346
3378
|
});
|
|
3347
3379
|
}
|
|
@@ -3349,7 +3381,7 @@ var DeepdotsPopups = class {
|
|
|
3349
3381
|
/** Log debug messages */
|
|
3350
3382
|
log(...args) {
|
|
3351
3383
|
if (this.config?.debug) {
|
|
3352
|
-
|
|
3384
|
+
this.logger.log("[DeepdotsPopups]", ...args);
|
|
3353
3385
|
}
|
|
3354
3386
|
}
|
|
3355
3387
|
/** External debug method for triggers */
|