@npaw/forge-web 10.0.2 → 10.0.3

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.
Binary file
package/dist/index.cjs CHANGED
@@ -1661,6 +1661,14 @@ var defaultPrivacy = {
1661
1661
  hashElementIdentity: false,
1662
1662
  captureElementText: true
1663
1663
  };
1664
+ var CACHE_STATS_RESPONSE_HEADERS = [
1665
+ "cache-status",
1666
+ "cf-cache-status",
1667
+ "x-cache-status",
1668
+ "x-cache",
1669
+ "x-cache-remote"
1670
+ ];
1671
+ var CACHE_STATS_JOIN_KEYS = new Set(CACHE_STATS_RESPONSE_HEADERS);
1664
1672
  var networkCaptureSuppressionDepth = 0;
1665
1673
  var nextNetworkEventId = 1;
1666
1674
  var REMOTE_FOCUS_KEYS = /* @__PURE__ */ new Set([
@@ -2903,7 +2911,11 @@ var BrowserCapture = class {
2903
2911
  if (Object.keys(requestHeaders).length > 0) {
2904
2912
  observation.requestHeaders = requestHeaders;
2905
2913
  }
2906
- const responseHeaders = result.response ? sanitizeHeaders(result.response.headers, this.options.privacy.allowedResponseHeaders) : sanitizeRawHeaders((_n = (_m = (_l = result.xhr) == null ? void 0 : _l.getAllResponseHeaders) == null ? void 0 : _m.call(_l)) != null ? _n : "", this.options.privacy.allowedResponseHeaders);
2914
+ const responseHeaderNames = [
2915
+ ...this.options.privacy.allowedResponseHeaders,
2916
+ ...CACHE_STATS_RESPONSE_HEADERS
2917
+ ];
2918
+ const responseHeaders = result.response ? sanitizeHeaders(result.response.headers, responseHeaderNames) : sanitizeRawHeaders((_n = (_m = (_l = result.xhr) == null ? void 0 : _l.getAllResponseHeaders) == null ? void 0 : _m.call(_l)) != null ? _n : "", responseHeaderNames);
2907
2919
  if (Object.keys(responseHeaders).length > 0) {
2908
2920
  observation.responseHeaders = responseHeaders;
2909
2921
  }
@@ -3328,8 +3340,14 @@ function sanitizeRawHeaders(rawHeaders, allowlist) {
3328
3340
  continue;
3329
3341
  }
3330
3342
  const key = line.slice(0, separator).trim().toLowerCase();
3331
- if (allowed.has(key)) {
3332
- output[key] = sanitizeCaptureString(line.slice(separator + 1).trim());
3343
+ if (!allowed.has(key)) {
3344
+ continue;
3345
+ }
3346
+ const value = sanitizeCaptureString(line.slice(separator + 1).trim());
3347
+ if (output[key] !== void 0 && CACHE_STATS_JOIN_KEYS.has(key)) {
3348
+ output[key] = `${output[key]}, ${value}`;
3349
+ } else {
3350
+ output[key] = value;
3333
3351
  }
3334
3352
  }
3335
3353
  return output;
@@ -3439,7 +3457,11 @@ var METRIC_FIELDS = [
3439
3457
  "batteryLevelPct",
3440
3458
  "batteryCharging",
3441
3459
  "thermal",
3442
- "diskFreeBytes"
3460
+ "diskFreeBytes",
3461
+ "netSignalDbm",
3462
+ "netLinkMbps",
3463
+ "netDownlinkKbps",
3464
+ "netFreqMhz"
3443
3465
  ];
3444
3466
  async function collectBrowserDeviceSample(families, environment = readBrowserDeviceInsightsEnvironment()) {
3445
3467
  const sample = {};
@@ -3458,6 +3480,12 @@ async function collectBrowserDeviceSample(families, environment = readBrowserDev
3458
3480
  sample.batteryCharging = battery.charging;
3459
3481
  }
3460
3482
  }
3483
+ if (families.includes("net")) {
3484
+ const downlinkKbps = readDownlinkKbps(environment);
3485
+ if (downlinkKbps !== void 0) {
3486
+ sample.netDownlinkKbps = downlinkKbps;
3487
+ }
3488
+ }
3461
3489
  return hasDeviceMetric(sample) ? sample : void 0;
3462
3490
  }
3463
3491
  function hasDeviceMetric(sample) {
@@ -3515,6 +3543,22 @@ async function readBattery(environment) {
3515
3543
  }
3516
3544
  return result;
3517
3545
  }
3546
+ function readDownlinkKbps(environment) {
3547
+ var _a;
3548
+ if (!environment.connection) {
3549
+ return void 0;
3550
+ }
3551
+ let downlink;
3552
+ try {
3553
+ downlink = (_a = environment.connection()) == null ? void 0 : _a.downlink;
3554
+ } catch (e) {
3555
+ return void 0;
3556
+ }
3557
+ if (typeof downlink !== "number" || !Number.isFinite(downlink) || downlink <= 0) {
3558
+ return void 0;
3559
+ }
3560
+ return Math.round(downlink * 1e3);
3561
+ }
3518
3562
  function readBrowserDeviceInsightsEnvironment() {
3519
3563
  const environment = {};
3520
3564
  const performanceRef = globalThis.performance;
@@ -3525,6 +3569,10 @@ function readBrowserDeviceInsightsEnvironment() {
3525
3569
  if (navigatorRef && typeof navigatorRef.getBattery === "function") {
3526
3570
  environment.getBattery = () => navigatorRef.getBattery();
3527
3571
  }
3572
+ const connectionRef = navigatorRef == null ? void 0 : navigatorRef.connection;
3573
+ if (connectionRef && typeof connectionRef === "object") {
3574
+ environment.connection = () => connectionRef;
3575
+ }
3528
3576
  return environment;
3529
3577
  }
3530
3578