@dataxamas/tracker-js 2.1.3 → 2.3.0

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.
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+
6
+
7
+ exports.__publicField = __publicField;
@@ -0,0 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ export {
6
+ __publicField
7
+ };
package/dist/index.cjs CHANGED
@@ -1,4 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/constants.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-ETV4XYOV.cjs');
2
+
3
+ // src/constants.ts
2
4
  var BASE_URL = "https://dataxamas.com";
3
5
 
4
6
  // src/utils.ts
@@ -358,6 +360,9 @@ var DataxamasTracking = class {
358
360
  this.currentPage = isBrowser() ? window.location.pathname : "";
359
361
  this.heatMapEnabled = _nullishCoalesce(options.heatMapEnabled, () => ( true));
360
362
  this.replayEnabled = _nullishCoalesce(options.replayEnabled, () => ( true));
363
+ this.webVitalsEnabled = _nullishCoalesce(options.webVitalsEnabled, () => ( true));
364
+ this.pendingVitals = /* @__PURE__ */ new Map();
365
+ this.vitalsPath = "";
361
366
  this.replaySampleRate = 1;
362
367
  this.eventQueue = [];
363
368
  this.isProcessing = false;
@@ -418,6 +423,14 @@ var DataxamasTracking = class {
418
423
  this.processQueue();
419
424
  }, QUEUE_DELAY_MS);
420
425
  }
426
+ // Só os pares `utm_*`: o resto da query pode carregar token ou dado pessoal e não sai do browser.
427
+ utmQuery() {
428
+ const utm = new URLSearchParams();
429
+ new URLSearchParams(window.location.search).forEach((value, key) => {
430
+ if (key.startsWith("utm_")) utm.append(key, value);
431
+ });
432
+ return utm.toString() || void 0;
433
+ }
421
434
  async sendEvent({
422
435
  name,
423
436
  path = this.currentPage,
@@ -428,6 +441,7 @@ var DataxamasTracking = class {
428
441
  name,
429
442
  path,
430
443
  referrer: document.referrer,
444
+ query: name === "PAGE_VIEW" ? this.utmQuery() : void 0,
431
445
  sessionId: this.sessionId,
432
446
  data
433
447
  });
@@ -536,6 +550,49 @@ var DataxamasTracking = class {
536
550
  }, 1e3);
537
551
  });
538
552
  }
553
+ flushVitals() {
554
+ if (!this.sessionId || this.pendingVitals.size === 0) return;
555
+ const metrics = Array.from(this.pendingVitals.values());
556
+ this.pendingVitals.clear();
557
+ window.fetch(`${this.baseUrl}/api/v1/vitals`, {
558
+ method: "POST",
559
+ headers: { Authorization: `Bearer ${this.apiKey}`, "Content-Type": "application/json" },
560
+ body: JSON.stringify({
561
+ sessionId: this.sessionId,
562
+ path: this.vitalsPath,
563
+ viewportWidth: window.innerWidth,
564
+ metrics
565
+ }),
566
+ keepalive: true,
567
+ credentials: "omit"
568
+ }).catch(() => {
569
+ });
570
+ }
571
+ async trackWebVitals() {
572
+ if (!this.webVitalsEnabled) return;
573
+ this.vitalsPath = window.location.pathname;
574
+ let webVitals;
575
+ try {
576
+ webVitals = await Promise.resolve().then(() => _interopRequireWildcard(require("./web-vitals-TFHN3UGU.cjs")));
577
+ } catch (_) {
578
+ return;
579
+ }
580
+ const queue = (metric) => {
581
+ this.pendingVitals.set(`${metric.name}:${metric.id}`, {
582
+ id: metric.id,
583
+ name: metric.name,
584
+ value: metric.value,
585
+ navigationType: metric.navigationType
586
+ });
587
+ };
588
+ webVitals.onLCP(queue);
589
+ webVitals.onINP(queue);
590
+ webVitals.onCLS(queue);
591
+ document.addEventListener("visibilitychange", () => {
592
+ if (document.visibilityState === "hidden") this.flushVitals();
593
+ });
594
+ window.addEventListener("pagehide", () => this.flushVitals());
595
+ }
539
596
  measureReplay() {
540
597
  const doc = document.documentElement;
541
598
  const viewportWidth = window.innerWidth;
@@ -735,7 +792,7 @@ var DataxamasTracking = class {
735
792
  this.replayStarting = true;
736
793
  try {
737
794
  if (!this.rrwebRecord) {
738
- const { record } = await Promise.resolve().then(() => _interopRequireWildcard(require("./rrweb-M7O3D3Q3.cjs")));
795
+ const { record } = await Promise.resolve().then(() => _interopRequireWildcard(require("./rrweb-QFJCWYDQ.cjs")));
739
796
  this.rrwebRecord = record;
740
797
  }
741
798
  } catch (_) {
@@ -788,11 +845,17 @@ var DataxamasTracking = class {
788
845
  this.trackPageChanges();
789
846
  this.trackClicks();
790
847
  this.trackScroll();
848
+ this.trackWebVitals();
791
849
  this.fetchWebsiteConfig().then(() => {
792
850
  if (!this.replayEnabled || !this.isReplaySampled()) return;
793
851
  this.setupReplayLifecycle();
794
852
  });
795
853
  }
854
+ /** Evento customizado (ex.: `signup_done`), usado em metas e funis. Antes do `start()` não envia nada. */
855
+ track(name, data) {
856
+ if (!isBrowser()) return;
857
+ void this.sendEvent({ name, data });
858
+ }
796
859
  start() {
797
860
  if (!isBrowser()) {
798
861
  throw new Error("DataxamasTracking: This SDK can only be used in a browser environment.");
@@ -833,6 +896,7 @@ var Dataxamas = class {
833
896
  baseUrl,
834
897
  replayEnabled: _nullishCoalesce(options.replayEnabled, () => ( true)),
835
898
  heatMapEnabled: _nullishCoalesce(options.heatMapEnabled, () => ( true)),
899
+ webVitalsEnabled: _nullishCoalesce(options.webVitalsEnabled, () => ( true)),
836
900
  allowLocalhost: _nullishCoalesce(options.allowLocalhost, () => ( false))
837
901
  });
838
902
  this.crawlers = new DataxamasCrawlers({
package/dist/index.d.cts CHANGED
@@ -103,6 +103,7 @@ interface DataxamasTrackingOptions {
103
103
  allowLocalhost?: boolean;
104
104
  replayEnabled?: boolean;
105
105
  heatMapEnabled?: boolean;
106
+ webVitalsEnabled?: boolean;
106
107
  }
107
108
  declare class DataxamasTracking {
108
109
  private apiKey;
@@ -112,6 +113,9 @@ declare class DataxamasTracking {
112
113
  private currentPage;
113
114
  private heatMapEnabled;
114
115
  private replayEnabled;
116
+ private webVitalsEnabled;
117
+ private pendingVitals;
118
+ private vitalsPath;
115
119
  private replaySampleRate;
116
120
  private eventQueue;
117
121
  private isProcessing;
@@ -136,6 +140,7 @@ declare class DataxamasTracking {
136
140
  private getSessionId;
137
141
  private createSessionId;
138
142
  private processQueue;
143
+ private utmQuery;
139
144
  private sendEvent;
140
145
  private trackPageChanges;
141
146
  private fetchWebsiteConfig;
@@ -145,6 +150,8 @@ declare class DataxamasTracking {
145
150
  private getTarget;
146
151
  private trackClicks;
147
152
  private trackScroll;
153
+ private flushVitals;
154
+ private trackWebVitals;
148
155
  private measureReplay;
149
156
  /**
150
157
  * Sorteio por visitante, não por gravação: quem entrou no sorteio tem a sessão inteira, em vez
@@ -181,6 +188,8 @@ declare class DataxamasTracking {
181
188
  private setupReplayLifecycle;
182
189
  private startReplayRecorder;
183
190
  private startTracking;
191
+ /** Evento customizado (ex.: `signup_done`), usado em metas e funis. Antes do `start()` não envia nada. */
192
+ track(name: string, data?: Record<string, unknown>): void;
184
193
  start(): void;
185
194
  }
186
195
 
@@ -196,6 +205,7 @@ interface DataxamasOptions {
196
205
  captureGlobalErrors?: boolean;
197
206
  replayEnabled?: boolean;
198
207
  heatMapEnabled?: boolean;
208
+ webVitalsEnabled?: boolean;
199
209
  }
200
210
  declare class Dataxamas {
201
211
  readonly logs: DataxamasLogs;
package/dist/index.d.ts CHANGED
@@ -103,6 +103,7 @@ interface DataxamasTrackingOptions {
103
103
  allowLocalhost?: boolean;
104
104
  replayEnabled?: boolean;
105
105
  heatMapEnabled?: boolean;
106
+ webVitalsEnabled?: boolean;
106
107
  }
107
108
  declare class DataxamasTracking {
108
109
  private apiKey;
@@ -112,6 +113,9 @@ declare class DataxamasTracking {
112
113
  private currentPage;
113
114
  private heatMapEnabled;
114
115
  private replayEnabled;
116
+ private webVitalsEnabled;
117
+ private pendingVitals;
118
+ private vitalsPath;
115
119
  private replaySampleRate;
116
120
  private eventQueue;
117
121
  private isProcessing;
@@ -136,6 +140,7 @@ declare class DataxamasTracking {
136
140
  private getSessionId;
137
141
  private createSessionId;
138
142
  private processQueue;
143
+ private utmQuery;
139
144
  private sendEvent;
140
145
  private trackPageChanges;
141
146
  private fetchWebsiteConfig;
@@ -145,6 +150,8 @@ declare class DataxamasTracking {
145
150
  private getTarget;
146
151
  private trackClicks;
147
152
  private trackScroll;
153
+ private flushVitals;
154
+ private trackWebVitals;
148
155
  private measureReplay;
149
156
  /**
150
157
  * Sorteio por visitante, não por gravação: quem entrou no sorteio tem a sessão inteira, em vez
@@ -181,6 +188,8 @@ declare class DataxamasTracking {
181
188
  private setupReplayLifecycle;
182
189
  private startReplayRecorder;
183
190
  private startTracking;
191
+ /** Evento customizado (ex.: `signup_done`), usado em metas e funis. Antes do `start()` não envia nada. */
192
+ track(name: string, data?: Record<string, unknown>): void;
184
193
  start(): void;
185
194
  }
186
195
 
@@ -196,6 +205,7 @@ interface DataxamasOptions {
196
205
  captureGlobalErrors?: boolean;
197
206
  replayEnabled?: boolean;
198
207
  heatMapEnabled?: boolean;
208
+ webVitalsEnabled?: boolean;
199
209
  }
200
210
  declare class Dataxamas {
201
211
  readonly logs: DataxamasLogs;
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import "./chunk-PKBMQBKP.js";
2
+
1
3
  // src/constants.ts
2
4
  var BASE_URL = "https://dataxamas.com";
3
5
 
@@ -358,6 +360,9 @@ var DataxamasTracking = class {
358
360
  this.currentPage = isBrowser() ? window.location.pathname : "";
359
361
  this.heatMapEnabled = options.heatMapEnabled ?? true;
360
362
  this.replayEnabled = options.replayEnabled ?? true;
363
+ this.webVitalsEnabled = options.webVitalsEnabled ?? true;
364
+ this.pendingVitals = /* @__PURE__ */ new Map();
365
+ this.vitalsPath = "";
361
366
  this.replaySampleRate = 1;
362
367
  this.eventQueue = [];
363
368
  this.isProcessing = false;
@@ -418,6 +423,14 @@ var DataxamasTracking = class {
418
423
  this.processQueue();
419
424
  }, QUEUE_DELAY_MS);
420
425
  }
426
+ // Só os pares `utm_*`: o resto da query pode carregar token ou dado pessoal e não sai do browser.
427
+ utmQuery() {
428
+ const utm = new URLSearchParams();
429
+ new URLSearchParams(window.location.search).forEach((value, key) => {
430
+ if (key.startsWith("utm_")) utm.append(key, value);
431
+ });
432
+ return utm.toString() || void 0;
433
+ }
421
434
  async sendEvent({
422
435
  name,
423
436
  path = this.currentPage,
@@ -428,6 +441,7 @@ var DataxamasTracking = class {
428
441
  name,
429
442
  path,
430
443
  referrer: document.referrer,
444
+ query: name === "PAGE_VIEW" ? this.utmQuery() : void 0,
431
445
  sessionId: this.sessionId,
432
446
  data
433
447
  });
@@ -536,6 +550,49 @@ var DataxamasTracking = class {
536
550
  }, 1e3);
537
551
  });
538
552
  }
553
+ flushVitals() {
554
+ if (!this.sessionId || this.pendingVitals.size === 0) return;
555
+ const metrics = Array.from(this.pendingVitals.values());
556
+ this.pendingVitals.clear();
557
+ window.fetch(`${this.baseUrl}/api/v1/vitals`, {
558
+ method: "POST",
559
+ headers: { Authorization: `Bearer ${this.apiKey}`, "Content-Type": "application/json" },
560
+ body: JSON.stringify({
561
+ sessionId: this.sessionId,
562
+ path: this.vitalsPath,
563
+ viewportWidth: window.innerWidth,
564
+ metrics
565
+ }),
566
+ keepalive: true,
567
+ credentials: "omit"
568
+ }).catch(() => {
569
+ });
570
+ }
571
+ async trackWebVitals() {
572
+ if (!this.webVitalsEnabled) return;
573
+ this.vitalsPath = window.location.pathname;
574
+ let webVitals;
575
+ try {
576
+ webVitals = await import("./web-vitals-6BV2S7VZ.js");
577
+ } catch (_) {
578
+ return;
579
+ }
580
+ const queue = (metric) => {
581
+ this.pendingVitals.set(`${metric.name}:${metric.id}`, {
582
+ id: metric.id,
583
+ name: metric.name,
584
+ value: metric.value,
585
+ navigationType: metric.navigationType
586
+ });
587
+ };
588
+ webVitals.onLCP(queue);
589
+ webVitals.onINP(queue);
590
+ webVitals.onCLS(queue);
591
+ document.addEventListener("visibilitychange", () => {
592
+ if (document.visibilityState === "hidden") this.flushVitals();
593
+ });
594
+ window.addEventListener("pagehide", () => this.flushVitals());
595
+ }
539
596
  measureReplay() {
540
597
  const doc = document.documentElement;
541
598
  const viewportWidth = window.innerWidth;
@@ -735,7 +792,7 @@ var DataxamasTracking = class {
735
792
  this.replayStarting = true;
736
793
  try {
737
794
  if (!this.rrwebRecord) {
738
- const { record } = await import("./rrweb-F6UF6U3D.js");
795
+ const { record } = await import("./rrweb-PPF5WV43.js");
739
796
  this.rrwebRecord = record;
740
797
  }
741
798
  } catch (_) {
@@ -788,11 +845,17 @@ var DataxamasTracking = class {
788
845
  this.trackPageChanges();
789
846
  this.trackClicks();
790
847
  this.trackScroll();
848
+ this.trackWebVitals();
791
849
  this.fetchWebsiteConfig().then(() => {
792
850
  if (!this.replayEnabled || !this.isReplaySampled()) return;
793
851
  this.setupReplayLifecycle();
794
852
  });
795
853
  }
854
+ /** Evento customizado (ex.: `signup_done`), usado em metas e funis. Antes do `start()` não envia nada. */
855
+ track(name, data) {
856
+ if (!isBrowser()) return;
857
+ void this.sendEvent({ name, data });
858
+ }
796
859
  start() {
797
860
  if (!isBrowser()) {
798
861
  throw new Error("DataxamasTracking: This SDK can only be used in a browser environment.");
@@ -833,6 +896,7 @@ var Dataxamas = class {
833
896
  baseUrl,
834
897
  replayEnabled: options.replayEnabled ?? true,
835
898
  heatMapEnabled: options.heatMapEnabled ?? true,
899
+ webVitalsEnabled: options.webVitalsEnabled ?? true,
836
900
  allowLocalhost: options.allowLocalhost ?? false
837
901
  });
838
902
  this.crawlers = new DataxamasCrawlers({
@@ -1,3 +1,5 @@
1
+ import "./chunk-PKBMQBKP.js";
2
+
1
3
  // ../../node_modules/rrweb/dist/rrweb.js
2
4
  var __defProp = Object.defineProperty;
3
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -1,4 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// ../../node_modules/rrweb/dist/rrweb.js
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }require('./chunk-ETV4XYOV.cjs');
2
+
3
+ // ../../node_modules/rrweb/dist/rrweb.js
2
4
  var __defProp = Object.defineProperty;
3
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -0,0 +1,345 @@
1
+ import {
2
+ __publicField
3
+ } from "./chunk-PKBMQBKP.js";
4
+
5
+ // ../../node_modules/web-vitals/dist/web-vitals.js
6
+ var t = -1;
7
+ var n = () => t;
8
+ var e = (n2) => {
9
+ addEventListener("pageshow", (e2) => {
10
+ e2.persisted && (t = e2.timeStamp, n2(e2));
11
+ }, true);
12
+ };
13
+ var i = (t2, n2, e2, i2) => {
14
+ let o2, s2;
15
+ return (a2) => {
16
+ n2.value >= 0 && (a2 || i2) && (s2 = n2.value - (o2 ?? 0), (s2 || void 0 === o2) && (o2 = n2.value, n2.delta = s2, n2.rating = ((t3, n3) => t3 > n3[1] ? "poor" : t3 > n3[0] ? "needs-improvement" : "good")(n2.value, e2), t2(n2)));
17
+ };
18
+ };
19
+ var o = (t2) => {
20
+ requestAnimationFrame(() => requestAnimationFrame(() => t2()));
21
+ };
22
+ var s = () => {
23
+ const t2 = performance.getEntriesByType("navigation")[0];
24
+ if (t2 && t2.responseStart > 0 && t2.responseStart < performance.now()) return t2;
25
+ };
26
+ var a = () => s()?.activationStart ?? 0;
27
+ var r = -1;
28
+ var c = /* @__PURE__ */ new Set();
29
+ var f = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0;
30
+ var h = (t2) => {
31
+ if ("hidden" === document.visibilityState) {
32
+ if ("visibilitychange" === t2.type) for (const t3 of c) t3();
33
+ isFinite(r) || (r = "visibilitychange" === t2.type ? t2.timeStamp : 0, removeEventListener("prerenderingchange", h, true));
34
+ }
35
+ };
36
+ var d = (t2 = false) => {
37
+ if (t2 && (r = 1 / 0), r < 0) {
38
+ const t3 = a(), n2 = document.prerendering ? void 0 : globalThis.performance.getEntriesByType("visibility-state").find((n3) => "hidden" === n3.name && n3.startTime >= t3)?.startTime;
39
+ r = n2 ?? f(), addEventListener("visibilitychange", h, true), addEventListener("prerenderingchange", h, true), e(() => {
40
+ setTimeout(() => {
41
+ r = f();
42
+ });
43
+ });
44
+ }
45
+ return { get firstHiddenTime() {
46
+ return r;
47
+ }, onHidden(t3) {
48
+ c.add(t3);
49
+ } };
50
+ };
51
+ var l = (t2, e2 = -1, i2, o2 = 0, r2, c2, f2) => {
52
+ const h2 = s(), d2 = h2?.navigationId || 0;
53
+ let l2 = "navigate";
54
+ i2 ? l2 = i2 : n() >= 0 ? l2 = "back-forward-cache" : h2 && (document.prerendering || a() > 0 ? l2 = "prerender" : document.wasDiscarded ? l2 = "restore" : h2.type && (l2 = h2.type.replace(/_/g, "-")));
55
+ return { name: t2, value: e2, rating: "good", delta: 0, entries: [], id: `v6-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`, navigationType: l2, navigationId: o2 || d2, navigationInteractionId: r2, navigationURL: c2 || h2?.name, navigationStartTime: f2 || 0 };
56
+ };
57
+ var g = /* @__PURE__ */ new WeakMap();
58
+ function u(t2, n2) {
59
+ let e2 = g.get(n2);
60
+ return e2 || (e2 = /* @__PURE__ */ new WeakMap(), g.set(n2, e2)), e2.get(t2) || e2.set(t2, new n2()), e2.get(t2);
61
+ }
62
+ var v = class {
63
+ constructor() {
64
+ __publicField(this, "t");
65
+ __publicField(this, "i", 0);
66
+ __publicField(this, "o", []);
67
+ }
68
+ h(t2) {
69
+ if (t2.hadRecentInput) return;
70
+ const n2 = this.o[0], e2 = this.o.at(-1);
71
+ this.i && n2 && e2 && t2.startTime - e2.startTime < 1e3 && t2.startTime - n2.startTime < 5e3 ? (this.i += t2.value, this.o.push(t2)) : (this.i = t2.value, this.o = [t2]), this.t?.(t2);
72
+ }
73
+ };
74
+ var m = (t2, n2, e2 = {}) => {
75
+ try {
76
+ const i2 = t2.filter((t3) => PerformanceObserver.supportedEntryTypes.includes(t3));
77
+ if (i2.length > 0) {
78
+ const t3 = new PerformanceObserver((t4) => {
79
+ queueMicrotask(() => {
80
+ const e3 = t4.getEntries();
81
+ i2.length > 1 && e3.sort((t5, n3) => t5.startTime + t5.duration - (n3.startTime + n3.duration)), n2(e3);
82
+ });
83
+ });
84
+ for (const n3 of i2) t3.observe({ type: n3, buffered: true, ...e2 });
85
+ return t3;
86
+ }
87
+ } catch {
88
+ }
89
+ };
90
+ var p = (t2) => globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation") && "function" == typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint && t2 && t2.reportSoftNavs;
91
+ var b = (t2, n2) => {
92
+ if (t2.set(n2.navigationId, n2), t2.size > 2) {
93
+ const n3 = t2.keys().next().value;
94
+ void 0 !== n3 && t2.delete(n3);
95
+ }
96
+ };
97
+ var T = (t2) => {
98
+ let n2 = false;
99
+ return () => {
100
+ n2 || (t2(), n2 = true);
101
+ };
102
+ };
103
+ var y = class {
104
+ constructor() {
105
+ __publicField(this, "l");
106
+ }
107
+ };
108
+ var _ = (t2) => {
109
+ document.prerendering ? addEventListener("prerenderingchange", t2, true) : t2();
110
+ };
111
+ var E = [1800, 3e3];
112
+ var M = (t2, s2 = {}) => {
113
+ const r2 = p(s2);
114
+ _(() => {
115
+ const c2 = u(s2, y), f2 = d();
116
+ let h2, g2 = l("FCP");
117
+ const v2 = m(["paint"], (t3) => {
118
+ for (const n2 of t3) "first-contentful-paint" === n2.name && (v2.disconnect(), n2.startTime < f2.firstHiddenTime && (g2.value = Math.max(n2.startTime - a(), 0), g2.entries.push(n2), g2.navigationId = n2.navigationId || g2.navigationId, h2(true)));
119
+ });
120
+ if (v2 && (h2 = i(t2, g2, E, s2.reportAllChanges), e((e2) => {
121
+ g2 = l("FCP", -1, "back-forward-cache", g2.navigationId, g2.navigationInteractionId, g2.navigationURL, n()), h2 = i(t2, g2, E, s2.reportAllChanges), o(() => {
122
+ g2.value = performance.now() - e2.timeStamp, h2(true);
123
+ });
124
+ })), r2) {
125
+ m(["soft-navigation"], (n2) => {
126
+ n2.forEach((n3) => {
127
+ c2.l && n3.navigationId && b(c2.l, n3);
128
+ const e2 = Math.max((n3.presentationTime || n3.paintTime || 0) - n3.startTime, 0);
129
+ g2 = l("FCP", e2, "soft-navigation", n3.navigationId, n3.interactionId, n3.name, n3.startTime), h2 = i(t2, g2, E, s2.reportAllChanges), h2(true);
130
+ });
131
+ }, s2);
132
+ }
133
+ });
134
+ };
135
+ var L = [0.1, 0.25];
136
+ var P = (t2, s2 = {}) => {
137
+ const a2 = d();
138
+ M(T(() => {
139
+ let r2, c2 = l("CLS", 0);
140
+ const f2 = u(s2, v), h2 = (n2, e2, o2, a3, h3) => {
141
+ c2 = l("CLS", 0, n2, e2, o2, a3, h3), f2.i = 0, r2 = i(t2, c2, L, s2.reportAllChanges);
142
+ }, d2 = (t3 = false) => {
143
+ f2.i > c2.value && (c2.value = f2.i, c2.entries = f2.o), r2(t3);
144
+ }, g2 = (t3) => {
145
+ d2(true), h2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
146
+ }, b2 = (t3) => {
147
+ for (const n2 of t3) "soft-navigation" !== n2.entryType ? f2.h(n2) : g2(n2);
148
+ d2();
149
+ }, T2 = ["layout-shift"];
150
+ p(s2) && T2.push("soft-navigation");
151
+ const y2 = m(T2, b2);
152
+ y2 && (r2 = i(t2, c2, L, s2.reportAllChanges), a2.onHidden(() => {
153
+ b2(y2.takeRecords()), r2(true);
154
+ }), e(() => {
155
+ h2("back-forward-cache", c2.navigationId, c2.navigationInteractionId, c2.navigationURL, n()), o(r2);
156
+ }), setTimeout(r2));
157
+ }));
158
+ };
159
+ var w = 0;
160
+ var I = 1 / 0;
161
+ var k = 0;
162
+ var C = (t2) => {
163
+ for (const n2 of t2) n2.interactionId && (I = Math.min(I, n2.interactionId), k = Math.max(k, n2.interactionId), w = k ? (k - I) / 7 + 1 : 0);
164
+ };
165
+ var F;
166
+ var N = () => F ? w : performance.interactionCount ?? 0;
167
+ var B = () => {
168
+ "interactionCount" in performance || F || (F = m(["event"], C, { durationThreshold: 0 }));
169
+ };
170
+ var S = class {
171
+ constructor() {
172
+ __publicField(this, "u", 0);
173
+ __publicField(this, "v", []);
174
+ __publicField(this, "m", /* @__PURE__ */ new Map());
175
+ __publicField(this, "p");
176
+ __publicField(this, "T");
177
+ }
178
+ _() {
179
+ return N() - this.u;
180
+ }
181
+ M() {
182
+ this.u = N(), this.v.length = 0, this.m.clear();
183
+ }
184
+ L(t2) {
185
+ const n2 = this._(), e2 = Math.min(this.v.length - 1, Math.floor(n2 / 50));
186
+ return !n2 || -1 !== e2 || "soft-navigation" !== t2 && "back-forward-cache" !== t2 ? this.v[e2] : { P: 8, id: -1, entries: [] };
187
+ }
188
+ h(t2) {
189
+ if (this.p?.(t2), !t2.interactionId) return;
190
+ const n2 = this.v.at(-1);
191
+ let e2 = this.m.get(t2.interactionId);
192
+ if (e2 || this.v.length < 10 || t2.duration > n2.P) {
193
+ if (e2 ? t2.duration > e2.P ? (e2.entries = [t2], e2.P = t2.duration) : t2.duration === e2.P && t2.startTime === e2.entries[0].startTime && e2.entries.push(t2) : (e2 = { id: t2.interactionId, entries: [t2], P: t2.duration }, this.m.set(e2.id, e2), this.v.push(e2)), this.v.sort((t3, n3) => n3.P - t3.P), this.v.length > 10) {
194
+ const t3 = this.v.splice(10);
195
+ for (const n3 of t3) this.m.delete(n3.id);
196
+ }
197
+ this.T?.(e2);
198
+ }
199
+ }
200
+ };
201
+ var q = (t2) => {
202
+ const n2 = "requestIdleCallback" in globalThis ? 1e3 : 0, e2 = globalThis.requestIdleCallback || setTimeout, i2 = globalThis.cancelIdleCallback || clearTimeout;
203
+ if ("hidden" === document.visibilityState) t2();
204
+ else {
205
+ const o2 = T(t2);
206
+ let s2 = -1;
207
+ const a2 = () => {
208
+ i2(s2), o2();
209
+ };
210
+ addEventListener("visibilitychange", a2, { once: true, capture: true }), s2 = e2(() => {
211
+ removeEventListener("visibilitychange", a2, { capture: true }), o2();
212
+ }, { timeout: n2 });
213
+ }
214
+ };
215
+ var A = [200, 500];
216
+ var x = (t2, o2 = {}) => {
217
+ if (!globalThis.PerformanceEventTiming || !("interactionId" in PerformanceEventTiming.prototype)) return;
218
+ const s2 = d();
219
+ _(() => {
220
+ B();
221
+ let a2, r2 = l("INP");
222
+ const c2 = u(o2, S), f2 = (n2, e2, s3, f3, h3) => {
223
+ c2.M(), r2 = l("INP", -1, n2, e2, s3, f3, h3), a2 = i(t2, r2, A, o2.reportAllChanges);
224
+ }, h2 = () => {
225
+ const t3 = c2.L(r2.navigationType);
226
+ t3 && t3.P !== r2.value && (r2.value = t3.P, r2.entries = t3.entries, a2());
227
+ }, d2 = (t3) => {
228
+ h2(), a2(true), f2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
229
+ }, g2 = (t3, n2 = false) => {
230
+ q(() => {
231
+ for (const n3 of t3) "soft-navigation" !== n3.entryType ? c2.h(n3) : d2(n3);
232
+ h2(), n2 && a2(true);
233
+ });
234
+ }, v2 = ["event", "first-input"];
235
+ p(o2) && v2.push("soft-navigation");
236
+ const b2 = m(v2, g2, { ...o2, durationThreshold: o2.durationThreshold ?? 40 });
237
+ a2 = i(t2, r2, A, o2.reportAllChanges), b2 && (s2.onHidden(() => {
238
+ g2(b2.takeRecords(), true);
239
+ }), e(() => {
240
+ f2("back-forward-cache", r2.navigationId, r2.navigationInteractionId, r2.navigationURL, n());
241
+ }));
242
+ });
243
+ };
244
+ var H = class {
245
+ constructor() {
246
+ __publicField(this, "p");
247
+ __publicField(this, "l");
248
+ }
249
+ h(t2) {
250
+ this.p?.(t2);
251
+ }
252
+ };
253
+ var O = [2500, 4e3];
254
+ var U = (t2, s2 = {}) => {
255
+ let r2 = false;
256
+ const c2 = p(s2);
257
+ _(() => {
258
+ let f2, h2 = d(), g2 = l("LCP");
259
+ const v2 = u(s2, H), p2 = (n2, e2, o2, a2, c3) => {
260
+ g2 = l("LCP", -1, n2, e2, o2, a2, c3), f2 = i(t2, g2, O, s2.reportAllChanges), r2 = false, "soft-navigation" === n2 && (h2 = d(true));
261
+ }, T2 = (t3) => {
262
+ v2.l && t3.navigationId && b(v2.l, t3), r2 || f2(true), p2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
263
+ const n2 = t3.getLargestInteractionContentfulPaint?.();
264
+ n2 && y2([n2]);
265
+ }, y2 = (t3) => {
266
+ s2.reportAllChanges || c2 || (t3 = t3.slice(-1));
267
+ for (const n2 of t3) {
268
+ if (!n2) continue;
269
+ if ("soft-navigation" === n2.entryType) {
270
+ T2(n2);
271
+ continue;
272
+ }
273
+ let t4 = 0, e2 = [], i2 = n2.startTime;
274
+ if ("largest-contentful-paint" === n2.entryType) t4 = Math.max(n2.startTime - a(), 0), v2.h(n2), e2 = [n2];
275
+ else if ("interaction-contentful-paint" === n2.entryType) {
276
+ const o2 = n2;
277
+ if (!g2.navigationId) continue;
278
+ if ("interactionId" in o2 && o2.interactionId != g2.navigationInteractionId) continue;
279
+ i2 = o2.largestContentfulPaint?.renderTime || 0, t4 = Math.max(i2 - n2.startTime, 0), o2.largestContentfulPaint && (v2.h(o2.largestContentfulPaint), e2 = [o2.largestContentfulPaint]);
280
+ }
281
+ i2 < h2.firstHiddenTime && (g2.value = t4, g2.entries = e2, f2());
282
+ }
283
+ }, _2 = ["largest-contentful-paint"];
284
+ c2 && _2.push("interaction-contentful-paint", "soft-navigation");
285
+ const E2 = m(_2, y2);
286
+ if (E2) {
287
+ f2 = i(t2, g2, O, s2.reportAllChanges);
288
+ const a2 = ["keydown", "click", "visibilitychange"], h3 = (t3) => {
289
+ if (t3.isTrusted && !r2) {
290
+ const t4 = g2.id;
291
+ q(() => {
292
+ if (!r2) {
293
+ if (!c2) {
294
+ E2.disconnect();
295
+ for (const t5 of a2) removeEventListener(t5, h3, { capture: true });
296
+ }
297
+ t4 === g2.id && (r2 = true, f2(true));
298
+ }
299
+ });
300
+ }
301
+ };
302
+ for (const t3 of a2) addEventListener(t3, h3, { capture: true });
303
+ e((e2) => {
304
+ p2("back-forward-cache", g2.navigationId, g2.navigationInteractionId, g2.navigationURL, n()), f2 = i(t2, g2, O, s2.reportAllChanges), o(() => {
305
+ g2.value = performance.now() - e2.timeStamp, r2 = true, f2(true);
306
+ });
307
+ });
308
+ }
309
+ });
310
+ };
311
+ var W = [800, 1800];
312
+ var $ = (t2) => {
313
+ document.prerendering ? _(() => $(t2)) : "complete" !== document.readyState ? addEventListener("load", () => $(t2), true) : setTimeout(t2);
314
+ };
315
+ var D = (t2, o2 = {}) => {
316
+ const r2 = p(o2);
317
+ let c2 = l("TTFB"), f2 = i(t2, c2, W, o2.reportAllChanges);
318
+ $(() => {
319
+ const h2 = s();
320
+ if (h2) {
321
+ const s2 = h2.responseStart;
322
+ if (c2.value = Math.max(s2 - a(), 0), c2.entries = [h2], f2(true), e(() => {
323
+ c2 = l("TTFB", 0, "back-forward-cache", c2.navigationId, c2.navigationInteractionId, c2.navigationURL, n()), f2 = i(t2, c2, W, o2.reportAllChanges), f2(true);
324
+ }), r2) {
325
+ m(["soft-navigation"], (n2) => {
326
+ n2.forEach((n3) => {
327
+ n3.navigationId && (c2 = l("TTFB", 0, "soft-navigation", n3.navigationId, n3.interactionId, n3.name, n3.startTime), c2.entries = [n3], f2 = i(t2, c2, W, o2.reportAllChanges), f2(true));
328
+ });
329
+ }, o2);
330
+ }
331
+ }
332
+ });
333
+ };
334
+ export {
335
+ L as CLSThresholds,
336
+ E as FCPThresholds,
337
+ A as INPThresholds,
338
+ O as LCPThresholds,
339
+ W as TTFBThresholds,
340
+ P as onCLS,
341
+ M as onFCP,
342
+ x as onINP,
343
+ U as onLCP,
344
+ D as onTTFB
345
+ };
@@ -0,0 +1,345 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkETV4XYOVcjs = require('./chunk-ETV4XYOV.cjs');
4
+
5
+ // ../../node_modules/web-vitals/dist/web-vitals.js
6
+ var t = -1;
7
+ var n = () => t;
8
+ var e = (n2) => {
9
+ addEventListener("pageshow", (e2) => {
10
+ e2.persisted && (t = e2.timeStamp, n2(e2));
11
+ }, true);
12
+ };
13
+ var i = (t2, n2, e2, i2) => {
14
+ let o2, s2;
15
+ return (a2) => {
16
+ n2.value >= 0 && (a2 || i2) && (s2 = n2.value - (_nullishCoalesce(o2, () => ( 0))), (s2 || void 0 === o2) && (o2 = n2.value, n2.delta = s2, n2.rating = ((t3, n3) => t3 > n3[1] ? "poor" : t3 > n3[0] ? "needs-improvement" : "good")(n2.value, e2), t2(n2)));
17
+ };
18
+ };
19
+ var o = (t2) => {
20
+ requestAnimationFrame(() => requestAnimationFrame(() => t2()));
21
+ };
22
+ var s = () => {
23
+ const t2 = performance.getEntriesByType("navigation")[0];
24
+ if (t2 && t2.responseStart > 0 && t2.responseStart < performance.now()) return t2;
25
+ };
26
+ var a = () => _nullishCoalesce(_optionalChain([s, 'call', _3 => _3(), 'optionalAccess', _4 => _4.activationStart]), () => ( 0));
27
+ var r = -1;
28
+ var c = /* @__PURE__ */ new Set();
29
+ var f = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0;
30
+ var h = (t2) => {
31
+ if ("hidden" === document.visibilityState) {
32
+ if ("visibilitychange" === t2.type) for (const t3 of c) t3();
33
+ isFinite(r) || (r = "visibilitychange" === t2.type ? t2.timeStamp : 0, removeEventListener("prerenderingchange", h, true));
34
+ }
35
+ };
36
+ var d = (t2 = false) => {
37
+ if (t2 && (r = 1 / 0), r < 0) {
38
+ const t3 = a(), n2 = document.prerendering ? void 0 : _optionalChain([globalThis, 'access', _5 => _5.performance, 'access', _6 => _6.getEntriesByType, 'call', _7 => _7("visibility-state"), 'access', _8 => _8.find, 'call', _9 => _9((n3) => "hidden" === n3.name && n3.startTime >= t3), 'optionalAccess', _10 => _10.startTime]);
39
+ r = _nullishCoalesce(n2, () => ( f())), addEventListener("visibilitychange", h, true), addEventListener("prerenderingchange", h, true), e(() => {
40
+ setTimeout(() => {
41
+ r = f();
42
+ });
43
+ });
44
+ }
45
+ return { get firstHiddenTime() {
46
+ return r;
47
+ }, onHidden(t3) {
48
+ c.add(t3);
49
+ } };
50
+ };
51
+ var l = (t2, e2 = -1, i2, o2 = 0, r2, c2, f2) => {
52
+ const h2 = s(), d2 = _optionalChain([h2, 'optionalAccess', _11 => _11.navigationId]) || 0;
53
+ let l2 = "navigate";
54
+ i2 ? l2 = i2 : n() >= 0 ? l2 = "back-forward-cache" : h2 && (document.prerendering || a() > 0 ? l2 = "prerender" : document.wasDiscarded ? l2 = "restore" : h2.type && (l2 = h2.type.replace(/_/g, "-")));
55
+ return { name: t2, value: e2, rating: "good", delta: 0, entries: [], id: `v6-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`, navigationType: l2, navigationId: o2 || d2, navigationInteractionId: r2, navigationURL: c2 || _optionalChain([h2, 'optionalAccess', _12 => _12.name]), navigationStartTime: f2 || 0 };
56
+ };
57
+ var g = /* @__PURE__ */ new WeakMap();
58
+ function u(t2, n2) {
59
+ let e2 = g.get(n2);
60
+ return e2 || (e2 = /* @__PURE__ */ new WeakMap(), g.set(n2, e2)), e2.get(t2) || e2.set(t2, new n2()), e2.get(t2);
61
+ }
62
+ var v = class {
63
+ constructor() {
64
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "t");
65
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "i", 0);
66
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "o", []);
67
+ }
68
+ h(t2) {
69
+ if (t2.hadRecentInput) return;
70
+ const n2 = this.o[0], e2 = this.o.at(-1);
71
+ this.i && n2 && e2 && t2.startTime - e2.startTime < 1e3 && t2.startTime - n2.startTime < 5e3 ? (this.i += t2.value, this.o.push(t2)) : (this.i = t2.value, this.o = [t2]), _optionalChain([this, 'access', _13 => _13.t, 'optionalCall', _14 => _14(t2)]);
72
+ }
73
+ };
74
+ var m = (t2, n2, e2 = {}) => {
75
+ try {
76
+ const i2 = t2.filter((t3) => PerformanceObserver.supportedEntryTypes.includes(t3));
77
+ if (i2.length > 0) {
78
+ const t3 = new PerformanceObserver((t4) => {
79
+ queueMicrotask(() => {
80
+ const e3 = t4.getEntries();
81
+ i2.length > 1 && e3.sort((t5, n3) => t5.startTime + t5.duration - (n3.startTime + n3.duration)), n2(e3);
82
+ });
83
+ });
84
+ for (const n3 of i2) t3.observe({ type: n3, buffered: true, ...e2 });
85
+ return t3;
86
+ }
87
+ } catch (e4) {
88
+ }
89
+ };
90
+ var p = (t2) => _optionalChain([globalThis, 'access', _15 => _15.PerformanceObserver, 'optionalAccess', _16 => _16.supportedEntryTypes, 'optionalAccess', _17 => _17.includes, 'call', _18 => _18("soft-navigation")]) && "function" == typeof _optionalChain([globalThis, 'access', _19 => _19.PerformanceSoftNavigation, 'optionalAccess', _20 => _20.prototype, 'optionalAccess', _21 => _21.getLargestInteractionContentfulPaint]) && t2 && t2.reportSoftNavs;
91
+ var b = (t2, n2) => {
92
+ if (t2.set(n2.navigationId, n2), t2.size > 2) {
93
+ const n3 = t2.keys().next().value;
94
+ void 0 !== n3 && t2.delete(n3);
95
+ }
96
+ };
97
+ var T = (t2) => {
98
+ let n2 = false;
99
+ return () => {
100
+ n2 || (t2(), n2 = true);
101
+ };
102
+ };
103
+ var y = class {
104
+ constructor() {
105
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "l");
106
+ }
107
+ };
108
+ var _ = (t2) => {
109
+ document.prerendering ? addEventListener("prerenderingchange", t2, true) : t2();
110
+ };
111
+ var E = [1800, 3e3];
112
+ var M = (t2, s2 = {}) => {
113
+ const r2 = p(s2);
114
+ _(() => {
115
+ const c2 = u(s2, y), f2 = d();
116
+ let h2, g2 = l("FCP");
117
+ const v2 = m(["paint"], (t3) => {
118
+ for (const n2 of t3) "first-contentful-paint" === n2.name && (v2.disconnect(), n2.startTime < f2.firstHiddenTime && (g2.value = Math.max(n2.startTime - a(), 0), g2.entries.push(n2), g2.navigationId = n2.navigationId || g2.navigationId, h2(true)));
119
+ });
120
+ if (v2 && (h2 = i(t2, g2, E, s2.reportAllChanges), e((e2) => {
121
+ g2 = l("FCP", -1, "back-forward-cache", g2.navigationId, g2.navigationInteractionId, g2.navigationURL, n()), h2 = i(t2, g2, E, s2.reportAllChanges), o(() => {
122
+ g2.value = performance.now() - e2.timeStamp, h2(true);
123
+ });
124
+ })), r2) {
125
+ m(["soft-navigation"], (n2) => {
126
+ n2.forEach((n3) => {
127
+ c2.l && n3.navigationId && b(c2.l, n3);
128
+ const e2 = Math.max((n3.presentationTime || n3.paintTime || 0) - n3.startTime, 0);
129
+ g2 = l("FCP", e2, "soft-navigation", n3.navigationId, n3.interactionId, n3.name, n3.startTime), h2 = i(t2, g2, E, s2.reportAllChanges), h2(true);
130
+ });
131
+ }, s2);
132
+ }
133
+ });
134
+ };
135
+ var L = [0.1, 0.25];
136
+ var P = (t2, s2 = {}) => {
137
+ const a2 = d();
138
+ M(T(() => {
139
+ let r2, c2 = l("CLS", 0);
140
+ const f2 = u(s2, v), h2 = (n2, e2, o2, a3, h3) => {
141
+ c2 = l("CLS", 0, n2, e2, o2, a3, h3), f2.i = 0, r2 = i(t2, c2, L, s2.reportAllChanges);
142
+ }, d2 = (t3 = false) => {
143
+ f2.i > c2.value && (c2.value = f2.i, c2.entries = f2.o), r2(t3);
144
+ }, g2 = (t3) => {
145
+ d2(true), h2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
146
+ }, b2 = (t3) => {
147
+ for (const n2 of t3) "soft-navigation" !== n2.entryType ? f2.h(n2) : g2(n2);
148
+ d2();
149
+ }, T2 = ["layout-shift"];
150
+ p(s2) && T2.push("soft-navigation");
151
+ const y2 = m(T2, b2);
152
+ y2 && (r2 = i(t2, c2, L, s2.reportAllChanges), a2.onHidden(() => {
153
+ b2(y2.takeRecords()), r2(true);
154
+ }), e(() => {
155
+ h2("back-forward-cache", c2.navigationId, c2.navigationInteractionId, c2.navigationURL, n()), o(r2);
156
+ }), setTimeout(r2));
157
+ }));
158
+ };
159
+ var w = 0;
160
+ var I = 1 / 0;
161
+ var k = 0;
162
+ var C = (t2) => {
163
+ for (const n2 of t2) n2.interactionId && (I = Math.min(I, n2.interactionId), k = Math.max(k, n2.interactionId), w = k ? (k - I) / 7 + 1 : 0);
164
+ };
165
+ var F;
166
+ var N = () => F ? w : _nullishCoalesce(performance.interactionCount, () => ( 0));
167
+ var B = () => {
168
+ "interactionCount" in performance || F || (F = m(["event"], C, { durationThreshold: 0 }));
169
+ };
170
+ var S = class {
171
+ constructor() {
172
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "u", 0);
173
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "v", []);
174
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "m", /* @__PURE__ */ new Map());
175
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "p");
176
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "T");
177
+ }
178
+ _() {
179
+ return N() - this.u;
180
+ }
181
+ M() {
182
+ this.u = N(), this.v.length = 0, this.m.clear();
183
+ }
184
+ L(t2) {
185
+ const n2 = this._(), e2 = Math.min(this.v.length - 1, Math.floor(n2 / 50));
186
+ return !n2 || -1 !== e2 || "soft-navigation" !== t2 && "back-forward-cache" !== t2 ? this.v[e2] : { P: 8, id: -1, entries: [] };
187
+ }
188
+ h(t2) {
189
+ if (_optionalChain([this, 'access', _22 => _22.p, 'optionalCall', _23 => _23(t2)]), !t2.interactionId) return;
190
+ const n2 = this.v.at(-1);
191
+ let e2 = this.m.get(t2.interactionId);
192
+ if (e2 || this.v.length < 10 || t2.duration > n2.P) {
193
+ if (e2 ? t2.duration > e2.P ? (e2.entries = [t2], e2.P = t2.duration) : t2.duration === e2.P && t2.startTime === e2.entries[0].startTime && e2.entries.push(t2) : (e2 = { id: t2.interactionId, entries: [t2], P: t2.duration }, this.m.set(e2.id, e2), this.v.push(e2)), this.v.sort((t3, n3) => n3.P - t3.P), this.v.length > 10) {
194
+ const t3 = this.v.splice(10);
195
+ for (const n3 of t3) this.m.delete(n3.id);
196
+ }
197
+ _optionalChain([this, 'access', _24 => _24.T, 'optionalCall', _25 => _25(e2)]);
198
+ }
199
+ }
200
+ };
201
+ var q = (t2) => {
202
+ const n2 = "requestIdleCallback" in globalThis ? 1e3 : 0, e2 = globalThis.requestIdleCallback || setTimeout, i2 = globalThis.cancelIdleCallback || clearTimeout;
203
+ if ("hidden" === document.visibilityState) t2();
204
+ else {
205
+ const o2 = T(t2);
206
+ let s2 = -1;
207
+ const a2 = () => {
208
+ i2(s2), o2();
209
+ };
210
+ addEventListener("visibilitychange", a2, { once: true, capture: true }), s2 = e2(() => {
211
+ removeEventListener("visibilitychange", a2, { capture: true }), o2();
212
+ }, { timeout: n2 });
213
+ }
214
+ };
215
+ var A = [200, 500];
216
+ var x = (t2, o2 = {}) => {
217
+ if (!globalThis.PerformanceEventTiming || !("interactionId" in PerformanceEventTiming.prototype)) return;
218
+ const s2 = d();
219
+ _(() => {
220
+ B();
221
+ let a2, r2 = l("INP");
222
+ const c2 = u(o2, S), f2 = (n2, e2, s3, f3, h3) => {
223
+ c2.M(), r2 = l("INP", -1, n2, e2, s3, f3, h3), a2 = i(t2, r2, A, o2.reportAllChanges);
224
+ }, h2 = () => {
225
+ const t3 = c2.L(r2.navigationType);
226
+ t3 && t3.P !== r2.value && (r2.value = t3.P, r2.entries = t3.entries, a2());
227
+ }, d2 = (t3) => {
228
+ h2(), a2(true), f2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
229
+ }, g2 = (t3, n2 = false) => {
230
+ q(() => {
231
+ for (const n3 of t3) "soft-navigation" !== n3.entryType ? c2.h(n3) : d2(n3);
232
+ h2(), n2 && a2(true);
233
+ });
234
+ }, v2 = ["event", "first-input"];
235
+ p(o2) && v2.push("soft-navigation");
236
+ const b2 = m(v2, g2, { ...o2, durationThreshold: _nullishCoalesce(o2.durationThreshold, () => ( 40)) });
237
+ a2 = i(t2, r2, A, o2.reportAllChanges), b2 && (s2.onHidden(() => {
238
+ g2(b2.takeRecords(), true);
239
+ }), e(() => {
240
+ f2("back-forward-cache", r2.navigationId, r2.navigationInteractionId, r2.navigationURL, n());
241
+ }));
242
+ });
243
+ };
244
+ var H = class {
245
+ constructor() {
246
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "p");
247
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "l");
248
+ }
249
+ h(t2) {
250
+ _optionalChain([this, 'access', _26 => _26.p, 'optionalCall', _27 => _27(t2)]);
251
+ }
252
+ };
253
+ var O = [2500, 4e3];
254
+ var U = (t2, s2 = {}) => {
255
+ let r2 = false;
256
+ const c2 = p(s2);
257
+ _(() => {
258
+ let f2, h2 = d(), g2 = l("LCP");
259
+ const v2 = u(s2, H), p2 = (n2, e2, o2, a2, c3) => {
260
+ g2 = l("LCP", -1, n2, e2, o2, a2, c3), f2 = i(t2, g2, O, s2.reportAllChanges), r2 = false, "soft-navigation" === n2 && (h2 = d(true));
261
+ }, T2 = (t3) => {
262
+ v2.l && t3.navigationId && b(v2.l, t3), r2 || f2(true), p2("soft-navigation", t3.navigationId, t3.interactionId, t3.name, t3.startTime);
263
+ const n2 = _optionalChain([t3, 'access', _28 => _28.getLargestInteractionContentfulPaint, 'optionalCall', _29 => _29()]);
264
+ n2 && y2([n2]);
265
+ }, y2 = (t3) => {
266
+ s2.reportAllChanges || c2 || (t3 = t3.slice(-1));
267
+ for (const n2 of t3) {
268
+ if (!n2) continue;
269
+ if ("soft-navigation" === n2.entryType) {
270
+ T2(n2);
271
+ continue;
272
+ }
273
+ let t4 = 0, e2 = [], i2 = n2.startTime;
274
+ if ("largest-contentful-paint" === n2.entryType) t4 = Math.max(n2.startTime - a(), 0), v2.h(n2), e2 = [n2];
275
+ else if ("interaction-contentful-paint" === n2.entryType) {
276
+ const o2 = n2;
277
+ if (!g2.navigationId) continue;
278
+ if ("interactionId" in o2 && o2.interactionId != g2.navigationInteractionId) continue;
279
+ i2 = _optionalChain([o2, 'access', _30 => _30.largestContentfulPaint, 'optionalAccess', _31 => _31.renderTime]) || 0, t4 = Math.max(i2 - n2.startTime, 0), o2.largestContentfulPaint && (v2.h(o2.largestContentfulPaint), e2 = [o2.largestContentfulPaint]);
280
+ }
281
+ i2 < h2.firstHiddenTime && (g2.value = t4, g2.entries = e2, f2());
282
+ }
283
+ }, _2 = ["largest-contentful-paint"];
284
+ c2 && _2.push("interaction-contentful-paint", "soft-navigation");
285
+ const E2 = m(_2, y2);
286
+ if (E2) {
287
+ f2 = i(t2, g2, O, s2.reportAllChanges);
288
+ const a2 = ["keydown", "click", "visibilitychange"], h3 = (t3) => {
289
+ if (t3.isTrusted && !r2) {
290
+ const t4 = g2.id;
291
+ q(() => {
292
+ if (!r2) {
293
+ if (!c2) {
294
+ E2.disconnect();
295
+ for (const t5 of a2) removeEventListener(t5, h3, { capture: true });
296
+ }
297
+ t4 === g2.id && (r2 = true, f2(true));
298
+ }
299
+ });
300
+ }
301
+ };
302
+ for (const t3 of a2) addEventListener(t3, h3, { capture: true });
303
+ e((e2) => {
304
+ p2("back-forward-cache", g2.navigationId, g2.navigationInteractionId, g2.navigationURL, n()), f2 = i(t2, g2, O, s2.reportAllChanges), o(() => {
305
+ g2.value = performance.now() - e2.timeStamp, r2 = true, f2(true);
306
+ });
307
+ });
308
+ }
309
+ });
310
+ };
311
+ var W = [800, 1800];
312
+ var $ = (t2) => {
313
+ document.prerendering ? _(() => $(t2)) : "complete" !== document.readyState ? addEventListener("load", () => $(t2), true) : setTimeout(t2);
314
+ };
315
+ var D = (t2, o2 = {}) => {
316
+ const r2 = p(o2);
317
+ let c2 = l("TTFB"), f2 = i(t2, c2, W, o2.reportAllChanges);
318
+ $(() => {
319
+ const h2 = s();
320
+ if (h2) {
321
+ const s2 = h2.responseStart;
322
+ if (c2.value = Math.max(s2 - a(), 0), c2.entries = [h2], f2(true), e(() => {
323
+ c2 = l("TTFB", 0, "back-forward-cache", c2.navigationId, c2.navigationInteractionId, c2.navigationURL, n()), f2 = i(t2, c2, W, o2.reportAllChanges), f2(true);
324
+ }), r2) {
325
+ m(["soft-navigation"], (n2) => {
326
+ n2.forEach((n3) => {
327
+ n3.navigationId && (c2 = l("TTFB", 0, "soft-navigation", n3.navigationId, n3.interactionId, n3.name, n3.startTime), c2.entries = [n3], f2 = i(t2, c2, W, o2.reportAllChanges), f2(true));
328
+ });
329
+ }, o2);
330
+ }
331
+ }
332
+ });
333
+ };
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+ exports.CLSThresholds = L; exports.FCPThresholds = E; exports.INPThresholds = A; exports.LCPThresholds = O; exports.TTFBThresholds = W; exports.onCLS = P; exports.onFCP = M; exports.onINP = x; exports.onLCP = U; exports.onTTFB = D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataxamas/tracker-js",
3
- "version": "2.1.3",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "description": "Node.js SDK for Dataxamas Analytics API",
6
6
  "license": "MIT",
@@ -54,7 +54,8 @@
54
54
  "rrweb": "^2.1.0",
55
55
  "tsup": "^8.5.1",
56
56
  "typescript": "^5",
57
- "vite": "^8.0.16"
57
+ "vite": "^8.0.16",
58
+ "web-vitals": "^6.2.3"
58
59
  },
59
60
  "dependencies": {
60
61
  "pino": "^10.3.1"