@debugbundle/cli 1.29.0 → 1.30.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.
Files changed (2) hide show
  1. package/dist/main.cjs +452 -63
  2. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -52486,6 +52486,13 @@ function isSensitiveKey(key, sensitiveKeys) {
52486
52486
  }
52487
52487
  return false;
52488
52488
  }
52489
+ function isExactSensitiveKey(key, exactKeys) {
52490
+ if (exactKeys.length === 0) {
52491
+ return false;
52492
+ }
52493
+ const normalized = key.trim().toLowerCase();
52494
+ return exactKeys.some((candidate) => candidate.trim().toLowerCase() === normalized);
52495
+ }
52489
52496
 
52490
52497
  // ../../packages/redaction/src/telemetry-text.ts
52491
52498
  var REDACTED = "[REDACTED]";
@@ -52526,7 +52533,8 @@ function isValidCard(value) {
52526
52533
  }
52527
52534
  return sum % 10 === 0;
52528
52535
  }
52529
- function scrubUrl(raw, keys) {
52536
+ function scrubUrl(raw, additionalKeys, exactKeys) {
52537
+ const broadKeys = [...DEFAULT_SENSITIVE_KEYS, ...additionalKeys];
52530
52538
  try {
52531
52539
  const url2 = new URL(raw);
52532
52540
  if (url2.username || url2.password) {
@@ -52535,10 +52543,10 @@ function scrubUrl(raw, keys) {
52535
52543
  }
52536
52544
  const nextQuery = new URLSearchParams();
52537
52545
  for (const [key, value] of url2.searchParams) {
52538
- if (key.length > 128 || scrubCredentialText(key, keys, false) !== key) continue;
52546
+ if (key.length > 128 || scrubCredentialText(key, additionalKeys, false, exactKeys) !== key) continue;
52539
52547
  nextQuery.append(
52540
52548
  key,
52541
- isSensitiveKey(key, keys) || scrubCredentialText(value, keys, false) !== value ? REDACTED : value
52549
+ isSensitiveKey(key, broadKeys) || isExactSensitiveKey(key, exactKeys) || scrubCredentialText(value, additionalKeys, false, exactKeys) !== value ? REDACTED : value
52542
52550
  );
52543
52551
  }
52544
52552
  url2.search = nextQuery.toString();
@@ -52548,8 +52556,7 @@ function scrubUrl(raw, keys) {
52548
52556
  return REDACTED;
52549
52557
  }
52550
52558
  }
52551
- function scrubCredentialText(input3, additionalKeys, scanUrls = true) {
52552
- const keys = [...DEFAULT_SENSITIVE_KEYS, ...additionalKeys];
52559
+ function scrubCredentialText(input3, additionalKeys, scanUrls = true, exactKeys = []) {
52553
52560
  if (PEM_START.test(input3) && !PEM_COMPLETE.test(input3)) return REDACTED;
52554
52561
  let output3 = input3;
52555
52562
  if (/(?:password|token|secret|authorization|cookie)%3[ad]/i.test(output3)) {
@@ -52572,11 +52579,23 @@ function scrubCredentialText(input3, additionalKeys, scanUrls = true) {
52572
52579
  output3 = output3.replace(named, "$1$2[REDACTED]");
52573
52580
  }
52574
52581
  }
52582
+ if (exactKeys.length > 0) {
52583
+ for (const key of exactKeys) {
52584
+ const trimmed = key.trim();
52585
+ if (trimmed.length === 0) continue;
52586
+ const escaped = trimmed.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
52587
+ const named = new RegExp(
52588
+ `(?<![A-Za-z0-9_-])(${escaped})(?![A-Za-z0-9_-])(["']?\\s*[:=]\\s*)(?:"[^"]*"|'[^']*'|[^\\s&,;]+)`,
52589
+ "gi"
52590
+ );
52591
+ output3 = output3.replace(named, "$1$2[REDACTED]");
52592
+ }
52593
+ }
52575
52594
  output3 = output3.replace(CARD, (candidate) => isValidCard(candidate) ? REDACTED : candidate);
52576
52595
  if (!scanUrls) return output3;
52577
52596
  return output3.replace(URL_TEXT, (matched) => {
52578
52597
  const trailing = matched.match(/[).,;]+$/)?.[0] ?? "";
52579
- return scrubUrl(matched.slice(0, matched.length - trailing.length), keys) + trailing;
52598
+ return scrubUrl(matched.slice(0, matched.length - trailing.length), additionalKeys, exactKeys) + trailing;
52580
52599
  });
52581
52600
  }
52582
52601
 
@@ -52616,7 +52635,7 @@ function sanitizeString(value, state2, allowStructured) {
52616
52635
  if (error62 instanceof BudgetExceeded) throw error62;
52617
52636
  }
52618
52637
  }
52619
- const result = scrubCredentialText(value, state2.extra);
52638
+ const result = scrubCredentialText(value, state2.extra, true, state2.exact);
52620
52639
  if (result !== value) state2.redactionCount += 1;
52621
52640
  if ((value.startsWith("{") || value.startsWith("[")) && result === value && /(?:password|token|secret|authorization|cookie)["']?\s*[:=]/i.test(value)) {
52622
52641
  return mask(state2);
@@ -52655,14 +52674,14 @@ function sanitizeValue(value, state2, depth, allowStructured) {
52655
52674
  }
52656
52675
  state2.textBytes += byteLength(key);
52657
52676
  if (state2.textBytes > state2.maxTotalBytes) throw new BudgetExceeded();
52658
- const safeKey = scrubCredentialText(key, state2.extra);
52677
+ const safeKey = scrubCredentialText(key, state2.extra, true, state2.exact);
52659
52678
  if (safeKey !== key) {
52660
52679
  state2.redactionCount += 1;
52661
52680
  continue;
52662
52681
  }
52663
52682
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
52664
52683
  if (descriptor === void 0 || !("value" in descriptor)) throw new TypeError("unsafe_input");
52665
- const safeValue = isSensitiveKey(key, state2.keys) ? mask(state2) : sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
52684
+ const safeValue = isSensitiveKey(key, state2.keys) || isExactSensitiveKey(key, state2.exact) ? mask(state2) : sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
52666
52685
  Object.defineProperty(result, key, {
52667
52686
  value: safeValue,
52668
52687
  enumerable: true,
@@ -52678,7 +52697,8 @@ function sanitizeValue(value, state2, depth, allowStructured) {
52678
52697
  function sanitizeTelemetry(value, options = {}) {
52679
52698
  try {
52680
52699
  const extra = options.additionalKeys ?? [];
52681
- if (extra.length > 128 || extra.some((key) => typeof key !== "string" || key.length > 64 || !key.trim())) {
52700
+ const exact = options.exactKeys ?? [];
52701
+ if (extra.length + exact.length > 128 || extra.some((key) => typeof key !== "string" || key.length > 64 || !key.trim()) || exact.some((key) => typeof key !== "string" || key.length > 64 || !key.trim())) {
52682
52702
  return { ok: false, reason: "unsafe_input" };
52683
52703
  }
52684
52704
  const maxTotalBytes = options.maxTotalBytes ?? MAX_TOTAL_BYTES;
@@ -52692,6 +52712,7 @@ function sanitizeTelemetry(value, options = {}) {
52692
52712
  seen: /* @__PURE__ */ new WeakSet(),
52693
52713
  keys: [...DEFAULT_SENSITIVE_KEYS, ...extra],
52694
52714
  extra,
52715
+ exact,
52695
52716
  maxTotalBytes
52696
52717
  };
52697
52718
  const sanitized = sanitizeValue(value, state2, 0, true);
@@ -52705,7 +52726,7 @@ function sanitizeTelemetry(value, options = {}) {
52705
52726
  }
52706
52727
 
52707
52728
  // ../../packages/redaction/src/index.ts
52708
- function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths, seen) {
52729
+ function redactInternal(value, path3, sensitiveKeys, exactKeys, replacement, touchedPaths, seen) {
52709
52730
  if (Array.isArray(value)) {
52710
52731
  if (seen.has(value)) {
52711
52732
  return "[Circular]";
@@ -52716,6 +52737,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52716
52737
  entry,
52717
52738
  path3.length === 0 ? `[${index}]` : `${path3}[${index}]`,
52718
52739
  sensitiveKeys,
52740
+ exactKeys,
52719
52741
  replacement,
52720
52742
  touchedPaths,
52721
52743
  seen
@@ -52734,7 +52756,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52734
52756
  const output3 = {};
52735
52757
  for (const [key, nestedValue] of Object.entries(value)) {
52736
52758
  const nextPath = path3.length === 0 ? key : `${path3}.${key}`;
52737
- if (isSensitiveKey(key, sensitiveKeys)) {
52759
+ if (isSensitiveKey(key, sensitiveKeys) || isExactSensitiveKey(key, exactKeys)) {
52738
52760
  output3[key] = replacement;
52739
52761
  touchedPaths.push(nextPath);
52740
52762
  continue;
@@ -52743,6 +52765,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52743
52765
  nestedValue,
52744
52766
  nextPath,
52745
52767
  sensitiveKeys,
52768
+ exactKeys,
52746
52769
  replacement,
52747
52770
  touchedPaths,
52748
52771
  seen
@@ -52755,12 +52778,14 @@ function redact(payload, options) {
52755
52778
  const sensitiveKeys = options?.sensitiveKeys?.map((key) => key.trim().toLowerCase()) ?? [
52756
52779
  ...DEFAULT_SENSITIVE_KEYS
52757
52780
  ];
52781
+ const exactKeys = options?.exactKeys?.map((key) => key.trim().toLowerCase()) ?? [];
52758
52782
  const replacement = options?.replacement ?? "[REDACTED]";
52759
52783
  const touchedPaths = [];
52760
52784
  const redacted = redactInternal(
52761
52785
  payload,
52762
52786
  "",
52763
52787
  sensitiveKeys,
52788
+ exactKeys,
52764
52789
  replacement,
52765
52790
  touchedPaths,
52766
52791
  /* @__PURE__ */ new WeakSet()
@@ -56157,12 +56182,19 @@ var CAPTURE_RULE_RUNTIME_VALUES = [
56157
56182
  "java",
56158
56183
  "go",
56159
56184
  "ruby",
56185
+ "dotnet",
56186
+ "rust",
56187
+ "android",
56188
+ "swift",
56189
+ "react-native",
56160
56190
  "unknown"
56161
56191
  ];
56162
- var CaptureRuleActionValues = ["demote", "sample", "drop"];
56192
+ var CaptureRuleActionValues = ["demote", "sample", "drop", "threshold", "allow"];
56163
56193
  var CaptureRuleActionSchema = external_exports.enum(CaptureRuleActionValues);
56164
56194
  var CaptureRuleSampleEventClassValues = ["preserve", "context"];
56165
56195
  var CaptureRuleSampleEventClassSchema = external_exports.enum(CaptureRuleSampleEventClassValues);
56196
+ var CaptureRuleThresholdGroupByValues = ["resource", "fingerprint"];
56197
+ var CaptureRuleThresholdGroupBySchema = external_exports.enum(CaptureRuleThresholdGroupByValues);
56166
56198
  var CaptureRuleRuntimeSchema = external_exports.enum(CAPTURE_RULE_RUNTIME_VALUES);
56167
56199
  var CaptureRuleEventTypeSchema = external_exports.enum(CAPTURE_RULE_EVENT_TYPES);
56168
56200
  var BrowserEventKindSchema = external_exports.enum(["window_error", "resource_error"]);
@@ -56244,6 +56276,29 @@ var UrlMatcherSchema = external_exports.object({
56244
56276
  message: "URL matchers must include at least one host or path constraint."
56245
56277
  }
56246
56278
  );
56279
+ var ExactUrlMatcherSchema = external_exports.object({
56280
+ host: external_exports.string().trim().min(1).max(255),
56281
+ path_equals: external_exports.string().trim().min(1).max(1024)
56282
+ }).strict().transform((value) => ({
56283
+ host: value.host.toLowerCase(),
56284
+ path_equals: value.path_equals.startsWith("/") ? value.path_equals : `/${value.path_equals}`
56285
+ }));
56286
+ function normalizeExactUrlMatchers(values) {
56287
+ if (values === void 0) {
56288
+ return void 0;
56289
+ }
56290
+ const seen = /* @__PURE__ */ new Set();
56291
+ const normalized = [];
56292
+ for (const entry of values) {
56293
+ const key = `${entry.host}\0${entry.path_equals}`;
56294
+ if (seen.has(key)) {
56295
+ continue;
56296
+ }
56297
+ seen.add(key);
56298
+ normalized.push(entry);
56299
+ }
56300
+ return normalized;
56301
+ }
56247
56302
  var StatusRangeSchema = external_exports.object({
56248
56303
  start: external_exports.number().int().min(100).max(599),
56249
56304
  end: external_exports.number().int().min(100).max(599)
@@ -56286,6 +56341,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56286
56341
  client_kind: CaptureRuleClientKindSchema.optional(),
56287
56342
  bot_family: external_exports.string().min(1).max(120).optional(),
56288
56343
  resource_url: UrlMatcherSchema.optional(),
56344
+ resource_urls: external_exports.array(ExactUrlMatcherSchema).min(1).max(10).optional(),
56289
56345
  request_url: UrlMatcherSchema.optional(),
56290
56346
  status_codes: external_exports.array(external_exports.number().int().min(100).max(599)).min(1).optional(),
56291
56347
  status_ranges: external_exports.array(StatusRangeSchema).min(1).optional(),
@@ -56301,6 +56357,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56301
56357
  const messageEquals = normalizeOptionalTrimmedString(value.message_equals);
56302
56358
  const botFamily = normalizeOptionalTrimmedString(value.bot_family);
56303
56359
  const browserTargetTagName = normalizeOptionalTrimmedString(value.browser_target_tag_name);
56360
+ const resourceUrls = normalizeExactUrlMatchers(value.resource_urls);
56304
56361
  const statusCodes = normalizeNumberArray(value.status_codes);
56305
56362
  if (eventTypes !== void 0) {
56306
56363
  normalized.event_types = eventTypes;
@@ -56353,6 +56410,9 @@ var CaptureRuleMatcherSchema = external_exports.object({
56353
56410
  if (value.resource_url !== void 0) {
56354
56411
  normalized.resource_url = value.resource_url;
56355
56412
  }
56413
+ if (resourceUrls !== void 0) {
56414
+ normalized.resource_urls = resourceUrls;
56415
+ }
56356
56416
  if (value.request_url !== void 0) {
56357
56417
  normalized.request_url = value.request_url;
56358
56418
  }
@@ -56384,6 +56444,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56384
56444
  "client_kind",
56385
56445
  "bot_family",
56386
56446
  "resource_url",
56447
+ "resource_urls",
56387
56448
  "request_url",
56388
56449
  "status_codes",
56389
56450
  "status_ranges",
@@ -56395,8 +56456,15 @@ var CaptureRuleMatcherSchema = external_exports.object({
56395
56456
  message: "Capture rules must include at least one narrowing field beyond event_types."
56396
56457
  });
56397
56458
  }
56459
+ if (hasValue(value.resource_url) && hasValue(value.resource_urls)) {
56460
+ context.addIssue({
56461
+ code: external_exports.ZodIssueCode.custom,
56462
+ path: ["resource_urls"],
56463
+ message: "Capture rules cannot combine resource_url and resource_urls."
56464
+ });
56465
+ }
56398
56466
  if (value.browser_event_kind === "resource_error") {
56399
- const hasResourceConstraint = hasValue(value.resource_url) || hasValue(value.fingerprint);
56467
+ const hasResourceConstraint = hasValue(value.resource_url) || hasValue(value.resource_urls) || hasValue(value.fingerprint);
56400
56468
  if (!hasResourceConstraint) {
56401
56469
  context.addIssue({
56402
56470
  code: external_exports.ZodIssueCode.custom,
@@ -56413,42 +56481,112 @@ var CaptureRuleCoreObjectSchema = external_exports.object({
56413
56481
  matcher: CaptureRuleMatcherSchema,
56414
56482
  sample_rate: external_exports.number().min(0).max(1).nullable(),
56415
56483
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable(),
56484
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56485
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56486
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56416
56487
  created_by_user_id: external_exports.string().min(1).max(120).nullable(),
56417
56488
  created_from_incident_id: external_exports.string().min(1).max(120).nullable(),
56418
56489
  created_from_event_id: external_exports.string().min(1).max(120).nullable(),
56419
56490
  expires_at: external_exports.string().datetime().nullable()
56420
56491
  });
56492
+ function validateResourceThresholdMatcher(matcher, context) {
56493
+ if (matcher === void 0) {
56494
+ return;
56495
+ }
56496
+ const allowsFrontendException = matcher.event_types === void 0 || matcher.event_types.includes("frontend_exception");
56497
+ if (matcher.browser_event_kind !== "resource_error" || !allowsFrontendException) {
56498
+ context.addIssue({
56499
+ code: external_exports.ZodIssueCode.custom,
56500
+ path: ["threshold_group_by"],
56501
+ message: "Resource threshold grouping requires a browser resource_error matcher."
56502
+ });
56503
+ }
56504
+ }
56421
56505
  function addCaptureRuleActionValidation(schema) {
56422
56506
  return schema.superRefine((value, context) => {
56423
- if (value["action"] === "sample") {
56424
- if (value["sample_rate"] === null) {
56507
+ const action = value["action"];
56508
+ const sampleRate = value["sample_rate"];
56509
+ const sampleEventClass = value["sample_event_class"];
56510
+ const thresholdCount = value["threshold_count"];
56511
+ const thresholdWindowSeconds = value["threshold_window_seconds"];
56512
+ const thresholdGroupBy = value["threshold_group_by"];
56513
+ const matcher = value["matcher"];
56514
+ if (action === "sample") {
56515
+ if (sampleRate === null || sampleRate === void 0) {
56425
56516
  context.addIssue({
56426
56517
  code: external_exports.ZodIssueCode.custom,
56427
56518
  path: ["sample_rate"],
56428
56519
  message: "Sample rules require sample_rate."
56429
56520
  });
56430
56521
  }
56431
- if (value["sample_event_class"] === null) {
56522
+ if (sampleEventClass === null || sampleEventClass === void 0) {
56432
56523
  context.addIssue({
56433
56524
  code: external_exports.ZodIssueCode.custom,
56434
56525
  path: ["sample_event_class"],
56435
56526
  message: "Sample rules require sample_event_class."
56436
56527
  });
56437
56528
  }
56529
+ } else {
56530
+ if (hasValue(sampleRate)) {
56531
+ context.addIssue({
56532
+ code: external_exports.ZodIssueCode.custom,
56533
+ path: ["sample_rate"],
56534
+ message: "Only sample rules can set sample_rate."
56535
+ });
56536
+ }
56537
+ if (hasValue(sampleEventClass)) {
56538
+ context.addIssue({
56539
+ code: external_exports.ZodIssueCode.custom,
56540
+ path: ["sample_event_class"],
56541
+ message: "Only sample rules can set sample_event_class."
56542
+ });
56543
+ }
56544
+ }
56545
+ if (action === "threshold") {
56546
+ if (!hasValue(thresholdCount)) {
56547
+ context.addIssue({
56548
+ code: external_exports.ZodIssueCode.custom,
56549
+ path: ["threshold_count"],
56550
+ message: "Threshold rules require threshold_count."
56551
+ });
56552
+ }
56553
+ if (!hasValue(thresholdWindowSeconds)) {
56554
+ context.addIssue({
56555
+ code: external_exports.ZodIssueCode.custom,
56556
+ path: ["threshold_window_seconds"],
56557
+ message: "Threshold rules require threshold_window_seconds."
56558
+ });
56559
+ }
56560
+ if (!hasValue(thresholdGroupBy)) {
56561
+ context.addIssue({
56562
+ code: external_exports.ZodIssueCode.custom,
56563
+ path: ["threshold_group_by"],
56564
+ message: "Threshold rules require threshold_group_by."
56565
+ });
56566
+ } else if (thresholdGroupBy === "resource") {
56567
+ validateResourceThresholdMatcher(matcher, context);
56568
+ }
56438
56569
  return;
56439
56570
  }
56440
- if (value["sample_rate"] !== null) {
56571
+ if (hasValue(thresholdCount)) {
56441
56572
  context.addIssue({
56442
56573
  code: external_exports.ZodIssueCode.custom,
56443
- path: ["sample_rate"],
56444
- message: "Only sample rules can set sample_rate."
56574
+ path: ["threshold_count"],
56575
+ message: "Only threshold rules can set threshold_count."
56445
56576
  });
56446
56577
  }
56447
- if (value["sample_event_class"] !== null) {
56578
+ if (hasValue(thresholdWindowSeconds)) {
56448
56579
  context.addIssue({
56449
56580
  code: external_exports.ZodIssueCode.custom,
56450
- path: ["sample_event_class"],
56451
- message: "Only sample rules can set sample_event_class."
56581
+ path: ["threshold_window_seconds"],
56582
+ message: "Only threshold rules can set threshold_window_seconds."
56583
+ });
56584
+ }
56585
+ if (hasValue(thresholdGroupBy)) {
56586
+ context.addIssue({
56587
+ code: external_exports.ZodIssueCode.custom,
56588
+ path: ["threshold_group_by"],
56589
+ message: "Only threshold rules can set threshold_group_by."
56452
56590
  });
56453
56591
  }
56454
56592
  });
@@ -56473,6 +56611,9 @@ var CaptureRuleCreateSchema = external_exports.object({
56473
56611
  matcher: CaptureRuleMatcherSchema,
56474
56612
  sample_rate: external_exports.number().min(0).max(1).nullable().optional(),
56475
56613
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable().optional(),
56614
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56615
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56616
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56476
56617
  created_by_user_id: external_exports.string().min(1).max(120).nullable().default(null),
56477
56618
  created_from_incident_id: external_exports.string().min(1).max(120).nullable().default(null),
56478
56619
  created_from_event_id: external_exports.string().min(1).max(120).nullable().default(null),
@@ -56486,26 +56627,76 @@ var CaptureRuleCreateSchema = external_exports.object({
56486
56627
  message: "Sample rules require sample_rate."
56487
56628
  });
56488
56629
  }
56630
+ } else {
56631
+ if (value.sample_rate !== void 0 && value.sample_rate !== null) {
56632
+ context.addIssue({
56633
+ code: external_exports.ZodIssueCode.custom,
56634
+ path: ["sample_rate"],
56635
+ message: "Only sample rules can set sample_rate."
56636
+ });
56637
+ }
56638
+ if (value.sample_event_class !== void 0 && value.sample_event_class !== null) {
56639
+ context.addIssue({
56640
+ code: external_exports.ZodIssueCode.custom,
56641
+ path: ["sample_event_class"],
56642
+ message: "Only sample rules can set sample_event_class."
56643
+ });
56644
+ }
56645
+ }
56646
+ if (value.action === "threshold") {
56647
+ if (!hasValue(value.threshold_count)) {
56648
+ context.addIssue({
56649
+ code: external_exports.ZodIssueCode.custom,
56650
+ path: ["threshold_count"],
56651
+ message: "Threshold rules require threshold_count."
56652
+ });
56653
+ }
56654
+ if (!hasValue(value.threshold_window_seconds)) {
56655
+ context.addIssue({
56656
+ code: external_exports.ZodIssueCode.custom,
56657
+ path: ["threshold_window_seconds"],
56658
+ message: "Threshold rules require threshold_window_seconds."
56659
+ });
56660
+ }
56661
+ if (!hasValue(value.threshold_group_by)) {
56662
+ context.addIssue({
56663
+ code: external_exports.ZodIssueCode.custom,
56664
+ path: ["threshold_group_by"],
56665
+ message: "Threshold rules require threshold_group_by."
56666
+ });
56667
+ } else if (value.threshold_group_by === "resource") {
56668
+ validateResourceThresholdMatcher(value.matcher, context);
56669
+ }
56489
56670
  return;
56490
56671
  }
56491
- if (value.sample_rate !== void 0 && value.sample_rate !== null) {
56672
+ if (hasValue(value.threshold_count)) {
56492
56673
  context.addIssue({
56493
56674
  code: external_exports.ZodIssueCode.custom,
56494
- path: ["sample_rate"],
56495
- message: "Only sample rules can set sample_rate."
56675
+ path: ["threshold_count"],
56676
+ message: "Only threshold rules can set threshold_count."
56496
56677
  });
56497
56678
  }
56498
- if (value.sample_event_class !== void 0 && value.sample_event_class !== null) {
56679
+ if (hasValue(value.threshold_window_seconds)) {
56499
56680
  context.addIssue({
56500
56681
  code: external_exports.ZodIssueCode.custom,
56501
- path: ["sample_event_class"],
56502
- message: "Only sample rules can set sample_event_class."
56682
+ path: ["threshold_window_seconds"],
56683
+ message: "Only threshold rules can set threshold_window_seconds."
56684
+ });
56685
+ }
56686
+ if (hasValue(value.threshold_group_by)) {
56687
+ context.addIssue({
56688
+ code: external_exports.ZodIssueCode.custom,
56689
+ path: ["threshold_group_by"],
56690
+ message: "Only threshold rules can set threshold_group_by."
56503
56691
  });
56504
56692
  }
56505
56693
  }).transform((value) => ({
56506
56694
  ...value,
56507
56695
  sample_rate: value.action === "sample" ? value.sample_rate : null,
56508
- sample_event_class: value.action === "sample" ? value.sample_event_class ?? "preserve" : null
56696
+ sample_event_class: value.action === "sample" ? value.sample_event_class ?? "preserve" : null,
56697
+ threshold_count: value.action === "threshold" ? value.threshold_count : null,
56698
+ threshold_window_seconds: value.action === "threshold" ? value.threshold_window_seconds : null,
56699
+ threshold_group_by: value.action === "threshold" ? value.threshold_group_by : null
56509
56700
  }));
56510
56701
  var CaptureRuleUpdateSchema = external_exports.object({
56511
56702
  project_scope: external_exports.literal("current_project").optional(),
@@ -56516,6 +56707,9 @@ var CaptureRuleUpdateSchema = external_exports.object({
56516
56707
  matcher: CaptureRuleMatcherSchema.optional(),
56517
56708
  sample_rate: external_exports.number().min(0).max(1).nullable().optional(),
56518
56709
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable().optional(),
56710
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56711
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56712
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56519
56713
  expires_at: external_exports.string().datetime().nullable().optional()
56520
56714
  }).superRefine((value, context) => {
56521
56715
  if (Object.keys(value).length === 0) {
@@ -56526,34 +56720,81 @@ var CaptureRuleUpdateSchema = external_exports.object({
56526
56720
  }
56527
56721
  const resolvedAction = value.action;
56528
56722
  if (resolvedAction === "sample") {
56529
- if (!("sample_rate" in value)) {
56723
+ if (!("sample_rate" in value) || value.sample_rate === null) {
56530
56724
  context.addIssue({
56531
56725
  code: external_exports.ZodIssueCode.custom,
56532
56726
  path: ["sample_rate"],
56533
56727
  message: "Sample rule updates must include sample_rate when changing action to sample."
56534
56728
  });
56535
56729
  }
56536
- if (!("sample_event_class" in value)) {
56730
+ if (!("sample_event_class" in value) || value.sample_event_class === null) {
56537
56731
  context.addIssue({
56538
56732
  code: external_exports.ZodIssueCode.custom,
56539
56733
  path: ["sample_event_class"],
56540
56734
  message: "Sample rule updates must include sample_event_class when changing action to sample."
56541
56735
  });
56542
56736
  }
56737
+ } else {
56738
+ if ("sample_rate" in value) {
56739
+ context.addIssue({
56740
+ code: external_exports.ZodIssueCode.custom,
56741
+ path: ["sample_rate"],
56742
+ message: "Sample rule fields can only be updated while setting action to sample."
56743
+ });
56744
+ }
56745
+ if ("sample_event_class" in value) {
56746
+ context.addIssue({
56747
+ code: external_exports.ZodIssueCode.custom,
56748
+ path: ["sample_event_class"],
56749
+ message: "Sample rule fields can only be updated while setting action to sample."
56750
+ });
56751
+ }
56752
+ }
56753
+ if (resolvedAction === "threshold") {
56754
+ if (!("threshold_count" in value) || !hasValue(value.threshold_count)) {
56755
+ context.addIssue({
56756
+ code: external_exports.ZodIssueCode.custom,
56757
+ path: ["threshold_count"],
56758
+ message: "Threshold rule updates must include threshold_count when changing action to threshold."
56759
+ });
56760
+ }
56761
+ if (!("threshold_window_seconds" in value) || !hasValue(value.threshold_window_seconds)) {
56762
+ context.addIssue({
56763
+ code: external_exports.ZodIssueCode.custom,
56764
+ path: ["threshold_window_seconds"],
56765
+ message: "Threshold rule updates must include threshold_window_seconds when changing action to threshold."
56766
+ });
56767
+ }
56768
+ if (!("threshold_group_by" in value) || !hasValue(value.threshold_group_by)) {
56769
+ context.addIssue({
56770
+ code: external_exports.ZodIssueCode.custom,
56771
+ path: ["threshold_group_by"],
56772
+ message: "Threshold rule updates must include threshold_group_by when changing action to threshold."
56773
+ });
56774
+ } else if (value.threshold_group_by === "resource" && value.matcher !== void 0) {
56775
+ validateResourceThresholdMatcher(value.matcher, context);
56776
+ }
56543
56777
  return;
56544
56778
  }
56545
- if ("sample_rate" in value) {
56779
+ if ("threshold_count" in value) {
56546
56780
  context.addIssue({
56547
56781
  code: external_exports.ZodIssueCode.custom,
56548
- path: ["sample_rate"],
56549
- message: "Sample rule fields can only be updated while setting action to sample."
56782
+ path: ["threshold_count"],
56783
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56550
56784
  });
56551
56785
  }
56552
- if ("sample_event_class" in value) {
56786
+ if ("threshold_window_seconds" in value) {
56553
56787
  context.addIssue({
56554
56788
  code: external_exports.ZodIssueCode.custom,
56555
- path: ["sample_event_class"],
56556
- message: "Sample rule fields can only be updated while setting action to sample."
56789
+ path: ["threshold_window_seconds"],
56790
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56791
+ });
56792
+ }
56793
+ if ("threshold_group_by" in value) {
56794
+ context.addIssue({
56795
+ code: external_exports.ZodIssueCode.custom,
56796
+ path: ["threshold_group_by"],
56797
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56557
56798
  });
56558
56799
  }
56559
56800
  });
@@ -56797,7 +57038,7 @@ function browserResourceDiagnosis(resource) {
56797
57038
  return resource?.optional_candidate === true ? "The browser reported that this script failed to load. Possibly blocked by privacy tools; network, CSP or provider failures are also possible. The captured event does not identify the cause." : "The browser reported that this resource failed to load. The captured event does not identify the cause or establish whether application functionality was affected.";
56798
57039
  }
56799
57040
 
56800
- // ../../packages/shared-types/src/capture-rule-evaluation.ts
57041
+ // ../../packages/shared-types/src/capture-rule-evaluation-context.ts
56801
57042
  var CaptureRuleEvaluationUrlSchema = external_exports.object({
56802
57043
  host: external_exports.string().min(1).transform((value) => value.toLowerCase()).optional(),
56803
57044
  path: external_exports.string().min(1).transform((value) => value.startsWith("/") ? value : `/${value}`)
@@ -62823,10 +63064,12 @@ function buildSkill() {
62823
63064
  "",
62824
63065
  "### Browser resource failures",
62825
63066
  "",
62826
- "- Inspect the primary failure and routes: one resource can span pages, route coverage may be incomplete, and historical incidents stay separate. Related tracker evidence does not explain an application exception.",
62827
- '- If the cause is unknown, say "possibly blocked by privacy tools." Network/CSP/provider failures remain possible; provider recognition proves neither Pi-hole blocking nor optionality.',
63067
+ "- Inspect the primary failure, routes, and passive evidence first: one resource can span pages, route coverage may be incomplete, and historical incidents stay separate. Related tracker evidence does not explain an application exception.",
63068
+ '- Distinguish observed evidence from unknown causes: treat enforced CSP (`disposition: "enforce"`) separately from report-only CSP (`disposition: "report"`, which does not block), check observed resource-timing HTTP status, explicit recovery outcomes, and `visibility_state: "unloaded"` (`pagehide` teardown aborts). When the cause is still unknown, say "possibly blocked by privacy tools." Network/CSP/provider failures remain possible; provider recognition proves neither Pi-hole blocking nor optionality.',
62828
63069
  "- Review exact resource host/path/type, service, environment and opacity, or the returned exact fingerprint when evidence is incomplete; never widen to a whole host. All resource incidents can offer explicit controls. Provider recognition does not establish that a dependency is optional; do not suppress authentication, app assets or unknown dependencies automatically.",
62829
- "- For confirmed optional dependencies, context (demote) retains diagnostics without new incidents/alerts/automation and may remain billable. Drop discards future matches; choose it only when evidence has no diagnostic value. Explain the tradeoff; neither deletes history. Use the returned suggestion ID.",
63070
+ '- For single-visitor transient resource failures or deploy-hashed application assets (such as `/assets/`), prefer an opt-in `threshold` rule (`resource_threshold` suggestion or `--action threshold` with `--threshold-count`, `--threshold-window-seconds`, and `--threshold-group-by <resource|fingerprint>`) over `demote` or `drop`. Events below threshold wait without opening incidents or alerts, while real repeated outages still open one incident with prior-window occurrences and routes backfilled. Pair broader prefix rules with higher-specificity `action: "allow"` carve-outs when critical paths (such as checkout or authentication assets) must still open on the first failure.',
63071
+ "- For confirmed optional dependencies, context (`demote`) retains diagnostics without new incidents/alerts/automation and may remain billable; `drop` discards future matches and should be chosen only when evidence has no diagnostic value. When one confirmed optional dependency loads across primary and fallback CDN addresses, group them in one rule using `matcher.resource_urls` (1\u201310 exact `{ host, path_equals }` entries) instead of widening to a host. Explain the tradeoff; neither deletes history. Use the returned suggestion ID.",
63072
+ "- If legacy resource events show a redacted `tag_name` splitting one resource into per-route incidents, check the app's SDK `redactFields` configuration and recommend moving narrow private domain keys (such as `tag`) to exact-key `redactExactFields` alongside a protected SDK release that preserves schema-validated protocol fields.",
62830
63073
  "- Check existing/disabled rules. Empty suggestions or pending/failed bundles do not justify broader rules. Applying requires user authorization and owner/admin access; preview is read-only. Verify subsequent matching and protected captures before claiming improvement; live tests need authorization.",
62831
63074
  "- The official OpenAI connection cannot suggest or apply rules. When it is the only connection, review returned evidence and hand off through a returned safe dashboard URL; never invent tools or switch credentials.",
62832
63075
  "",
@@ -62937,11 +63180,12 @@ function buildCliReference() {
62937
63180
  "- `debugbundle capture-rule suggest <incident-id> [--auth-file <path>] [--json]`",
62938
63181
  "- `debugbundle capture-rule create-from-suggestion <incident-id> --suggestion-id <id> [--name <name>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]`",
62939
63182
  "- `debugbundle capture-rule list --project-id <id> [--auth-file <path>] [--json]`",
62940
- "- `debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop> --matcher-json <json> [--auth-file <path>] [--json]`",
63183
+ "- `debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop|threshold|allow> --matcher-json <json> [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]`",
63184
+ "- `debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--action <demote|sample|drop|threshold|allow>] [--matcher-json <json>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--enabled <true|false>] [--expires-at <ISO8601|null>] [--auth-file <path>] [--json]`",
62941
63185
  "- `debugbundle capture-policy get [--project <id>] [--json]`",
62942
63186
  "- `debugbundle capture-policy set [--project <id>] --client-error-path-rule <404=/path/*@GET,POST> [--json]`",
62943
63187
  "",
62944
- "Use capture-rule suggestions for repeated operational noise after inspecting an incident bundle. Use capture-policy client-error path rules for route-scoped 4xx incidents instead of promoting all client errors.",
63188
+ "Use capture-rule suggestions for repeated operational noise after inspecting an incident bundle. Prefer `threshold` (`resource_threshold` suggestion) for single-visitor transient resource failures and deploy-hashed assets, pair broader prefix rules with higher-specificity `allow` carve-outs for critical paths, and use `matcher.resource_urls` (1\u201310 exact `{ host, path_equals }` entries) for multi-CDN optional dependencies. Use capture-policy client-error path rules for route-scoped 4xx incidents instead of promoting all client errors.",
62945
63189
  "For browser resource failures, follow the skill's Browser resource failures guidance. Use the current response's suggestion ID, inspect `bundle_status`, `access_mode` and existing-rule state, and review the complete matcher before applying.",
62946
63190
  "",
62947
63191
  "## Probes",
@@ -63082,10 +63326,10 @@ function buildMcpReference() {
63082
63326
  "",
63083
63327
  "- `suggest_capture_rules_from_incident` \u2014 generate deterministic capture-rule suggestions from an incident bundle.",
63084
63328
  "- `create_capture_rule_from_incident_suggestion` \u2014 apply a confirmed suggestion.",
63085
- "- `list_capture_rules`, `create_capture_rule`, `update_capture_rule`, `delete_capture_rule` \u2014 manage project capture rules.",
63329
+ "- `list_capture_rules`, `create_capture_rule`, `update_capture_rule`, `delete_capture_rule` \u2014 manage project capture rules (`demote`, `sample`, `drop`, `threshold` with rolling-window counts, `allow` carve-outs, and bounded `matcher.resource_urls`).",
63086
63330
  "- `get_capture_policy`, `update_capture_policy` \u2014 review or update capture policy, including path-scoped client-error incident rules.",
63087
63331
  "",
63088
- "Use these tools for repeated low-value operational noise only after inspecting incident evidence. Keep frontend suppression scoped by structured browser and client signals, and use path-scoped capture policy for known 4xx routes.",
63332
+ "Use these tools for repeated low-value operational noise only after inspecting incident evidence. Prefer `threshold` (`resource_threshold`) for transient single-visitor or deploy-hashed resource noise, `allow` carve-outs for critical assets, and `resource_urls` for multi-CDN optional dependencies. Keep frontend suppression scoped by structured browser and client signals, and use path-scoped capture policy for known 4xx routes.",
63089
63333
  "For browser resource failures, follow the skill's Browser resource failures guidance and use the suggestion ID returned by the server. These management tools belong to the access-token-authenticated MCP surface; the official OpenAI connection is read-only and cannot suggest or apply capture rules.",
63090
63334
  "",
63091
63335
  "## Product Analytics Tools",
@@ -63310,6 +63554,15 @@ function buildSkillEvals() {
63310
63554
  "Verify the returned rule without claiming historical incidents were removed or live noise reduction was already observed."
63311
63555
  ]
63312
63556
  },
63557
+ {
63558
+ name: "transient_hashed_asset_threshold_review",
63559
+ prompt: "Single-visitor deploy-hashed CSS/JS failures under /assets/ keep opening one-off incidents, while checkout assets under /assets/checkout- must stay immediate. A separate resource incident has a redacted tag_name because the app put tag in redactFields. Explain how to handle both safely.",
63560
+ expected_behavior: [
63561
+ "Inspect bundle evidence first, including passive CSP disposition, resource timing status, recovery observations, and unloaded teardown state.",
63562
+ "Recommend a scoped threshold rule (or resource_threshold suggestion) for transient /assets/ failures instead of broad demote/drop or whole-host suppression, paired with a higher-specificity allow carve-out for /assets/checkout-.",
63563
+ "Recommend moving narrow private domain keys such as tag to exact-key redactExactFields alongside a protected SDK release so protocol fields like tag_name stay intact."
63564
+ ]
63565
+ },
63313
63566
  {
63314
63567
  name: "protected_resource_noise_review",
63315
63568
  prompt: "A checkout TypeError has related GTM evidence. Separate incidents show Google sign-in and an unknown script failing. The user asks whether ignoring all Google or third-party hosts would clean this up.",
@@ -71468,6 +71721,18 @@ function buildDependenciesContext(incident, errorContext, requestContext) {
71468
71721
  ]
71469
71722
  };
71470
71723
  }
71724
+ function formatPassiveRecoveryNote(recoveryContext) {
71725
+ if (recoveryContext === void 0 || recoveryContext.outcome === "unknown") {
71726
+ return "";
71727
+ }
71728
+ if (recoveryContext.outcome === "recovered") {
71729
+ return " Explicit application recovery was later observed within the failure scope; incident status remains unchanged.";
71730
+ }
71731
+ if (recoveryContext.outcome === "persisted") {
71732
+ return " An explicit persistent-failure observation was later recorded within the failure scope.";
71733
+ }
71734
+ return " Conflicting recovery and persistent-failure observations were recorded within the failure scope.";
71735
+ }
71471
71736
  function buildSummaryGuidance(input3) {
71472
71737
  if (input3.errorContext === null) {
71473
71738
  return {
@@ -71478,10 +71743,11 @@ function buildSummaryGuidance(input3) {
71478
71743
  }
71479
71744
  if (input3.opaqueBrowserError) {
71480
71745
  if (input3.browserEvent?.kind === "resource_error") {
71746
+ const recoveryNote = formatPassiveRecoveryNote(input3.recoveryContext);
71481
71747
  const recoveryFailure = input3.resourceContext?.recovery_failures?.[0];
71482
71748
  if (recoveryFailure !== void 0) {
71483
71749
  return {
71484
- likely_cause: `The browser resource failure was followed by ${recoveryFailure.method} ${recoveryFailure.path} returning HTTP ${recoveryFailure.status_code}. This correlated recovery failure is the most actionable captured signal; it does not establish why the original resource load was interrupted.`,
71750
+ likely_cause: `The browser resource failure was followed by ${recoveryFailure.method} ${recoveryFailure.path} returning HTTP ${recoveryFailure.status_code}. This correlated recovery failure is the most actionable captured signal; it does not establish why the original resource load was interrupted.${recoveryNote}`,
71485
71751
  confidence: 0.65,
71486
71752
  recommended_action: `Inspect the ${recoveryFailure.path} recovery route and its HTTP ${recoveryFailure.status_code} response, including any refresh, retry, or signed-URL handling, before investigating the generic resource error.`
71487
71753
  };
@@ -71489,14 +71755,60 @@ function buildSummaryGuidance(input3) {
71489
71755
  if (input3.resourceContext?.interruption !== void 0) {
71490
71756
  const interruption = input3.resourceContext.interruption;
71491
71757
  return {
71492
- likely_cause: `The browser reported an opaque ${interruption.rel} failure while the page was ${interruption.visibility_state} and ${interruption.ready_state}. This is consistent with a browser-aborted speculative load, but the captured lifecycle state does not prove the cause.`,
71758
+ likely_cause: `The browser reported an opaque ${interruption.rel} failure while the page was ${interruption.visibility_state} and ${interruption.ready_state}. This is consistent with a browser-aborted speculative load, but the captured lifecycle state does not prove the cause.${recoveryNote}`,
71493
71759
  confidence: 0.55,
71494
71760
  recommended_action: "Confirm whether the page was navigating or suspended, then review only lifecycle-scoped demotion if the asset succeeds during active page loads."
71495
71761
  };
71496
71762
  }
71763
+ const observationItems = input3.resourceObservations?.items ?? [];
71764
+ const enforcedCspDirectives = Array.from(
71765
+ new Set(
71766
+ observationItems.flatMap(
71767
+ ({ observation }) => observation.kind === "csp" && observation.disposition === "enforce" ? [observation.effective_directive] : []
71768
+ )
71769
+ )
71770
+ ).sort();
71771
+ if (enforcedCspDirectives.length > 0) {
71772
+ const directiveLabel = enforcedCspDirectives.join(", ");
71773
+ return {
71774
+ likely_cause: `An enforced Content Security Policy observation (${directiveLabel}) was captured alongside this resource failure. Temporal association does not prove causation, and document HTTP status is separate from resource status.${recoveryNote}`,
71775
+ confidence: 0.55,
71776
+ recommended_action: `Review the enforced ${directiveLabel} Content Security Policy directive for the affected resource host and confirm whether the asset should be permitted.`
71777
+ };
71778
+ }
71779
+ const observedFailureStatuses = Array.from(
71780
+ new Set(
71781
+ observationItems.flatMap(
71782
+ ({ observation }) => observation.kind === "timing" && observation.availability === "observed" && observation.response_status !== null && observation.response_status >= 400 ? [observation.response_status] : []
71783
+ )
71784
+ )
71785
+ ).sort((left, right) => left - right);
71786
+ if (observedFailureStatuses.length > 0) {
71787
+ const statusLabel = observedFailureStatuses.map((code) => `HTTP ${code}`).join(", ");
71788
+ return {
71789
+ likely_cause: `Passive resource timing observed ${statusLabel} for a matching resource load around this failure. Association is passive and does not prove the root cause.${recoveryNote}`,
71790
+ confidence: 0.55,
71791
+ recommended_action: `Check server or CDN availability, permissions, and asset deployment for the affected resource returning ${statusLabel}.`
71792
+ };
71793
+ }
71794
+ const reportOnlyCspDirectives = Array.from(
71795
+ new Set(
71796
+ observationItems.flatMap(
71797
+ ({ observation }) => observation.kind === "csp" && observation.disposition === "report" ? [observation.effective_directive] : []
71798
+ )
71799
+ )
71800
+ ).sort();
71497
71801
  const resource = describeBrowserResource(input3.browserEvent);
71802
+ if (reportOnlyCspDirectives.length > 0) {
71803
+ const directiveLabel = reportOnlyCspDirectives.join(", ");
71804
+ return {
71805
+ likely_cause: `A report-only Content Security Policy observation (${directiveLabel}) was captured alongside this resource failure. Report-only policies do not block resource loads, so the cause and application impact remain unknown.${recoveryNote}`,
71806
+ confidence: 0.35,
71807
+ recommended_action: "Check the affected resource and routes, browser network failures, CSP and provider availability." + (resource?.optional_candidate === true ? " If the dependency is optional for your app, review a resource-scoped noise rule." : " Verify whether application functionality is affected.")
71808
+ };
71809
+ }
71498
71810
  return {
71499
- likely_cause: browserResourceDiagnosis(resource),
71811
+ likely_cause: `${browserResourceDiagnosis(resource)}${recoveryNote}`,
71500
71812
  confidence: 0.35,
71501
71813
  recommended_action: "Check the affected resource and routes, browser network failures, CSP and provider availability." + (resource?.optional_candidate === true ? " If the dependency is optional for your app, review a resource-scoped noise rule." : " Verify whether application functionality is affected.")
71502
71814
  };
@@ -71751,7 +72063,8 @@ function buildBundle(input3) {
71751
72063
  const primaryService = primarySignalEnvelope?.event_type === "probe_event" ? void 0 : primarySignalEnvelope?.service;
71752
72064
  const serviceRuntime = primaryService?.runtime ?? input3.incident.service_runtime ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.runtime ?? null;
71753
72065
  const serviceFramework = primaryService?.framework ?? input3.incident.service_framework ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.framework ?? null;
71754
- const customerVisible = frontendContext !== null;
72066
+ const hiddenOrUnloadedOpaqueResourceError = opaqueBrowserError && browserEvent?.kind === "resource_error" && (browserEvent.page?.visibility_state === "hidden" || browserEvent.page?.visibility_state === "prerender" || browserEvent.page?.visibility_state === "unloaded");
72067
+ const customerVisible = frontendContext !== null && !hiddenOrUnloadedOpaqueResourceError;
71755
72068
  const firstApplicationFrame = opaqueBrowserError ? null : deriveFirstApplicationFrame(errorContext);
71756
72069
  const summaryGuidance = buildSummaryGuidance({
71757
72070
  errorContext,
@@ -71761,7 +72074,9 @@ function buildBundle(input3) {
71761
72074
  firstApplicationFrame,
71762
72075
  browserEvent,
71763
72076
  opaqueBrowserError,
71764
- resourceContext
72077
+ resourceContext,
72078
+ ...diagnostics.resources === void 0 ? {} : { resourceObservations: diagnostics.resources },
72079
+ ...diagnostics.recovery === void 0 ? {} : { recoveryContext: diagnostics.recovery }
71765
72080
  });
71766
72081
  const candidate = {
71767
72082
  bundle_version: 1,
@@ -72695,7 +73010,7 @@ async function processCommand(input3, dependencies = {}) {
72695
73010
  aggregate.newEvents.push(event);
72696
73011
  aggregate.signalEventTypes.add(event.event_type);
72697
73012
  const traceId = getTraceId(event);
72698
- if (traceId !== null && normalizedEvent.resource_type === void 0) {
73013
+ if (traceId !== null && normalizedEvent.browser_event_kind !== "resource_error") {
72699
73014
  aggregate.traceIds.add(traceId);
72700
73015
  const traceKey = buildTraceCorrelationKey(projectId, event.service.environment, traceId);
72701
73016
  const traceCorrelationGroup = traceCorrelationGroups.get(traceKey) ?? {
@@ -81329,8 +81644,8 @@ var CLI_USAGE_LINES = [
81329
81644
  " debugbundle capture-rule list --project-id <id> [--auth-file <path>] [--json]",
81330
81645
  " debugbundle capture-rule suggest <incident-id> [--auth-file <path>] [--json]",
81331
81646
  " debugbundle capture-rule create-from-suggestion <incident-id> --suggestion-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81332
- " debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop> --matcher-json <json> [--description <text>] [--enabled <true|false>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81333
- " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601|null>] [--project-scope <current_project>] [--auth-file <path>] [--json]",
81647
+ " debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop|threshold|allow> --matcher-json <json> [--description <text>] [--enabled <true|false>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81648
+ " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop|threshold|allow>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601|null>] [--project-scope <current_project>] [--auth-file <path>] [--json]",
81334
81649
  " debugbundle capture-rule delete <rule-id> --project-id <id> [--auth-file <path>] [--json]",
81335
81650
  " debugbundle improvements list [--project-id <id>] [--environment <name>] [--service <name>] [--status <status>] [--severity <level>] [--kind <kind>] [--cursor <cursor>] [--limit <n>] [--auth-file <path>] [--json]",
81336
81651
  " debugbundle improvements get <improvement-id> [--auth-file <path>] [--json]",
@@ -87911,7 +88226,7 @@ function createCaptureRuleApi(httpClient) {
87911
88226
  async listCaptureRules(input3) {
87912
88227
  const response = await httpClient.request({
87913
88228
  method: "GET",
87914
- path: `/v1/projects/${encodeURIComponent(input3.projectId)}/capture-rules`,
88229
+ path: `/v1/projects/${encodeURIComponent(input3.projectId)}/capture-rules?rule_schema=2`,
87915
88230
  bearerToken: input3.bearerToken
87916
88231
  });
87917
88232
  if (response.status !== 200) {
@@ -87942,7 +88257,7 @@ function createCaptureRuleApi(httpClient) {
87942
88257
  async suggestCaptureRulesFromIncident(input3) {
87943
88258
  const response = await httpClient.request({
87944
88259
  method: "POST",
87945
- path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rule-suggestion`,
88260
+ path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rule-suggestion?rule_schema=2`,
87946
88261
  bearerToken: input3.bearerToken
87947
88262
  });
87948
88263
  if (response.status !== 200) {
@@ -87957,12 +88272,16 @@ function createCaptureRuleApi(httpClient) {
87957
88272
  async createCaptureRuleFromIncidentSuggestion(input3) {
87958
88273
  const response = await httpClient.request({
87959
88274
  method: "POST",
87960
- path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rules`,
88275
+ path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rules?rule_schema=2`,
87961
88276
  bearerToken: input3.bearerToken,
87962
88277
  body: input3.create
87963
88278
  });
87964
88279
  if (response.status !== 200 && response.status !== 201) {
87965
- throw toApiError10(response.status, response.body, "Failed to create capture rule from suggestion.");
88280
+ throw toApiError10(
88281
+ response.status,
88282
+ response.body,
88283
+ "Failed to create capture rule from suggestion."
88284
+ );
87966
88285
  }
87967
88286
  const parsed = CaptureRuleResponseSchema.safeParse(response.body);
87968
88287
  if (!parsed.success) {
@@ -88034,7 +88353,11 @@ function formatMatcherFromValue(matcher) {
88034
88353
  if (matcher.browser_event_opaque !== void 0) {
88035
88354
  parts.push(`browser_event_opaque=${String(matcher.browser_event_opaque)}`);
88036
88355
  }
88037
- for (const key of ["browser_page_visibility_state", "browser_page_ready_state", "browser_target_tag_name"]) {
88356
+ for (const key of [
88357
+ "browser_page_visibility_state",
88358
+ "browser_page_ready_state",
88359
+ "browser_target_tag_name"
88360
+ ]) {
88038
88361
  if (matcher[key] !== void 0) parts.push(`${key}=${matcher[key]}`);
88039
88362
  }
88040
88363
  if (matcher.browser_target_attributes !== void 0) {
@@ -88064,9 +88387,20 @@ function formatMatcherFromValue(matcher) {
88064
88387
  if (matcher.resource_url?.host !== void 0) {
88065
88388
  parts.push(`resource_host=${matcher.resource_url.host}`);
88066
88389
  }
88390
+ if (matcher.resource_url?.host_suffix !== void 0) {
88391
+ parts.push(`resource_host_suffix=${matcher.resource_url.host_suffix}`);
88392
+ }
88067
88393
  if (matcher.resource_url?.path_equals !== void 0) {
88068
88394
  parts.push(`resource_path=${matcher.resource_url.path_equals}`);
88069
88395
  }
88396
+ if (matcher.resource_url?.path_prefix !== void 0) {
88397
+ parts.push(`resource_path_prefix=${matcher.resource_url.path_prefix}`);
88398
+ }
88399
+ if (matcher.resource_urls !== void 0 && matcher.resource_urls.length > 0) {
88400
+ parts.push(
88401
+ `resource_urls=${matcher.resource_urls.map((entry) => `${entry.host}${entry.path_equals}`).join(",")}`
88402
+ );
88403
+ }
88070
88404
  if (matcher.request_url?.path_equals !== void 0) {
88071
88405
  parts.push(`request_path=${matcher.request_url.path_equals}`);
88072
88406
  }
@@ -88082,7 +88416,7 @@ function formatMatcher(rule) {
88082
88416
  return formatMatcherFromValue(rule.matcher);
88083
88417
  }
88084
88418
  function formatRule(rule) {
88085
- const action = rule.action === "sample" ? `${rule.action}:${rule.sample_rate ?? "?"}:${rule.sample_event_class ?? "?"}` : rule.action;
88419
+ const action = rule.action === "sample" ? `${rule.action}:${rule.sample_rate ?? "?"}:${rule.sample_event_class ?? "?"}` : rule.action === "threshold" ? `${rule.action}:${rule.threshold_count ?? "?"}/${rule.threshold_window_seconds ?? "?"}s:${rule.threshold_group_by ?? "?"}` : rule.action;
88086
88420
  return [
88087
88421
  `${rule.enabled ? "enabled" : "disabled"} ${rule.id} ${action} ${rule.name}`,
88088
88422
  formatMatcher(rule)
@@ -88788,6 +89122,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88788
89122
  "matcher-json",
88789
89123
  "sample-rate",
88790
89124
  "sample-event-class",
89125
+ "threshold-count",
89126
+ "threshold-window-seconds",
89127
+ "threshold-group-by",
88791
89128
  "expires-at"
88792
89129
  ]);
88793
89130
  ensureNoExtraPositionals(parsedArgv, 2);
@@ -88803,7 +89140,7 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88803
89140
  if (actionValue === void 0) {
88804
89141
  throw new CliInputError("Missing required option --action.");
88805
89142
  }
88806
- if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop") {
89143
+ if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop" && actionValue !== "threshold" && actionValue !== "allow") {
88807
89144
  throw new CliInputError("Invalid value for --action.");
88808
89145
  }
88809
89146
  const matcher = readJsonOption(parsedArgv, "matcher-json");
@@ -88821,6 +89158,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88821
89158
  matcher,
88822
89159
  sample_rate: null,
88823
89160
  sample_event_class: null,
89161
+ threshold_count: null,
89162
+ threshold_window_seconds: null,
89163
+ threshold_group_by: null,
88824
89164
  created_by_user_id: null,
88825
89165
  created_from_incident_id: null,
88826
89166
  created_from_event_id: null,
@@ -88841,6 +89181,29 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88841
89181
  }
88842
89182
  create.sample_event_class = sampleEventClass;
88843
89183
  }
89184
+ const thresholdCount = readStringOption(parsedArgv, "threshold-count");
89185
+ if (thresholdCount !== void 0) {
89186
+ const parsed = Number(thresholdCount);
89187
+ if (!Number.isInteger(parsed)) {
89188
+ throw new CliInputError("Invalid value for --threshold-count.");
89189
+ }
89190
+ create.threshold_count = parsed;
89191
+ }
89192
+ const thresholdWindowSeconds = readStringOption(parsedArgv, "threshold-window-seconds");
89193
+ if (thresholdWindowSeconds !== void 0) {
89194
+ const parsed = Number(thresholdWindowSeconds);
89195
+ if (!Number.isInteger(parsed)) {
89196
+ throw new CliInputError("Invalid value for --threshold-window-seconds.");
89197
+ }
89198
+ create.threshold_window_seconds = parsed;
89199
+ }
89200
+ const thresholdGroupBy = readStringOption(parsedArgv, "threshold-group-by");
89201
+ if (thresholdGroupBy !== void 0) {
89202
+ if (thresholdGroupBy !== "resource" && thresholdGroupBy !== "fingerprint") {
89203
+ throw new CliInputError("Invalid value for --threshold-group-by.");
89204
+ }
89205
+ create.threshold_group_by = thresholdGroupBy;
89206
+ }
88844
89207
  return await (dependencies.createCaptureRuleCommand ?? createCaptureRuleWithAuthCommand)(
88845
89208
  appendCommonAuthOptions(parsedArgv, { projectId, create })
88846
89209
  );
@@ -88857,6 +89220,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88857
89220
  "matcher-json",
88858
89221
  "sample-rate",
88859
89222
  "sample-event-class",
89223
+ "threshold-count",
89224
+ "threshold-window-seconds",
89225
+ "threshold-group-by",
88860
89226
  "expires-at",
88861
89227
  "project-scope"
88862
89228
  ]);
@@ -88886,7 +89252,7 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88886
89252
  }
88887
89253
  const actionValue = readStringOption(parsedArgv, "action");
88888
89254
  if (actionValue !== void 0) {
88889
- if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop") {
89255
+ if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop" && actionValue !== "threshold" && actionValue !== "allow") {
88890
89256
  throw new CliInputError("Invalid value for --action.");
88891
89257
  }
88892
89258
  update["action"] = actionValue;
@@ -88913,6 +89279,29 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88913
89279
  }
88914
89280
  update["sample_event_class"] = sampleEventClass;
88915
89281
  }
89282
+ const thresholdCount = readStringOption(parsedArgv, "threshold-count");
89283
+ if (thresholdCount !== void 0) {
89284
+ const parsed = Number(thresholdCount);
89285
+ if (!Number.isInteger(parsed)) {
89286
+ throw new CliInputError("Invalid value for --threshold-count.");
89287
+ }
89288
+ update["threshold_count"] = parsed;
89289
+ }
89290
+ const thresholdWindowSeconds = readStringOption(parsedArgv, "threshold-window-seconds");
89291
+ if (thresholdWindowSeconds !== void 0) {
89292
+ const parsed = Number(thresholdWindowSeconds);
89293
+ if (!Number.isInteger(parsed)) {
89294
+ throw new CliInputError("Invalid value for --threshold-window-seconds.");
89295
+ }
89296
+ update["threshold_window_seconds"] = parsed;
89297
+ }
89298
+ const thresholdGroupBy = readStringOption(parsedArgv, "threshold-group-by");
89299
+ if (thresholdGroupBy !== void 0) {
89300
+ if (thresholdGroupBy !== "resource" && thresholdGroupBy !== "fingerprint") {
89301
+ throw new CliInputError("Invalid value for --threshold-group-by.");
89302
+ }
89303
+ update["threshold_group_by"] = thresholdGroupBy;
89304
+ }
88916
89305
  const expiresAt = readStringOption(parsedArgv, "expires-at");
88917
89306
  if (expiresAt !== void 0) {
88918
89307
  update["expires_at"] = expiresAt === "null" ? null : expiresAt;
@@ -90715,7 +91104,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
90715
91104
  // package.json
90716
91105
  var package_default = {
90717
91106
  name: "@debugbundle/cli",
90718
- version: "1.29.0",
91107
+ version: "1.30.0",
90719
91108
  private: false,
90720
91109
  description: "Command-line interface for DebugBundle",
90721
91110
  license: "Apache-2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@debugbundle/cli",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "private": false,
5
5
  "description": "Command-line interface for DebugBundle",
6
6
  "license": "Apache-2.0",