@magicfeedback/popup-sdk 1.8.4 → 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.
@@ -1293,7 +1293,7 @@ function createFeedbackSink(options) {
1293
1293
 
1294
1294
  // src/tracking/navigation-observer.ts
1295
1295
  var UUID_PREFIX = /^[0-9a-f]{8}-[0-9a-f]{4}-/i;
1296
- function normalizeScreen(href) {
1296
+ function screenPath(href) {
1297
1297
  let pathAndHash;
1298
1298
  try {
1299
1299
  const u = new URL(href, "http://deepdots.local");
@@ -1301,7 +1301,10 @@ function normalizeScreen(href) {
1301
1301
  } catch {
1302
1302
  pathAndHash = href;
1303
1303
  }
1304
- pathAndHash = pathAndHash.replace(/\?[^#]*/g, "");
1304
+ return pathAndHash.replace(/\?[^#]*/g, "") || "/";
1305
+ }
1306
+ function normalizeScreen(href) {
1307
+ const pathAndHash = screenPath(href);
1305
1308
  const collapsed = pathAndHash.split("/").map((seg) => /^[0-9]+$/.test(seg) || UUID_PREFIX.test(seg) ? ":id" : seg).join("/");
1306
1309
  return collapsed || "/";
1307
1310
  }
@@ -1309,6 +1312,7 @@ var NavigationObserver = class {
1309
1312
  constructor(options = {}) {
1310
1313
  this.listeners = /* @__PURE__ */ new Set();
1311
1314
  this.currentScreen = null;
1315
+ this.currentPath = null;
1312
1316
  this.entryAt = 0;
1313
1317
  this.installed = false;
1314
1318
  this.domHandlers = [];
@@ -1320,20 +1324,23 @@ var NavigationObserver = class {
1320
1324
  /** Fija la pantalla inicial (sin emitir visita; su duración se cierra al salir). */
1321
1325
  begin(href) {
1322
1326
  this.currentScreen = normalizeScreen(href);
1327
+ this.currentPath = screenPath(href);
1323
1328
  this.entryAt = this.now();
1324
1329
  }
1325
1330
  /** Navega a una pantalla nueva: cierra la anterior (emite visita) y abre la nueva. */
1326
1331
  visit(href) {
1327
- const next = normalizeScreen(href);
1328
- if (next === this.currentScreen) return;
1332
+ const nextPath = screenPath(href);
1333
+ if (this.currentScreen != null && nextPath === this.currentPath) return;
1329
1334
  this.closeCurrent();
1330
- this.currentScreen = next;
1335
+ this.currentScreen = normalizeScreen(href);
1336
+ this.currentPath = nextPath;
1331
1337
  this.entryAt = this.now();
1332
1338
  }
1333
1339
  /** Cierra la pantalla actual emitiendo su visita (p. ej. al cerrar la app/pestaña). */
1334
1340
  stop() {
1335
1341
  this.closeCurrent();
1336
1342
  this.currentScreen = null;
1343
+ this.currentPath = null;
1337
1344
  }
1338
1345
  /**
1339
1346
  * Olvida la pantalla actual SIN emitir su visita. Para una sesión que el backend ya dio
@@ -1342,6 +1349,7 @@ var NavigationObserver = class {
1342
1349
  */
1343
1350
  discard() {
1344
1351
  this.currentScreen = null;
1352
+ this.currentPath = null;
1345
1353
  }
1346
1354
  /**
1347
1355
  * Retoma el seguimiento en la pantalla actual tras un `stop()`, cuando se abre una sesión
@@ -1357,6 +1365,7 @@ var NavigationObserver = class {
1357
1365
  const exit = this.now();
1358
1366
  const visit = {
1359
1367
  screen: this.currentScreen,
1368
+ path: this.currentPath ?? this.currentScreen,
1360
1369
  entry: this.entryAt,
1361
1370
  exit,
1362
1371
  durationSeconds: Math.max(0, Math.round((exit - this.entryAt) / 1e3))
@@ -2045,7 +2054,9 @@ var DeepdotsPopups = class {
2045
2054
  this.geoWanted = this.geoEnabled && !!config.analytics;
2046
2055
  this.resolveGeo();
2047
2056
  this.navObserver = new NavigationObserver();
2048
- this.navObserver.onVisit((v) => this.track("deepdots_page_view", { screen: v.screen, duration_seconds: v.durationSeconds }));
2057
+ this.navObserver.onVisit(
2058
+ (v) => this.track("deepdots_page_view", { screen: v.screen, path: v.path, duration_seconds: v.durationSeconds })
2059
+ );
2049
2060
  this.navObserver.install();
2050
2061
  this.engagement = new EngagementTracker();
2051
2062
  this.setupAnalyticsFlush();