@magicfeedback/popup-sdk 1.8.3 → 1.8.5

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/README.md CHANGED
@@ -121,7 +121,8 @@ Config fields:
121
121
  - `logger?: DeepdotsLogger` — replaces `console` for SDK logs
122
122
  - `trackingEnabled?: boolean` — starts analytics on (default) or off, for consent flows
123
123
  - `analytics?: { publicKey: string; integration: string }` — enables the real analytics
124
- delivery. Without it the analytics channel stays in dry-run and only logs the payload.
124
+ delivery. Without it the analytics channel stays in dry-run: nothing is sent, and the
125
+ payload is only logged when `debug` is on.
125
126
  - `geolocation?: boolean` — IP geolocation (country/city) for analytics, default `true`. It
126
127
  calls third-party services (`ipapi.co`, then `ipwho.is`, then `ipinfo.io` as fallbacks, 3 s
127
128
  timeout each, stopping at the first answer). It only runs when `analytics` is set, tracking
package/dist/index.d.mts CHANGED
@@ -257,7 +257,8 @@ interface DeepdotsInitParams {
257
257
  device?: DeviceInfo;
258
258
  /**
259
259
  * Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
260
- * to the configured integration; if missing, it stays in dry-run mode (console.log only).
260
+ * to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
261
+ * logged when `debug` is true.
261
262
  */
262
263
  analytics?: AnalyticsKeys;
263
264
  /**
package/dist/index.d.ts CHANGED
@@ -257,7 +257,8 @@ interface DeepdotsInitParams {
257
257
  device?: DeviceInfo;
258
258
  /**
259
259
  * Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
260
- * to the configured integration; if missing, it stays in dry-run mode (console.log only).
260
+ * to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
261
+ * logged when `debug` is true.
261
262
  */
262
263
  analytics?: AnalyticsKeys;
263
264
  /**
package/dist/index.js CHANGED
@@ -6889,7 +6889,7 @@ function createFeedbackSink(options) {
6889
6889
 
6890
6890
  // src/tracking/navigation-observer.ts
6891
6891
  var UUID_PREFIX = /^[0-9a-f]{8}-[0-9a-f]{4}-/i;
6892
- function normalizeScreen(href) {
6892
+ function screenPath(href) {
6893
6893
  let pathAndHash;
6894
6894
  try {
6895
6895
  const u = new URL(href, "http://deepdots.local");
@@ -6897,7 +6897,10 @@ function normalizeScreen(href) {
6897
6897
  } catch {
6898
6898
  pathAndHash = href;
6899
6899
  }
6900
- pathAndHash = pathAndHash.replace(/\?[^#]*/g, "");
6900
+ return pathAndHash.replace(/\?[^#]*/g, "") || "/";
6901
+ }
6902
+ function normalizeScreen(href) {
6903
+ const pathAndHash = screenPath(href);
6901
6904
  const collapsed = pathAndHash.split("/").map((seg) => /^[0-9]+$/.test(seg) || UUID_PREFIX.test(seg) ? ":id" : seg).join("/");
6902
6905
  return collapsed || "/";
6903
6906
  }
@@ -6905,6 +6908,7 @@ var NavigationObserver = class {
6905
6908
  constructor(options = {}) {
6906
6909
  this.listeners = /* @__PURE__ */ new Set();
6907
6910
  this.currentScreen = null;
6911
+ this.currentPath = null;
6908
6912
  this.entryAt = 0;
6909
6913
  this.installed = false;
6910
6914
  this.domHandlers = [];
@@ -6916,20 +6920,23 @@ var NavigationObserver = class {
6916
6920
  /** Fija la pantalla inicial (sin emitir visita; su duración se cierra al salir). */
6917
6921
  begin(href) {
6918
6922
  this.currentScreen = normalizeScreen(href);
6923
+ this.currentPath = screenPath(href);
6919
6924
  this.entryAt = this.now();
6920
6925
  }
6921
6926
  /** Navega a una pantalla nueva: cierra la anterior (emite visita) y abre la nueva. */
6922
6927
  visit(href) {
6923
- const next = normalizeScreen(href);
6924
- if (next === this.currentScreen) return;
6928
+ const nextPath = screenPath(href);
6929
+ if (this.currentScreen != null && nextPath === this.currentPath) return;
6925
6930
  this.closeCurrent();
6926
- this.currentScreen = next;
6931
+ this.currentScreen = normalizeScreen(href);
6932
+ this.currentPath = nextPath;
6927
6933
  this.entryAt = this.now();
6928
6934
  }
6929
6935
  /** Cierra la pantalla actual emitiendo su visita (p. ej. al cerrar la app/pestaña). */
6930
6936
  stop() {
6931
6937
  this.closeCurrent();
6932
6938
  this.currentScreen = null;
6939
+ this.currentPath = null;
6933
6940
  }
6934
6941
  /**
6935
6942
  * Olvida la pantalla actual SIN emitir su visita. Para una sesión que el backend ya dio
@@ -6938,6 +6945,7 @@ var NavigationObserver = class {
6938
6945
  */
6939
6946
  discard() {
6940
6947
  this.currentScreen = null;
6948
+ this.currentPath = null;
6941
6949
  }
6942
6950
  /**
6943
6951
  * Retoma el seguimiento en la pantalla actual tras un `stop()`, cuando se abre una sesión
@@ -6953,6 +6961,7 @@ var NavigationObserver = class {
6953
6961
  const exit = this.now();
6954
6962
  const visit = {
6955
6963
  screen: this.currentScreen,
6964
+ path: this.currentPath ?? this.currentScreen,
6956
6965
  entry: this.entryAt,
6957
6966
  exit,
6958
6967
  durationSeconds: Math.max(0, Math.round((exit - this.entryAt) / 1e3))
@@ -7611,7 +7620,9 @@ var DeepdotsPopups = class {
7611
7620
  onSessionReset: () => {
7612
7621
  this.analyticsFeedbackSessionId = void 0;
7613
7622
  }
7614
- }) : createDryRunSink((...a) => this.logger.log(...a));
7623
+ }) : createDryRunSink((...a) => {
7624
+ if (this.config?.debug) this.logger.log(...a);
7625
+ });
7615
7626
  const device = config.device ?? collectDeviceInfo(config.appVersion);
7616
7627
  this.language = resolveLanguage({
7617
7628
  explicit: config.language,
@@ -7643,7 +7654,9 @@ var DeepdotsPopups = class {
7643
7654
  this.geoWanted = this.geoEnabled && !!config.analytics;
7644
7655
  this.resolveGeo();
7645
7656
  this.navObserver = new NavigationObserver();
7646
- this.navObserver.onVisit((v) => this.track("deepdots_page_view", { screen: v.screen, duration_seconds: v.durationSeconds }));
7657
+ this.navObserver.onVisit(
7658
+ (v) => this.track("deepdots_page_view", { screen: v.screen, path: v.path, duration_seconds: v.durationSeconds })
7659
+ );
7647
7660
  this.navObserver.install();
7648
7661
  this.engagement = new EngagementTracker();
7649
7662
  this.setupAnalyticsFlush();