@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.
@@ -5,8 +5,10 @@ import {
5
5
  buildFontFaceCss,
6
6
  buildFontFamilyValue,
7
7
  buildSurveyIdentity,
8
- createDefaultStorage
9
- } from "./chunk-LSTKGFU7.mjs";
8
+ createDefaultStorage,
9
+ sdkWarn,
10
+ setLogger
11
+ } from "./chunk-4UXOEIAB.mjs";
10
12
 
11
13
  // src/react-native/index.tsx
12
14
  import { createContext, useContext, useEffect, useRef, useState } from "react";
@@ -272,7 +274,7 @@ var ReactNativePopupRenderer = class {
272
274
  if (this.options.onShow) {
273
275
  this.options.onShow({ surveyId, productId, html });
274
276
  } else {
275
- console.warn(
277
+ sdkWarn(
276
278
  "[Deepdots] ReactNativePopupRenderer sin onShow: pasa { onShow } a new ReactNativePopupRenderer({...}) para montar el WebView del survey."
277
279
  );
278
280
  }
@@ -364,7 +366,7 @@ var BrowserPopupRenderer = class {
364
366
  if (!this.container) return;
365
367
  this.visible = true;
366
368
  const container = this.container;
367
- void import("./renderPopup-YNH2TD3B.mjs").then(({ renderPopup }) => {
369
+ void import("./renderPopup-PS3NJDUR.mjs").then(({ renderPopup }) => {
368
370
  renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
369
371
  });
370
372
  }
@@ -386,12 +388,13 @@ function createDefaultRenderer() {
386
388
  }
387
389
 
388
390
  // src/analytics/analytics-manager.ts
389
- var dryRunSink = (payload) => {
390
- console.log(
391
+ function createDryRunSink(log = console.log) {
392
+ return (payload) => log(
391
393
  "[DeepdotsAnalytics] (dry-run \xB7 NO enviado \xB7 sin init.analytics) POST /sdk/feedback \u2192",
392
394
  JSON.stringify(payload, null, 2)
393
395
  );
394
- };
396
+ }
397
+ var dryRunSink = createDryRunSink();
395
398
  var AnalyticsManager = class {
396
399
  constructor(options = {}) {
397
400
  this.events = [];
@@ -906,7 +909,7 @@ var CrashReporter = class {
906
909
  }
907
910
  /** Instala los handlers globales de errores no capturados (no-op sin `window`). */
908
911
  install() {
909
- if (typeof window === "undefined") return;
912
+ if (typeof window === "undefined" || typeof window.addEventListener !== "function") return;
910
913
  window.addEventListener("error", (e) => {
911
914
  if (!this.isEnabled()) return;
912
915
  this.captureUnhandled(e.error ?? e.message ?? "error");
@@ -958,6 +961,8 @@ var DeepdotsPopups = class {
958
961
  this.triggers = [];
959
962
  this.initialized = false;
960
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;
961
966
  this.popupContainer = null;
962
967
  // deprecated: mantenido para compatibilidad interna
963
968
  this.popupDefinitions = [];
@@ -993,6 +998,8 @@ var DeepdotsPopups = class {
993
998
  }
994
999
  /** Initialize the SDK with configuration */
995
1000
  init(config) {
1001
+ this.logger = config.logger ?? console;
1002
+ setLogger(this.logger);
996
1003
  if (this.initialized) {
997
1004
  this.log("SDK already initialized");
998
1005
  return;
@@ -1032,7 +1039,7 @@ var DeepdotsPopups = class {
1032
1039
  onSessionId: (id) => {
1033
1040
  this.analyticsFeedbackSessionId = id;
1034
1041
  }
1035
- }) : void 0;
1042
+ }) : createDryRunSink((...a) => this.logger.log(...a));
1036
1043
  const device = config.device ?? collectDeviceInfo(config.appVersion);
1037
1044
  this.analytics = new AnalyticsManager({
1038
1045
  sink: analyticsSink,
@@ -1685,7 +1692,7 @@ var DeepdotsPopups = class {
1685
1692
  }
1686
1693
  if (!this.popupContainer) return;
1687
1694
  const container = this.popupContainer;
1688
- void import("./renderPopup-YNH2TD3B.mjs").then(({ renderPopup }) => {
1695
+ void import("./renderPopup-PS3NJDUR.mjs").then(({ renderPopup }) => {
1689
1696
  renderPopup(
1690
1697
  container,
1691
1698
  surveyId,
@@ -1741,7 +1748,8 @@ var DeepdotsPopups = class {
1741
1748
  try {
1742
1749
  listener(event);
1743
1750
  } catch (error) {
1744
- console.error("Error in event listener:", error);
1751
+ if (this.logger.error) this.logger.error("Error in event listener:", error);
1752
+ else this.logger.log("Error in event listener:", error);
1745
1753
  }
1746
1754
  });
1747
1755
  }
@@ -1749,7 +1757,7 @@ var DeepdotsPopups = class {
1749
1757
  /** Log debug messages */
1750
1758
  log(...args) {
1751
1759
  if (this.config?.debug) {
1752
- console.log("[DeepdotsPopups]", ...args);
1760
+ this.logger.log("[DeepdotsPopups]", ...args);
1753
1761
  }
1754
1762
  }
1755
1763
  /** External debug method for triggers */