@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.
@@ -153,7 +153,8 @@ interface DeepdotsInitParams {
153
153
  device?: DeviceInfo;
154
154
  /**
155
155
  * Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
156
- * to the configured integration; if missing, it stays in dry-run mode (console.log only).
156
+ * to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
157
+ * logged when `debug` is true.
157
158
  */
158
159
  analytics?: AnalyticsKeys;
159
160
  /**
@@ -153,7 +153,8 @@ interface DeepdotsInitParams {
153
153
  device?: DeviceInfo;
154
154
  /**
155
155
  * Analytics channel keys (`POST /sdk/feedback`). If provided, analytics is SENT
156
- * to the configured integration; if missing, it stays in dry-run mode (console.log only).
156
+ * to the configured integration; if missing, it stays in dry-run mode: nothing is sent, and the payload is only
157
+ * logged when `debug` is true.
157
158
  */
158
159
  analytics?: AnalyticsKeys;
159
160
  /**
@@ -4449,7 +4449,7 @@ function createFeedbackSink(options) {
4449
4449
 
4450
4450
  // src/tracking/navigation-observer.ts
4451
4451
  var UUID_PREFIX = /^[0-9a-f]{8}-[0-9a-f]{4}-/i;
4452
- function normalizeScreen(href) {
4452
+ function screenPath(href) {
4453
4453
  let pathAndHash;
4454
4454
  try {
4455
4455
  const u = new URL(href, "http://deepdots.local");
@@ -4457,7 +4457,10 @@ function normalizeScreen(href) {
4457
4457
  } catch {
4458
4458
  pathAndHash = href;
4459
4459
  }
4460
- pathAndHash = pathAndHash.replace(/\?[^#]*/g, "");
4460
+ return pathAndHash.replace(/\?[^#]*/g, "") || "/";
4461
+ }
4462
+ function normalizeScreen(href) {
4463
+ const pathAndHash = screenPath(href);
4461
4464
  const collapsed = pathAndHash.split("/").map((seg) => /^[0-9]+$/.test(seg) || UUID_PREFIX.test(seg) ? ":id" : seg).join("/");
4462
4465
  return collapsed || "/";
4463
4466
  }
@@ -4465,6 +4468,7 @@ var NavigationObserver = class {
4465
4468
  constructor(options = {}) {
4466
4469
  this.listeners = /* @__PURE__ */ new Set();
4467
4470
  this.currentScreen = null;
4471
+ this.currentPath = null;
4468
4472
  this.entryAt = 0;
4469
4473
  this.installed = false;
4470
4474
  this.domHandlers = [];
@@ -4476,20 +4480,23 @@ var NavigationObserver = class {
4476
4480
  /** Fija la pantalla inicial (sin emitir visita; su duración se cierra al salir). */
4477
4481
  begin(href) {
4478
4482
  this.currentScreen = normalizeScreen(href);
4483
+ this.currentPath = screenPath(href);
4479
4484
  this.entryAt = this.now();
4480
4485
  }
4481
4486
  /** Navega a una pantalla nueva: cierra la anterior (emite visita) y abre la nueva. */
4482
4487
  visit(href) {
4483
- const next = normalizeScreen(href);
4484
- if (next === this.currentScreen) return;
4488
+ const nextPath = screenPath(href);
4489
+ if (this.currentScreen != null && nextPath === this.currentPath) return;
4485
4490
  this.closeCurrent();
4486
- this.currentScreen = next;
4491
+ this.currentScreen = normalizeScreen(href);
4492
+ this.currentPath = nextPath;
4487
4493
  this.entryAt = this.now();
4488
4494
  }
4489
4495
  /** Cierra la pantalla actual emitiendo su visita (p. ej. al cerrar la app/pestaña). */
4490
4496
  stop() {
4491
4497
  this.closeCurrent();
4492
4498
  this.currentScreen = null;
4499
+ this.currentPath = null;
4493
4500
  }
4494
4501
  /**
4495
4502
  * Olvida la pantalla actual SIN emitir su visita. Para una sesión que el backend ya dio
@@ -4498,6 +4505,7 @@ var NavigationObserver = class {
4498
4505
  */
4499
4506
  discard() {
4500
4507
  this.currentScreen = null;
4508
+ this.currentPath = null;
4501
4509
  }
4502
4510
  /**
4503
4511
  * Retoma el seguimiento en la pantalla actual tras un `stop()`, cuando se abre una sesión
@@ -4513,6 +4521,7 @@ var NavigationObserver = class {
4513
4521
  const exit = this.now();
4514
4522
  const visit = {
4515
4523
  screen: this.currentScreen,
4524
+ path: this.currentPath ?? this.currentScreen,
4516
4525
  entry: this.entryAt,
4517
4526
  exit,
4518
4527
  durationSeconds: Math.max(0, Math.round((exit - this.entryAt) / 1e3))
@@ -5171,7 +5180,9 @@ var DeepdotsPopups = class {
5171
5180
  onSessionReset: () => {
5172
5181
  this.analyticsFeedbackSessionId = void 0;
5173
5182
  }
5174
- }) : createDryRunSink((...a) => this.logger.log(...a));
5183
+ }) : createDryRunSink((...a) => {
5184
+ if (this.config?.debug) this.logger.log(...a);
5185
+ });
5175
5186
  const device = config.device ?? collectDeviceInfo(config.appVersion);
5176
5187
  this.language = resolveLanguage({
5177
5188
  explicit: config.language,
@@ -5203,7 +5214,9 @@ var DeepdotsPopups = class {
5203
5214
  this.geoWanted = this.geoEnabled && !!config.analytics;
5204
5215
  this.resolveGeo();
5205
5216
  this.navObserver = new NavigationObserver();
5206
- this.navObserver.onVisit((v) => this.track("deepdots_page_view", { screen: v.screen, duration_seconds: v.durationSeconds }));
5217
+ this.navObserver.onVisit(
5218
+ (v) => this.track("deepdots_page_view", { screen: v.screen, path: v.path, duration_seconds: v.durationSeconds })
5219
+ );
5207
5220
  this.navObserver.install();
5208
5221
  this.engagement = new EngagementTracker();
5209
5222
  this.setupAnalyticsFlush();