@debugbundle/cli 1.8.1 → 1.9.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.
- package/dist/main.cjs +637 -435
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -39659,17 +39659,17 @@ var require_dns = __commonJS({
|
|
|
39659
39659
|
const timestamp = Date.now();
|
|
39660
39660
|
const records = { records: { 4: null, 6: null } };
|
|
39661
39661
|
let minTTL = this.#maxTTL;
|
|
39662
|
-
for (const
|
|
39663
|
-
|
|
39664
|
-
if (typeof
|
|
39665
|
-
|
|
39666
|
-
minTTL = Math.min(minTTL,
|
|
39662
|
+
for (const record2 of addresses) {
|
|
39663
|
+
record2.timestamp = timestamp;
|
|
39664
|
+
if (typeof record2.ttl === "number") {
|
|
39665
|
+
record2.ttl = Math.min(record2.ttl, this.#maxTTL);
|
|
39666
|
+
minTTL = Math.min(minTTL, record2.ttl);
|
|
39667
39667
|
} else {
|
|
39668
|
-
|
|
39668
|
+
record2.ttl = this.#maxTTL;
|
|
39669
39669
|
}
|
|
39670
|
-
const familyRecords = records.records[
|
|
39671
|
-
familyRecords.ips.push(
|
|
39672
|
-
records.records[
|
|
39670
|
+
const familyRecords = records.records[record2.family] ?? { ips: [] };
|
|
39671
|
+
familyRecords.ips.push(record2);
|
|
39672
|
+
records.records[record2.family] = familyRecords;
|
|
39673
39673
|
}
|
|
39674
39674
|
this.storage.set(origin.hostname, records, { ttl: minTTL });
|
|
39675
39675
|
}
|
|
@@ -55119,15 +55119,15 @@ var require_util7 = __commonJS({
|
|
|
55119
55119
|
exports2.getUniqueHostnamesFromOptions = getUniqueHostnamesFromOptions;
|
|
55120
55120
|
function groupSrvRecords(records) {
|
|
55121
55121
|
const recordsByPriority = {};
|
|
55122
|
-
for (const
|
|
55123
|
-
if (!recordsByPriority.hasOwnProperty(
|
|
55124
|
-
recordsByPriority[
|
|
55125
|
-
totalWeight:
|
|
55126
|
-
records: [
|
|
55122
|
+
for (const record2 of records) {
|
|
55123
|
+
if (!recordsByPriority.hasOwnProperty(record2.priority)) {
|
|
55124
|
+
recordsByPriority[record2.priority] = {
|
|
55125
|
+
totalWeight: record2.weight,
|
|
55126
|
+
records: [record2]
|
|
55127
55127
|
};
|
|
55128
55128
|
} else {
|
|
55129
|
-
recordsByPriority[
|
|
55130
|
-
recordsByPriority[
|
|
55129
|
+
recordsByPriority[record2.priority].totalWeight += record2.weight;
|
|
55130
|
+
recordsByPriority[record2.priority].records.push(record2);
|
|
55131
55131
|
}
|
|
55132
55132
|
}
|
|
55133
55133
|
return recordsByPriority;
|
|
@@ -55140,12 +55140,12 @@ var require_util7 = __commonJS({
|
|
|
55140
55140
|
}
|
|
55141
55141
|
const random = Math.floor(Math.random() * (recordsGroup.totalWeight + recordsGroup.records.length));
|
|
55142
55142
|
let total = 0;
|
|
55143
|
-
for (const [i,
|
|
55144
|
-
total += 1 +
|
|
55143
|
+
for (const [i, record2] of recordsGroup.records.entries()) {
|
|
55144
|
+
total += 1 + record2.weight;
|
|
55145
55145
|
if (total > random) {
|
|
55146
|
-
recordsGroup.totalWeight -=
|
|
55146
|
+
recordsGroup.totalWeight -= record2.weight;
|
|
55147
55147
|
recordsGroup.records.splice(i, 1);
|
|
55148
|
-
return
|
|
55148
|
+
return record2;
|
|
55149
55149
|
}
|
|
55150
55150
|
}
|
|
55151
55151
|
}
|
|
@@ -57067,13 +57067,13 @@ var require_cluster = __commonJS({
|
|
|
57067
57067
|
if (!sortedKeys.length) {
|
|
57068
57068
|
return reject(err2);
|
|
57069
57069
|
}
|
|
57070
|
-
const key = sortedKeys[0], group = groupedRecords[key],
|
|
57070
|
+
const key = sortedKeys[0], group = groupedRecords[key], record2 = (0, util_1.weightSrvRecords)(group);
|
|
57071
57071
|
if (!group.records.length) {
|
|
57072
57072
|
sortedKeys.shift();
|
|
57073
57073
|
}
|
|
57074
|
-
self.dnsLookup(
|
|
57074
|
+
self.dnsLookup(record2.name).then((host) => resolve2({
|
|
57075
57075
|
host,
|
|
57076
|
-
port:
|
|
57076
|
+
port: record2.port
|
|
57077
57077
|
}), tryFirstOne);
|
|
57078
57078
|
}
|
|
57079
57079
|
tryFirstOne();
|
|
@@ -63786,6 +63786,73 @@ function createEventEnvelope(input3) {
|
|
|
63786
63786
|
return EventEnvelopeSchema.parse(candidate);
|
|
63787
63787
|
}
|
|
63788
63788
|
|
|
63789
|
+
// ../../packages/shared-types/src/browser-resource-routes.ts
|
|
63790
|
+
var BrowserResourceRoutesSchema = external_exports.object({
|
|
63791
|
+
items: external_exports.array(external_exports.object({ route: external_exports.string().max(1024), occurrences: external_exports.number().int().positive() })).max(20),
|
|
63792
|
+
recorded_occurrences: external_exports.number().int().nonnegative(),
|
|
63793
|
+
unattributed_occurrences: external_exports.number().int().nonnegative(),
|
|
63794
|
+
omitted_routes: external_exports.number().int().nonnegative(),
|
|
63795
|
+
coverage: external_exports.enum(["occurrence_metadata", "retained_samples"])
|
|
63796
|
+
});
|
|
63797
|
+
function normalizeResourceRoute(value) {
|
|
63798
|
+
if (typeof value !== "string" || !value.startsWith("/") || value.startsWith("//") || value.length > 4096)
|
|
63799
|
+
return null;
|
|
63800
|
+
const path = value.split(/[?#]/, 1)[0];
|
|
63801
|
+
if (/[\u0000-\u0020\u007f\\]/.test(path)) return null;
|
|
63802
|
+
const segments = path.split("/").filter(Boolean).map((segment) => {
|
|
63803
|
+
let decoded;
|
|
63804
|
+
try {
|
|
63805
|
+
decoded = decodeURIComponent(segment);
|
|
63806
|
+
} catch {
|
|
63807
|
+
return "{param}";
|
|
63808
|
+
}
|
|
63809
|
+
if (decoded === "{param}" || /^:[A-Za-z_][A-Za-z_0-9]*$/.test(decoded)) return "{param}";
|
|
63810
|
+
return /^\d+$/.test(decoded) || /^[a-f0-9-]{16,}$/i.test(decoded) || /^[A-Za-z0-9_-]{24,}$/.test(decoded) || decoded.length >= 16 && /[A-Za-z]/.test(decoded) && /\d/.test(decoded) || /[@/\\\u0000-\u0020\u007f]/.test(decoded) ? "{param}" : segment;
|
|
63811
|
+
});
|
|
63812
|
+
const route = `/${segments.join("/")}`;
|
|
63813
|
+
return route.length <= 1024 ? route : null;
|
|
63814
|
+
}
|
|
63815
|
+
function summarizeResourceRoutes(routes, occurrenceCount) {
|
|
63816
|
+
const counts = /* @__PURE__ */ new Map();
|
|
63817
|
+
for (const raw of routes) {
|
|
63818
|
+
const route = normalizeResourceRoute(raw);
|
|
63819
|
+
if (route !== null) counts.set(route, (counts.get(route) ?? 0) + 1);
|
|
63820
|
+
}
|
|
63821
|
+
const items = [...counts].map(([route, occurrences]) => ({ route, occurrences })).sort(
|
|
63822
|
+
(a, b) => b.occurrences - a.occurrences || (a.route < b.route ? -1 : a.route > b.route ? 1 : 0)
|
|
63823
|
+
);
|
|
63824
|
+
const recorded = items.reduce((total, item) => total + item.occurrences, 0);
|
|
63825
|
+
return {
|
|
63826
|
+
items: items.slice(0, 20),
|
|
63827
|
+
recorded_occurrences: recorded,
|
|
63828
|
+
unattributed_occurrences: Math.max(0, occurrenceCount - recorded),
|
|
63829
|
+
omitted_routes: Math.max(0, items.length - 20),
|
|
63830
|
+
coverage: "retained_samples"
|
|
63831
|
+
};
|
|
63832
|
+
}
|
|
63833
|
+
|
|
63834
|
+
// ../../packages/shared-types/src/browser-resource-context.ts
|
|
63835
|
+
var BrowserResourceContextSchema = external_exports.object({
|
|
63836
|
+
version: external_exports.literal(1),
|
|
63837
|
+
host: external_exports.string().max(255).nullable(),
|
|
63838
|
+
path: external_exports.string().max(1024),
|
|
63839
|
+
type: external_exports.string().nullable(),
|
|
63840
|
+
first_party: external_exports.boolean().nullable(),
|
|
63841
|
+
role: external_exports.enum([
|
|
63842
|
+
"analytics",
|
|
63843
|
+
"advertising",
|
|
63844
|
+
"tag_manager",
|
|
63845
|
+
"authentication",
|
|
63846
|
+
"application_asset",
|
|
63847
|
+
"unknown"
|
|
63848
|
+
]),
|
|
63849
|
+
provider: external_exports.string().nullable(),
|
|
63850
|
+
title: external_exports.string(),
|
|
63851
|
+
optional_candidate: external_exports.boolean(),
|
|
63852
|
+
diagnosis: external_exports.string(),
|
|
63853
|
+
routes: BrowserResourceRoutesSchema
|
|
63854
|
+
});
|
|
63855
|
+
|
|
63789
63856
|
// ../../packages/shared-types/src/tier-capabilities.ts
|
|
63790
63857
|
var TIER_CAPABILITIES = {
|
|
63791
63858
|
free: {
|
|
@@ -64620,6 +64687,93 @@ var CaptureRulesFileSchema = external_exports.object({
|
|
|
64620
64687
|
rules: external_exports.array(CaptureRuleSchema)
|
|
64621
64688
|
});
|
|
64622
64689
|
|
|
64690
|
+
// ../../packages/shared-types/src/browser-resource.ts
|
|
64691
|
+
function record(value) {
|
|
64692
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
64693
|
+
}
|
|
64694
|
+
function httpUrl(value, base2) {
|
|
64695
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 4096 || /[\u0000-\u0020\u007f]/.test(value))
|
|
64696
|
+
return null;
|
|
64697
|
+
try {
|
|
64698
|
+
const url = base2 === void 0 ? new URL(value) : new URL(value, base2);
|
|
64699
|
+
return url.protocol === "http:" || url.protocol === "https:" ? url : null;
|
|
64700
|
+
} catch {
|
|
64701
|
+
return null;
|
|
64702
|
+
}
|
|
64703
|
+
}
|
|
64704
|
+
function browserResourceLocation(source, page) {
|
|
64705
|
+
if (typeof source !== "string") return null;
|
|
64706
|
+
const pageUrl = httpUrl(page);
|
|
64707
|
+
const url = httpUrl(source, pageUrl ?? void 0);
|
|
64708
|
+
if (url !== null) {
|
|
64709
|
+
if (url.pathname.length > 1024 || url.hostname.length > 255) return null;
|
|
64710
|
+
return {
|
|
64711
|
+
host: url.hostname.toLowerCase(),
|
|
64712
|
+
path: url.pathname || "/",
|
|
64713
|
+
first_party: pageUrl === null ? null : url.origin === pageUrl.origin
|
|
64714
|
+
};
|
|
64715
|
+
}
|
|
64716
|
+
if (source.startsWith("/") && !source.startsWith("//") && !source.includes("\\") && !/[\u0000-\u0020\u007f]/.test(source)) {
|
|
64717
|
+
const path = source.split(/[?#]/, 1)[0];
|
|
64718
|
+
if (path.length <= 1024) return { host: null, path, first_party: true };
|
|
64719
|
+
}
|
|
64720
|
+
return null;
|
|
64721
|
+
}
|
|
64722
|
+
function describeBrowserResource(value) {
|
|
64723
|
+
const event = record(value);
|
|
64724
|
+
if (event?.["kind"] !== "resource_error") return null;
|
|
64725
|
+
const target = record(event["target"]);
|
|
64726
|
+
const page = record(event["page"]);
|
|
64727
|
+
const location = browserResourceLocation(
|
|
64728
|
+
target?.["source_url"] ?? event["file_name"],
|
|
64729
|
+
page?.["url"]
|
|
64730
|
+
);
|
|
64731
|
+
if (location === null) return null;
|
|
64732
|
+
const tag2 = typeof target?.["tag_name"] === "string" ? target["tag_name"].toLowerCase() : null;
|
|
64733
|
+
const type = tag2 !== null && [
|
|
64734
|
+
"script",
|
|
64735
|
+
"link",
|
|
64736
|
+
"img",
|
|
64737
|
+
"audio",
|
|
64738
|
+
"video",
|
|
64739
|
+
"source",
|
|
64740
|
+
"iframe",
|
|
64741
|
+
"object",
|
|
64742
|
+
"embed",
|
|
64743
|
+
"input"
|
|
64744
|
+
].includes(tag2) ? tag2 : null;
|
|
64745
|
+
let role = location.first_party === true ? "application_asset" : "unknown";
|
|
64746
|
+
let provider = null;
|
|
64747
|
+
if (type === "script") {
|
|
64748
|
+
if (location.host === "www.googletagmanager.com" && location.path === "/gtm.js") {
|
|
64749
|
+
provider = "Google Tag Manager";
|
|
64750
|
+
role = "tag_manager";
|
|
64751
|
+
} else if (location.host === "connect.facebook.net" && /^\/[a-z]{2}_[A-Z]{2}\/fbevents\.js$/.test(location.path)) {
|
|
64752
|
+
provider = "Meta Pixel";
|
|
64753
|
+
role = "advertising";
|
|
64754
|
+
} else if (location.host === "www.clarity.ms" && /^\/tag\/[A-Za-z0-9]+$/.test(location.path)) {
|
|
64755
|
+
provider = "Microsoft Clarity";
|
|
64756
|
+
role = "analytics";
|
|
64757
|
+
} else if (location.host === "accounts.google.com" && location.path === "/gsi/client") {
|
|
64758
|
+
provider = "Google sign-in";
|
|
64759
|
+
role = "authentication";
|
|
64760
|
+
}
|
|
64761
|
+
}
|
|
64762
|
+
const file = location.path.split("/").filter(Boolean).at(-1) ?? location.path;
|
|
64763
|
+
const kind = type === "img" ? "Image" : type === "script" || /\.m?js$/i.test(file) ? "JavaScript asset" : "Resource";
|
|
64764
|
+
return {
|
|
64765
|
+
...location,
|
|
64766
|
+
type,
|
|
64767
|
+
role,
|
|
64768
|
+
provider,
|
|
64769
|
+
title: provider !== null ? `${provider} script failed to load` : `${kind} failed to load: ${file}${location.host === null ? "" : ` (${location.host})`}`,
|
|
64770
|
+
optional_candidate: event["opaque"] === true && location.first_party !== true && ["analytics", "advertising", "tag_manager"].includes(role)
|
|
64771
|
+
};
|
|
64772
|
+
}
|
|
64773
|
+
function browserResourceDiagnosis(resource) {
|
|
64774
|
+
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.";
|
|
64775
|
+
}
|
|
64776
|
+
|
|
64623
64777
|
// ../../packages/shared-types/src/capture-rule-evaluation.ts
|
|
64624
64778
|
var CaptureRuleEvaluationUrlSchema = external_exports.object({
|
|
64625
64779
|
host: external_exports.string().min(1).transform((value) => value.toLowerCase()).optional(),
|
|
@@ -64687,6 +64841,7 @@ var CaptureRuleSuggestionSchema = external_exports.object({
|
|
|
64687
64841
|
rule: CaptureRuleCreateSchema
|
|
64688
64842
|
});
|
|
64689
64843
|
var CaptureRuleSuggestionsResponseSchema = external_exports.object({
|
|
64844
|
+
access_mode: external_exports.enum(["manage", "preview"]).optional(),
|
|
64690
64845
|
suggestions: external_exports.array(CaptureRuleSuggestionSchema),
|
|
64691
64846
|
bundle_status: external_exports.enum(["ready", "pending", "failed"]).optional(),
|
|
64692
64847
|
bundle_reason: external_exports.string().nullable().optional()
|
|
@@ -65182,6 +65337,14 @@ function looksSensitiveCustomDimensionValue(value) {
|
|
|
65182
65337
|
return /https?:\/\//i.test(value) || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) || /\bBearer\s+[A-Za-z0-9._~+/=-]+/i.test(value) || /\b(?:token|password|secret|api_key)=/i.test(value);
|
|
65183
65338
|
}
|
|
65184
65339
|
|
|
65340
|
+
// ../../packages/shared-types/src/frontend-severity.ts
|
|
65341
|
+
function inferFrontendExceptionSeverity(event) {
|
|
65342
|
+
const browserEvent = event.payload.browser_event;
|
|
65343
|
+
if (browserEvent?.opaque === true)
|
|
65344
|
+
return browserEvent.kind === "resource_error" ? "medium" : "low";
|
|
65345
|
+
return "high";
|
|
65346
|
+
}
|
|
65347
|
+
|
|
65185
65348
|
// ../../packages/shared-types/src/analytics-product.ts
|
|
65186
65349
|
var AnalyticsOpportunityStatusValues = ["open", "resolved", "snoozed"];
|
|
65187
65350
|
var AnalyticsOpportunityStatusSchema = external_exports.enum(AnalyticsOpportunityStatusValues);
|
|
@@ -65756,6 +65919,7 @@ var ContextDeviceSchema = external_exports.object({
|
|
|
65756
65919
|
color_scheme_preference: external_exports.enum(["light", "dark", "no-preference"]).nullable()
|
|
65757
65920
|
});
|
|
65758
65921
|
var BundleContextSchema = external_exports.object({
|
|
65922
|
+
resource_failure: BrowserResourceContextSchema.optional(),
|
|
65759
65923
|
error: ContextErrorSchema.nullable().optional(),
|
|
65760
65924
|
request: ContextRequestSchema.nullable().optional(),
|
|
65761
65925
|
response: ContextResponseSchema.nullable().optional(),
|
|
@@ -84218,8 +84382,57 @@ var WINDOW_RETENTION_SECONDS = WINDOW_24H_SECONDS + WINDOW_1H_SECONDS;
|
|
|
84218
84382
|
// ../../packages/storage/src/ingestion-rate-limiter.ts
|
|
84219
84383
|
var import_ioredis3 = __toESM(require_built3(), 1);
|
|
84220
84384
|
|
|
84221
|
-
// ../../packages/event-normalizer/src/
|
|
84222
|
-
var
|
|
84385
|
+
// ../../packages/event-normalizer/src/fingerprints.ts
|
|
84386
|
+
var import_node_crypto4 = require("node:crypto");
|
|
84387
|
+
var FINGERPRINT_VERSION = "v2";
|
|
84388
|
+
var RESOURCE_FINGERPRINT_VERSION = "v3";
|
|
84389
|
+
function fingerprintVersion(event) {
|
|
84390
|
+
return event.resource_type != null ? RESOURCE_FINGERPRINT_VERSION : FINGERPRINT_VERSION;
|
|
84391
|
+
}
|
|
84392
|
+
function stableJson(value) {
|
|
84393
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
84394
|
+
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
|
|
84395
|
+
const object = value;
|
|
84396
|
+
return `{${Object.keys(object).sort().map((key) => `${JSON.stringify(key)}:${stableJson(object[key])}`).join(",")}}`;
|
|
84397
|
+
}
|
|
84398
|
+
function fingerprint(event) {
|
|
84399
|
+
const canonical = event.resource_type != null ? {
|
|
84400
|
+
// A concrete resource is the grouping unit, not proof of a common underlying cause.
|
|
84401
|
+
browser_event_kind: "resource_error",
|
|
84402
|
+
resource_host: event.resource_host,
|
|
84403
|
+
resource_path: event.resource_path,
|
|
84404
|
+
resource_type: event.resource_type,
|
|
84405
|
+
environment: event.environment,
|
|
84406
|
+
fingerprint_version: RESOURCE_FINGERPRINT_VERSION
|
|
84407
|
+
} : {
|
|
84408
|
+
// Preserve exact historical bytes for every non-resource event and explicit legacy normalization.
|
|
84409
|
+
error_type: event.error_type,
|
|
84410
|
+
normalized_message: event.normalized_message,
|
|
84411
|
+
top_frames: event.top_frames,
|
|
84412
|
+
route_template: event.route_template,
|
|
84413
|
+
browser_event_kind: event.browser_event_kind,
|
|
84414
|
+
resource_host: event.resource_host,
|
|
84415
|
+
resource_path: event.resource_path,
|
|
84416
|
+
http_method: event.http_method,
|
|
84417
|
+
http_status: event.http_status,
|
|
84418
|
+
environment: event.environment
|
|
84419
|
+
};
|
|
84420
|
+
return (0, import_node_crypto4.createHash)("sha256").update(stableJson(canonical)).digest("hex");
|
|
84421
|
+
}
|
|
84422
|
+
function inferMatchedFields(event) {
|
|
84423
|
+
if (event.resource_type != null)
|
|
84424
|
+
return ["environment", "browser_event_kind", "resource_host", "resource_path", "resource_type"];
|
|
84425
|
+
const fields = ["environment", "normalized_message"];
|
|
84426
|
+
if (event.error_type !== null) fields.push("error_type");
|
|
84427
|
+
if (event.route_template !== null) fields.push("route_template");
|
|
84428
|
+
if (event.top_frames.length > 0) fields.push("top_frames");
|
|
84429
|
+
if (event.browser_event_kind != null) fields.push("browser_event_kind");
|
|
84430
|
+
if (event.resource_host != null) fields.push("resource_host");
|
|
84431
|
+
if (event.resource_path != null) fields.push("resource_path");
|
|
84432
|
+
if (event.http_method !== null) fields.push("http_method");
|
|
84433
|
+
if (event.http_status !== null) fields.push("http_status");
|
|
84434
|
+
return fields;
|
|
84435
|
+
}
|
|
84223
84436
|
|
|
84224
84437
|
// ../../packages/redaction/src/index.ts
|
|
84225
84438
|
var DEFAULT_SENSITIVE_KEYS = [
|
|
@@ -84318,7 +84531,7 @@ function redact(payload2, options) {
|
|
|
84318
84531
|
}
|
|
84319
84532
|
|
|
84320
84533
|
// ../../packages/event-normalizer/src/mobile-event-compatibility.ts
|
|
84321
|
-
var
|
|
84534
|
+
var import_node_crypto5 = require("node:crypto");
|
|
84322
84535
|
var MOBILE_SDKS = /* @__PURE__ */ new Set(["@debugbundle/sdk-android", "@debugbundle/sdk-swift"]);
|
|
84323
84536
|
function isRecord3(candidate) {
|
|
84324
84537
|
return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
|
|
@@ -84345,8 +84558,8 @@ function readInteger(candidate) {
|
|
|
84345
84558
|
function readBoolean2(candidate) {
|
|
84346
84559
|
return typeof candidate === "boolean" ? candidate : null;
|
|
84347
84560
|
}
|
|
84348
|
-
function readField(
|
|
84349
|
-
return
|
|
84561
|
+
function readField(record2, snakeCase, camelCase) {
|
|
84562
|
+
return record2[snakeCase] ?? record2[camelCase];
|
|
84350
84563
|
}
|
|
84351
84564
|
function stableValue(candidate) {
|
|
84352
84565
|
if (Array.isArray(candidate)) {
|
|
@@ -84360,7 +84573,7 @@ function stableValue(candidate) {
|
|
|
84360
84573
|
);
|
|
84361
84574
|
}
|
|
84362
84575
|
function deterministicEventId(candidate) {
|
|
84363
|
-
const digest2 = (0,
|
|
84576
|
+
const digest2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify(stableValue(candidate))).digest("hex");
|
|
84364
84577
|
const chars = digest2.slice(0, 32).split("");
|
|
84365
84578
|
chars[12] = "5";
|
|
84366
84579
|
chars[16] = ["8", "9", "a", "b"][Number.parseInt(chars[16] ?? "0", 16) % 4] ?? "8";
|
|
@@ -84726,7 +84939,6 @@ function normalizeJavaTimerMessage(message3) {
|
|
|
84726
84939
|
}
|
|
84727
84940
|
|
|
84728
84941
|
// ../../packages/event-normalizer/src/index.ts
|
|
84729
|
-
var FINGERPRINT_VERSION = "v2";
|
|
84730
84942
|
var PAYLOAD_ALLOWED_KEYS = {
|
|
84731
84943
|
backend_exception: /* @__PURE__ */ new Set([
|
|
84732
84944
|
"name",
|
|
@@ -84909,34 +85121,6 @@ function normalizeCompatibleEventCandidate(candidate) {
|
|
|
84909
85121
|
}
|
|
84910
85122
|
return event;
|
|
84911
85123
|
}
|
|
84912
|
-
function inferMatchedFields(event) {
|
|
84913
|
-
const matchedFields = ["environment", "normalized_message"];
|
|
84914
|
-
if (event.error_type !== null) {
|
|
84915
|
-
matchedFields.push("error_type");
|
|
84916
|
-
}
|
|
84917
|
-
if (event.route_template !== null) {
|
|
84918
|
-
matchedFields.push("route_template");
|
|
84919
|
-
}
|
|
84920
|
-
if (event.top_frames.length > 0) {
|
|
84921
|
-
matchedFields.push("top_frames");
|
|
84922
|
-
}
|
|
84923
|
-
if (event.browser_event_kind != null) {
|
|
84924
|
-
matchedFields.push("browser_event_kind");
|
|
84925
|
-
}
|
|
84926
|
-
if (event.resource_host != null) {
|
|
84927
|
-
matchedFields.push("resource_host");
|
|
84928
|
-
}
|
|
84929
|
-
if (event.resource_path != null) {
|
|
84930
|
-
matchedFields.push("resource_path");
|
|
84931
|
-
}
|
|
84932
|
-
if (event.http_method !== null) {
|
|
84933
|
-
matchedFields.push("http_method");
|
|
84934
|
-
}
|
|
84935
|
-
if (event.http_status !== null) {
|
|
84936
|
-
matchedFields.push("http_status");
|
|
84937
|
-
}
|
|
84938
|
-
return matchedFields;
|
|
84939
|
-
}
|
|
84940
85124
|
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi;
|
|
84941
85125
|
var EMAIL_PATTERN = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
84942
85126
|
var ISO_TIMESTAMP_PATTERN = /\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z\b/g;
|
|
@@ -85140,22 +85324,10 @@ function normalizeResourceIdentity(value) {
|
|
|
85140
85324
|
};
|
|
85141
85325
|
}
|
|
85142
85326
|
}
|
|
85143
|
-
function stableJson(value) {
|
|
85144
|
-
if (value === null || typeof value !== "object") {
|
|
85145
|
-
return JSON.stringify(value);
|
|
85146
|
-
}
|
|
85147
|
-
if (Array.isArray(value)) {
|
|
85148
|
-
return `[${value.map((entry) => stableJson(entry)).join(",")}]`;
|
|
85149
|
-
}
|
|
85150
|
-
const record = value;
|
|
85151
|
-
const keys2 = Object.keys(record).sort();
|
|
85152
|
-
const pairs = keys2.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`);
|
|
85153
|
-
return `{${pairs.join(",")}}`;
|
|
85154
|
-
}
|
|
85155
85327
|
function validateEvent(candidate) {
|
|
85156
85328
|
return EventEnvelopeSchema.safeParse(normalizeCompatibleEventCandidate(candidate));
|
|
85157
85329
|
}
|
|
85158
|
-
function normalizeEvent(event, version2 =
|
|
85330
|
+
function normalizeEvent(event, version2 = RESOURCE_FINGERPRINT_VERSION) {
|
|
85159
85331
|
const redactedPayload = redact(event.payload).redacted;
|
|
85160
85332
|
if (event.event_type === "backend_exception") {
|
|
85161
85333
|
return {
|
|
@@ -85209,6 +85381,8 @@ function normalizeEvent(event, version2 = FINGERPRINT_VERSION) {
|
|
|
85209
85381
|
const browserEvent = event.payload.browser_event;
|
|
85210
85382
|
const resourceIdentity = browserEvent?.kind === "resource_error" ? normalizeResourceIdentity(browserEvent.target?.source_url ?? browserEvent.file_name) : { host: null, path: null };
|
|
85211
85383
|
const topFrames = browserEvent?.opaque === true ? [] : selectTopFrames(event.payload.stack);
|
|
85384
|
+
const resource = describeBrowserResource(browserEvent);
|
|
85385
|
+
const concreteResource = version2 === RESOURCE_FINGERPRINT_VERSION && browserEvent?.opaque === true && resource?.host != null && resource.type !== null;
|
|
85212
85386
|
return {
|
|
85213
85387
|
event_type: event.event_type,
|
|
85214
85388
|
environment: event.service.environment,
|
|
@@ -85219,8 +85393,10 @@ function normalizeEvent(event, version2 = FINGERPRINT_VERSION) {
|
|
|
85219
85393
|
http_status: null,
|
|
85220
85394
|
top_frames: topFrames,
|
|
85221
85395
|
browser_event_kind: browserEvent?.kind ?? null,
|
|
85222
|
-
resource_host: resourceIdentity.host,
|
|
85223
|
-
resource_path: resourceIdentity.path,
|
|
85396
|
+
resource_host: concreteResource ? resource.host : resourceIdentity.host,
|
|
85397
|
+
resource_path: concreteResource ? resource.path : resourceIdentity.path,
|
|
85398
|
+
...concreteResource ? { resource_type: resource.type } : {},
|
|
85399
|
+
...resource === null ? {} : { incident_title: resource.title },
|
|
85224
85400
|
payload: redactedPayload
|
|
85225
85401
|
};
|
|
85226
85402
|
}
|
|
@@ -85239,21 +85415,6 @@ function normalizeEvent(event, version2 = FINGERPRINT_VERSION) {
|
|
|
85239
85415
|
payload: redactedPayload
|
|
85240
85416
|
};
|
|
85241
85417
|
}
|
|
85242
|
-
function fingerprint(event) {
|
|
85243
|
-
const canonical = {
|
|
85244
|
-
error_type: event.error_type,
|
|
85245
|
-
normalized_message: event.normalized_message,
|
|
85246
|
-
top_frames: event.top_frames,
|
|
85247
|
-
route_template: event.route_template,
|
|
85248
|
-
browser_event_kind: event.browser_event_kind,
|
|
85249
|
-
resource_host: event.resource_host,
|
|
85250
|
-
resource_path: event.resource_path,
|
|
85251
|
-
http_method: event.http_method,
|
|
85252
|
-
http_status: event.http_status,
|
|
85253
|
-
environment: event.environment
|
|
85254
|
-
};
|
|
85255
|
-
return (0, import_node_crypto5.createHash)("sha256").update(stableJson(canonical)).digest("hex");
|
|
85256
|
-
}
|
|
85257
85418
|
var INCIDENT_LOG_LEVELS = /* @__PURE__ */ new Set(["error", "fatal", "critical"]);
|
|
85258
85419
|
function getRequestResponseStatus(payload2) {
|
|
85259
85420
|
const status = payload2?.["response_status"];
|
|
@@ -86080,6 +86241,192 @@ var OPENAI_OAUTH_BOOTSTRAP_STATEMENTS = [
|
|
|
86080
86241
|
`CREATE INDEX oauth_provider_artifacts_expires_idx ON oauth_provider_artifacts (expires_at, model, provider_id_hash)`
|
|
86081
86242
|
];
|
|
86082
86243
|
|
|
86244
|
+
// ../../packages/storage/src/storage-bootstrap-incident-statements.ts
|
|
86245
|
+
var STORAGE_BOOTSTRAP_INCIDENT_STATEMENTS = [
|
|
86246
|
+
`
|
|
86247
|
+
CREATE TABLE incidents (
|
|
86248
|
+
id uuid PRIMARY KEY,
|
|
86249
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86250
|
+
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86251
|
+
environment text NOT NULL DEFAULT 'production',
|
|
86252
|
+
fingerprint text NOT NULL,
|
|
86253
|
+
fingerprint_version text NOT NULL DEFAULT 'v1',
|
|
86254
|
+
title text NOT NULL,
|
|
86255
|
+
severity text NOT NULL,
|
|
86256
|
+
status text NOT NULL DEFAULT 'open',
|
|
86257
|
+
first_seen_at timestamptz NOT NULL,
|
|
86258
|
+
last_seen_at timestamptz NOT NULL,
|
|
86259
|
+
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86260
|
+
matched_fields text[],
|
|
86261
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86262
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86263
|
+
regressed_at timestamptz,
|
|
86264
|
+
spike_detected_at timestamptz,
|
|
86265
|
+
frequency_occurrences_1m integer,
|
|
86266
|
+
frequency_occurrences_5m integer,
|
|
86267
|
+
frequency_occurrences_1h integer,
|
|
86268
|
+
frequency_occurrences_24h integer,
|
|
86269
|
+
frequency_baseline_1h_per_5m double precision,
|
|
86270
|
+
frequency_spike_ratio_5m_to_1h double precision,
|
|
86271
|
+
frequency_has_sufficient_baseline boolean,
|
|
86272
|
+
frequency_is_spiking boolean,
|
|
86273
|
+
frequency_snapshot_at timestamptz,
|
|
86274
|
+
latest_deployment_id uuid REFERENCES deployments(id) ON DELETE SET NULL,
|
|
86275
|
+
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86276
|
+
bundle_created_at timestamptz,
|
|
86277
|
+
bundle_updated_at timestamptz,
|
|
86278
|
+
bundle_source_event_id uuid,
|
|
86279
|
+
bundle_source_occurred_at timestamptz,
|
|
86280
|
+
bundle_trigger text,
|
|
86281
|
+
bundle_failure_reason text,
|
|
86282
|
+
resolved_at timestamptz,
|
|
86283
|
+
resolved_by_member_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86284
|
+
UNIQUE (project_id, environment, service_id, fingerprint)
|
|
86285
|
+
)
|
|
86286
|
+
`,
|
|
86287
|
+
`
|
|
86288
|
+
CREATE TABLE processed_events (
|
|
86289
|
+
event_id uuid PRIMARY KEY,
|
|
86290
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86291
|
+
event_type text NOT NULL,
|
|
86292
|
+
fingerprint text NOT NULL,
|
|
86293
|
+
normalized_message text NOT NULL,
|
|
86294
|
+
processed_at timestamptz NOT NULL DEFAULT now()
|
|
86295
|
+
)
|
|
86296
|
+
`,
|
|
86297
|
+
`
|
|
86298
|
+
CREATE TABLE improvement_opportunities (
|
|
86299
|
+
id uuid PRIMARY KEY,
|
|
86300
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86301
|
+
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86302
|
+
service_name text NOT NULL,
|
|
86303
|
+
environment text NOT NULL DEFAULT 'production',
|
|
86304
|
+
kind text NOT NULL,
|
|
86305
|
+
status text NOT NULL DEFAULT 'open',
|
|
86306
|
+
severity text NOT NULL,
|
|
86307
|
+
confidence numeric NOT NULL,
|
|
86308
|
+
fingerprint text NOT NULL,
|
|
86309
|
+
title text NOT NULL,
|
|
86310
|
+
summary text NOT NULL,
|
|
86311
|
+
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86312
|
+
evidence jsonb NOT NULL,
|
|
86313
|
+
first_detected_at timestamptz NOT NULL,
|
|
86314
|
+
last_detected_at timestamptz NOT NULL,
|
|
86315
|
+
last_source_event_id uuid,
|
|
86316
|
+
related_incident_ids uuid[] NOT NULL DEFAULT '{}',
|
|
86317
|
+
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86318
|
+
bundle_created_at timestamptz,
|
|
86319
|
+
bundle_updated_at timestamptz,
|
|
86320
|
+
bundle_source_event_id uuid,
|
|
86321
|
+
bundle_failure_reason text,
|
|
86322
|
+
resolved_at timestamptz,
|
|
86323
|
+
resolved_by_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86324
|
+
snoozed_until timestamptz,
|
|
86325
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86326
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86327
|
+
UNIQUE (project_id, fingerprint)
|
|
86328
|
+
)
|
|
86329
|
+
`,
|
|
86330
|
+
`
|
|
86331
|
+
CREATE INDEX improvement_opportunities_project_status_detected_idx
|
|
86332
|
+
ON improvement_opportunities (project_id, status, last_detected_at DESC)
|
|
86333
|
+
`,
|
|
86334
|
+
`
|
|
86335
|
+
CREATE INDEX improvement_opportunities_project_kind_detected_idx
|
|
86336
|
+
ON improvement_opportunities (project_id, kind, last_detected_at DESC)
|
|
86337
|
+
`,
|
|
86338
|
+
`
|
|
86339
|
+
CREATE INDEX improvement_opportunities_project_service_env_idx
|
|
86340
|
+
ON improvement_opportunities (project_id, service_id, environment)
|
|
86341
|
+
`,
|
|
86342
|
+
`
|
|
86343
|
+
CREATE TABLE improvement_opportunity_events (
|
|
86344
|
+
improvement_opportunity_id uuid NOT NULL REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86345
|
+
event_id uuid NOT NULL,
|
|
86346
|
+
event_type text NOT NULL,
|
|
86347
|
+
occurred_at timestamptz NOT NULL,
|
|
86348
|
+
PRIMARY KEY (improvement_opportunity_id, event_id)
|
|
86349
|
+
)
|
|
86350
|
+
`,
|
|
86351
|
+
`
|
|
86352
|
+
CREATE INDEX improvement_opportunity_events_detected_idx
|
|
86353
|
+
ON improvement_opportunity_events (improvement_opportunity_id, occurred_at DESC, event_id DESC)
|
|
86354
|
+
`,
|
|
86355
|
+
`
|
|
86356
|
+
CREATE TABLE bundle_generations (
|
|
86357
|
+
id uuid PRIMARY KEY,
|
|
86358
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86359
|
+
incident_id uuid REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86360
|
+
improvement_opportunity_id uuid REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86361
|
+
bundle_type text NOT NULL,
|
|
86362
|
+
generation_number integer NOT NULL,
|
|
86363
|
+
source_event_id uuid NOT NULL,
|
|
86364
|
+
source_occurred_at timestamptz NOT NULL,
|
|
86365
|
+
trigger text NOT NULL,
|
|
86366
|
+
created_at timestamptz NOT NULL,
|
|
86367
|
+
updated_at timestamptz NOT NULL,
|
|
86368
|
+
CHECK (
|
|
86369
|
+
(incident_id IS NOT NULL AND improvement_opportunity_id IS NULL AND bundle_type = 'failure')
|
|
86370
|
+
OR (incident_id IS NULL AND improvement_opportunity_id IS NOT NULL AND bundle_type = 'improvement')
|
|
86371
|
+
)
|
|
86372
|
+
)
|
|
86373
|
+
`,
|
|
86374
|
+
`
|
|
86375
|
+
CREATE UNIQUE INDEX bundle_generations_incident_source_idx
|
|
86376
|
+
ON bundle_generations (incident_id, source_event_id)
|
|
86377
|
+
WHERE incident_id IS NOT NULL
|
|
86378
|
+
`,
|
|
86379
|
+
`
|
|
86380
|
+
CREATE UNIQUE INDEX bundle_generations_improvement_source_idx
|
|
86381
|
+
ON bundle_generations (improvement_opportunity_id, source_event_id)
|
|
86382
|
+
WHERE improvement_opportunity_id IS NOT NULL
|
|
86383
|
+
`,
|
|
86384
|
+
`
|
|
86385
|
+
CREATE INDEX bundle_generations_project_created_idx
|
|
86386
|
+
ON bundle_generations (project_id, created_at DESC, bundle_type)
|
|
86387
|
+
`,
|
|
86388
|
+
`
|
|
86389
|
+
CREATE INDEX bundle_generations_incident_generation_idx
|
|
86390
|
+
ON bundle_generations (incident_id, generation_number DESC)
|
|
86391
|
+
`,
|
|
86392
|
+
`
|
|
86393
|
+
CREATE INDEX bundle_generations_improvement_generation_idx
|
|
86394
|
+
ON bundle_generations (improvement_opportunity_id, generation_number DESC)
|
|
86395
|
+
WHERE improvement_opportunity_id IS NOT NULL
|
|
86396
|
+
`,
|
|
86397
|
+
`
|
|
86398
|
+
CREATE TABLE incident_events (
|
|
86399
|
+
incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86400
|
+
event_id uuid NOT NULL,
|
|
86401
|
+
event_type text NOT NULL,
|
|
86402
|
+
event_class text NOT NULL DEFAULT 'context_signal',
|
|
86403
|
+
occurred_at timestamptz NOT NULL,
|
|
86404
|
+
is_sampled boolean NOT NULL DEFAULT false,
|
|
86405
|
+
level text,
|
|
86406
|
+
resource_route text,
|
|
86407
|
+
retain_first boolean NOT NULL DEFAULT false,
|
|
86408
|
+
retain_latest boolean NOT NULL DEFAULT false,
|
|
86409
|
+
retain_after_deploy boolean NOT NULL DEFAULT false,
|
|
86410
|
+
retain_highest_severity boolean NOT NULL DEFAULT false,
|
|
86411
|
+
retain_deploy_metadata boolean NOT NULL DEFAULT false,
|
|
86412
|
+
severity_rank integer NOT NULL DEFAULT 0,
|
|
86413
|
+
PRIMARY KEY (incident_id, event_id)
|
|
86414
|
+
)
|
|
86415
|
+
`,
|
|
86416
|
+
`
|
|
86417
|
+
CREATE INDEX incident_events_incident_occurred_event_idx
|
|
86418
|
+
ON incident_events (incident_id, occurred_at DESC, event_id DESC)
|
|
86419
|
+
`,
|
|
86420
|
+
`
|
|
86421
|
+
CREATE INDEX incident_events_incident_level_occurred_event_idx
|
|
86422
|
+
ON incident_events (incident_id, level, occurred_at DESC, event_id DESC)
|
|
86423
|
+
`,
|
|
86424
|
+
`
|
|
86425
|
+
CREATE INDEX incident_events_incident_sampled_idx
|
|
86426
|
+
ON incident_events (incident_id, is_sampled, occurred_at ASC, event_id ASC)
|
|
86427
|
+
`
|
|
86428
|
+
];
|
|
86429
|
+
|
|
86083
86430
|
// ../../packages/storage/src/storage-bootstrap-account-analytics-statements.ts
|
|
86084
86431
|
var STORAGE_BOOTSTRAP_ACCOUNT_ANALYTICS_STATEMENTS = [
|
|
86085
86432
|
`
|
|
@@ -86600,187 +86947,7 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
|
|
|
86600
86947
|
CREATE INDEX deployments_project_service_env_deployed_idx
|
|
86601
86948
|
ON deployments (project_id, service_id, environment, deployed_at DESC)
|
|
86602
86949
|
`,
|
|
86603
|
-
|
|
86604
|
-
CREATE TABLE incidents (
|
|
86605
|
-
id uuid PRIMARY KEY,
|
|
86606
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86607
|
-
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86608
|
-
environment text NOT NULL DEFAULT 'production',
|
|
86609
|
-
fingerprint text NOT NULL,
|
|
86610
|
-
fingerprint_version text NOT NULL DEFAULT 'v1',
|
|
86611
|
-
title text NOT NULL,
|
|
86612
|
-
severity text NOT NULL,
|
|
86613
|
-
status text NOT NULL DEFAULT 'open',
|
|
86614
|
-
first_seen_at timestamptz NOT NULL,
|
|
86615
|
-
last_seen_at timestamptz NOT NULL,
|
|
86616
|
-
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86617
|
-
matched_fields text[],
|
|
86618
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86619
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86620
|
-
regressed_at timestamptz,
|
|
86621
|
-
spike_detected_at timestamptz,
|
|
86622
|
-
frequency_occurrences_1m integer,
|
|
86623
|
-
frequency_occurrences_5m integer,
|
|
86624
|
-
frequency_occurrences_1h integer,
|
|
86625
|
-
frequency_occurrences_24h integer,
|
|
86626
|
-
frequency_baseline_1h_per_5m double precision,
|
|
86627
|
-
frequency_spike_ratio_5m_to_1h double precision,
|
|
86628
|
-
frequency_has_sufficient_baseline boolean,
|
|
86629
|
-
frequency_is_spiking boolean,
|
|
86630
|
-
frequency_snapshot_at timestamptz,
|
|
86631
|
-
latest_deployment_id uuid REFERENCES deployments(id) ON DELETE SET NULL,
|
|
86632
|
-
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86633
|
-
bundle_created_at timestamptz,
|
|
86634
|
-
bundle_updated_at timestamptz,
|
|
86635
|
-
bundle_source_event_id uuid,
|
|
86636
|
-
bundle_source_occurred_at timestamptz,
|
|
86637
|
-
bundle_trigger text,
|
|
86638
|
-
bundle_failure_reason text,
|
|
86639
|
-
resolved_at timestamptz,
|
|
86640
|
-
resolved_by_member_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86641
|
-
UNIQUE (project_id, environment, service_id, fingerprint)
|
|
86642
|
-
)
|
|
86643
|
-
`,
|
|
86644
|
-
`
|
|
86645
|
-
CREATE TABLE processed_events (
|
|
86646
|
-
event_id uuid PRIMARY KEY,
|
|
86647
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86648
|
-
event_type text NOT NULL,
|
|
86649
|
-
fingerprint text NOT NULL,
|
|
86650
|
-
normalized_message text NOT NULL,
|
|
86651
|
-
processed_at timestamptz NOT NULL DEFAULT now()
|
|
86652
|
-
)
|
|
86653
|
-
`,
|
|
86654
|
-
`
|
|
86655
|
-
CREATE TABLE improvement_opportunities (
|
|
86656
|
-
id uuid PRIMARY KEY,
|
|
86657
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86658
|
-
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86659
|
-
service_name text NOT NULL,
|
|
86660
|
-
environment text NOT NULL DEFAULT 'production',
|
|
86661
|
-
kind text NOT NULL,
|
|
86662
|
-
status text NOT NULL DEFAULT 'open',
|
|
86663
|
-
severity text NOT NULL,
|
|
86664
|
-
confidence numeric NOT NULL,
|
|
86665
|
-
fingerprint text NOT NULL,
|
|
86666
|
-
title text NOT NULL,
|
|
86667
|
-
summary text NOT NULL,
|
|
86668
|
-
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86669
|
-
evidence jsonb NOT NULL,
|
|
86670
|
-
first_detected_at timestamptz NOT NULL,
|
|
86671
|
-
last_detected_at timestamptz NOT NULL,
|
|
86672
|
-
last_source_event_id uuid,
|
|
86673
|
-
related_incident_ids uuid[] NOT NULL DEFAULT '{}',
|
|
86674
|
-
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86675
|
-
bundle_created_at timestamptz,
|
|
86676
|
-
bundle_updated_at timestamptz,
|
|
86677
|
-
bundle_source_event_id uuid,
|
|
86678
|
-
bundle_failure_reason text,
|
|
86679
|
-
resolved_at timestamptz,
|
|
86680
|
-
resolved_by_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86681
|
-
snoozed_until timestamptz,
|
|
86682
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86683
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86684
|
-
UNIQUE (project_id, fingerprint)
|
|
86685
|
-
)
|
|
86686
|
-
`,
|
|
86687
|
-
`
|
|
86688
|
-
CREATE INDEX improvement_opportunities_project_status_detected_idx
|
|
86689
|
-
ON improvement_opportunities (project_id, status, last_detected_at DESC)
|
|
86690
|
-
`,
|
|
86691
|
-
`
|
|
86692
|
-
CREATE INDEX improvement_opportunities_project_kind_detected_idx
|
|
86693
|
-
ON improvement_opportunities (project_id, kind, last_detected_at DESC)
|
|
86694
|
-
`,
|
|
86695
|
-
`
|
|
86696
|
-
CREATE INDEX improvement_opportunities_project_service_env_idx
|
|
86697
|
-
ON improvement_opportunities (project_id, service_id, environment)
|
|
86698
|
-
`,
|
|
86699
|
-
`
|
|
86700
|
-
CREATE TABLE improvement_opportunity_events (
|
|
86701
|
-
improvement_opportunity_id uuid NOT NULL REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86702
|
-
event_id uuid NOT NULL,
|
|
86703
|
-
event_type text NOT NULL,
|
|
86704
|
-
occurred_at timestamptz NOT NULL,
|
|
86705
|
-
PRIMARY KEY (improvement_opportunity_id, event_id)
|
|
86706
|
-
)
|
|
86707
|
-
`,
|
|
86708
|
-
`
|
|
86709
|
-
CREATE INDEX improvement_opportunity_events_detected_idx
|
|
86710
|
-
ON improvement_opportunity_events (improvement_opportunity_id, occurred_at DESC, event_id DESC)
|
|
86711
|
-
`,
|
|
86712
|
-
`
|
|
86713
|
-
CREATE TABLE bundle_generations (
|
|
86714
|
-
id uuid PRIMARY KEY,
|
|
86715
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86716
|
-
incident_id uuid REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86717
|
-
improvement_opportunity_id uuid REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86718
|
-
bundle_type text NOT NULL,
|
|
86719
|
-
generation_number integer NOT NULL,
|
|
86720
|
-
source_event_id uuid NOT NULL,
|
|
86721
|
-
source_occurred_at timestamptz NOT NULL,
|
|
86722
|
-
trigger text NOT NULL,
|
|
86723
|
-
created_at timestamptz NOT NULL,
|
|
86724
|
-
updated_at timestamptz NOT NULL,
|
|
86725
|
-
CHECK (
|
|
86726
|
-
(incident_id IS NOT NULL AND improvement_opportunity_id IS NULL AND bundle_type = 'failure')
|
|
86727
|
-
OR (incident_id IS NULL AND improvement_opportunity_id IS NOT NULL AND bundle_type = 'improvement')
|
|
86728
|
-
)
|
|
86729
|
-
)
|
|
86730
|
-
`,
|
|
86731
|
-
`
|
|
86732
|
-
CREATE UNIQUE INDEX bundle_generations_incident_source_idx
|
|
86733
|
-
ON bundle_generations (incident_id, source_event_id)
|
|
86734
|
-
WHERE incident_id IS NOT NULL
|
|
86735
|
-
`,
|
|
86736
|
-
`
|
|
86737
|
-
CREATE UNIQUE INDEX bundle_generations_improvement_source_idx
|
|
86738
|
-
ON bundle_generations (improvement_opportunity_id, source_event_id)
|
|
86739
|
-
WHERE improvement_opportunity_id IS NOT NULL
|
|
86740
|
-
`,
|
|
86741
|
-
`
|
|
86742
|
-
CREATE INDEX bundle_generations_project_created_idx
|
|
86743
|
-
ON bundle_generations (project_id, created_at DESC, bundle_type)
|
|
86744
|
-
`,
|
|
86745
|
-
`
|
|
86746
|
-
CREATE INDEX bundle_generations_incident_generation_idx
|
|
86747
|
-
ON bundle_generations (incident_id, generation_number DESC)
|
|
86748
|
-
`,
|
|
86749
|
-
`
|
|
86750
|
-
CREATE INDEX bundle_generations_improvement_generation_idx
|
|
86751
|
-
ON bundle_generations (improvement_opportunity_id, generation_number DESC)
|
|
86752
|
-
WHERE improvement_opportunity_id IS NOT NULL
|
|
86753
|
-
`,
|
|
86754
|
-
`
|
|
86755
|
-
CREATE TABLE incident_events (
|
|
86756
|
-
incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86757
|
-
event_id uuid NOT NULL,
|
|
86758
|
-
event_type text NOT NULL,
|
|
86759
|
-
event_class text NOT NULL DEFAULT 'context_signal',
|
|
86760
|
-
occurred_at timestamptz NOT NULL,
|
|
86761
|
-
is_sampled boolean NOT NULL DEFAULT false,
|
|
86762
|
-
level text,
|
|
86763
|
-
retain_first boolean NOT NULL DEFAULT false,
|
|
86764
|
-
retain_latest boolean NOT NULL DEFAULT false,
|
|
86765
|
-
retain_after_deploy boolean NOT NULL DEFAULT false,
|
|
86766
|
-
retain_highest_severity boolean NOT NULL DEFAULT false,
|
|
86767
|
-
retain_deploy_metadata boolean NOT NULL DEFAULT false,
|
|
86768
|
-
severity_rank integer NOT NULL DEFAULT 0,
|
|
86769
|
-
PRIMARY KEY (incident_id, event_id)
|
|
86770
|
-
)
|
|
86771
|
-
`,
|
|
86772
|
-
`
|
|
86773
|
-
CREATE INDEX incident_events_incident_occurred_event_idx
|
|
86774
|
-
ON incident_events (incident_id, occurred_at DESC, event_id DESC)
|
|
86775
|
-
`,
|
|
86776
|
-
`
|
|
86777
|
-
CREATE INDEX incident_events_incident_level_occurred_event_idx
|
|
86778
|
-
ON incident_events (incident_id, level, occurred_at DESC, event_id DESC)
|
|
86779
|
-
`,
|
|
86780
|
-
`
|
|
86781
|
-
CREATE INDEX incident_events_incident_sampled_idx
|
|
86782
|
-
ON incident_events (incident_id, is_sampled, occurred_at ASC, event_id ASC)
|
|
86783
|
-
`,
|
|
86950
|
+
...STORAGE_BOOTSTRAP_INCIDENT_STATEMENTS,
|
|
86784
86951
|
`
|
|
86785
86952
|
CREATE TABLE weekly_report_channels (
|
|
86786
86953
|
id uuid PRIMARY KEY,
|
|
@@ -89369,7 +89536,12 @@ var LATE_STORAGE_SCHEMA_MIGRATIONS = [
|
|
|
89369
89536
|
// ../../packages/storage/src/schema-migrations-catalog.ts
|
|
89370
89537
|
var STORAGE_SCHEMA_MIGRATIONS = [
|
|
89371
89538
|
...EARLY_STORAGE_SCHEMA_MIGRATIONS,
|
|
89372
|
-
...LATE_STORAGE_SCHEMA_MIGRATIONS
|
|
89539
|
+
...LATE_STORAGE_SCHEMA_MIGRATIONS,
|
|
89540
|
+
defineStorageSchemaMigration({
|
|
89541
|
+
id: "202609160001_add_browser_resource_routes",
|
|
89542
|
+
description: "Retain sanitized browser resource routes independently of raw event sampling.",
|
|
89543
|
+
statements: ["ALTER TABLE incident_events ADD COLUMN IF NOT EXISTS resource_route text"]
|
|
89544
|
+
})
|
|
89373
89545
|
];
|
|
89374
89546
|
|
|
89375
89547
|
// ../../packages/storage/src/schema-migrations.ts
|
|
@@ -93745,6 +93917,27 @@ var import_node_crypto10 = require("node:crypto");
|
|
|
93745
93917
|
var import_promises10 = require("node:fs/promises");
|
|
93746
93918
|
var import_node_path11 = require("node:path");
|
|
93747
93919
|
|
|
93920
|
+
// ../../packages/bundle-engine/src/browser-resource-context.ts
|
|
93921
|
+
function buildBrowserResourceContext(browserEvent, incident, events2) {
|
|
93922
|
+
const resource = describeBrowserResource(browserEvent);
|
|
93923
|
+
if (resource === null) return void 0;
|
|
93924
|
+
const routes = [];
|
|
93925
|
+
for (const event of events2) {
|
|
93926
|
+
if (event.event_type !== "frontend_exception" || event.service.name !== incident.service_name || event.service.environment !== incident.environment)
|
|
93927
|
+
continue;
|
|
93928
|
+
const candidate = describeBrowserResource(event.payload.browser_event);
|
|
93929
|
+
if (candidate !== null && candidate.host === resource.host && candidate.path === resource.path && candidate.type === resource.type) {
|
|
93930
|
+
routes.push(event.payload.route ?? null);
|
|
93931
|
+
}
|
|
93932
|
+
}
|
|
93933
|
+
return {
|
|
93934
|
+
version: 1,
|
|
93935
|
+
...resource,
|
|
93936
|
+
diagnosis: browserResourceDiagnosis(resource),
|
|
93937
|
+
routes: incident.resource_routes ?? summarizeResourceRoutes(routes, incident.occurrence_count)
|
|
93938
|
+
};
|
|
93939
|
+
}
|
|
93940
|
+
|
|
93748
93941
|
// ../../packages/bundle-engine/src/deployment-context.ts
|
|
93749
93942
|
function selectScopedDeployments(input3) {
|
|
93750
93943
|
const cutoff = Date.parse(input3.occurredAt);
|
|
@@ -93830,9 +94023,9 @@ function stableJson2(value) {
|
|
|
93830
94023
|
if (Array.isArray(value)) {
|
|
93831
94024
|
return `[${value.map((entry) => stableJson2(entry)).join(",")}]`;
|
|
93832
94025
|
}
|
|
93833
|
-
const
|
|
93834
|
-
const keys2 = Object.keys(
|
|
93835
|
-
return `{${keys2.map((key) => `${JSON.stringify(key)}:${stableJson2(
|
|
94026
|
+
const record2 = value;
|
|
94027
|
+
const keys2 = Object.keys(record2).sort();
|
|
94028
|
+
return `{${keys2.map((key) => `${JSON.stringify(key)}:${stableJson2(record2[key])}`).join(",")}}`;
|
|
93836
94029
|
}
|
|
93837
94030
|
function buildFrontendBreadcrumbKey(input3) {
|
|
93838
94031
|
return `${input3.breadcrumb_type}:${input3.ts}:${input3.route ?? ""}:${stableJson2(input3.data)}`;
|
|
@@ -94206,10 +94399,11 @@ function buildSummaryGuidance(input3) {
|
|
|
94206
94399
|
}
|
|
94207
94400
|
if (input3.opaqueBrowserError) {
|
|
94208
94401
|
if (input3.browserEvent?.kind === "resource_error") {
|
|
94402
|
+
const resource = describeBrowserResource(input3.browserEvent);
|
|
94209
94403
|
return {
|
|
94210
|
-
likely_cause:
|
|
94404
|
+
likely_cause: browserResourceDiagnosis(resource),
|
|
94211
94405
|
confidence: 0.35,
|
|
94212
|
-
recommended_action: "
|
|
94406
|
+
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.")
|
|
94213
94407
|
};
|
|
94214
94408
|
}
|
|
94215
94409
|
return {
|
|
@@ -94483,8 +94677,10 @@ function buildBundle(input3) {
|
|
|
94483
94677
|
errorContext,
|
|
94484
94678
|
requestContext
|
|
94485
94679
|
);
|
|
94486
|
-
const
|
|
94680
|
+
const browserEventCandidate = getPrimaryBrowserExceptionEvent(sourceEnvelopes, primarySignalEnvelope);
|
|
94681
|
+
const browserEvent = browserEventCandidate?.kind === "resource_error" && primarySignalEnvelope !== null && !isFrontendExceptionEnvelope(primarySignalEnvelope) ? null : browserEventCandidate;
|
|
94487
94682
|
const opaqueBrowserError = isOpaqueBrowserError(errorContext, browserEvent);
|
|
94683
|
+
const resourceContext = buildBrowserResourceContext(browserEvent, input3.incident, sourceEnvelopes);
|
|
94488
94684
|
const primarySignalType = primarySignalEnvelope !== null ? mapSignalType(primarySignalEnvelope.event_type) : inferSignalTypeFromSourceEventTypes(sourceEventTypes);
|
|
94489
94685
|
const primarySourceEvent = errorContext?.name ?? sourceEventTypes[0] ?? "backend_exception";
|
|
94490
94686
|
const firstSeenAt = new Date(input3.incident.first_seen_at).toISOString();
|
|
@@ -94558,6 +94754,7 @@ function buildBundle(input3) {
|
|
|
94558
94754
|
regression_suspected: input3.job.trigger === "regression_reopen"
|
|
94559
94755
|
},
|
|
94560
94756
|
context: {
|
|
94757
|
+
...resourceContext === void 0 ? {} : { resource_failure: resourceContext },
|
|
94561
94758
|
error: errorContext,
|
|
94562
94759
|
request: requestContext,
|
|
94563
94760
|
response: responseContext,
|
|
@@ -94621,8 +94818,8 @@ function stableStringify(value) {
|
|
|
94621
94818
|
function shellQuote(value) {
|
|
94622
94819
|
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
94623
94820
|
}
|
|
94624
|
-
function sortRecordEntries(
|
|
94625
|
-
return Object.entries(
|
|
94821
|
+
function sortRecordEntries(record2) {
|
|
94822
|
+
return Object.entries(record2).sort(([left], [right]) => left.localeCompare(right));
|
|
94626
94823
|
}
|
|
94627
94824
|
var REPLAY_HEADER_PRIORITY = [
|
|
94628
94825
|
"authorization",
|
|
@@ -94927,6 +95124,159 @@ function buildReproduction(bundle) {
|
|
|
94927
95124
|
};
|
|
94928
95125
|
}
|
|
94929
95126
|
|
|
95127
|
+
// src/local-processing-state.ts
|
|
95128
|
+
var EVENT_TYPE_SET = new Set(EventTypeValues);
|
|
95129
|
+
function isEventType(value) {
|
|
95130
|
+
return typeof value === "string" && EVENT_TYPE_SET.has(value);
|
|
95131
|
+
}
|
|
95132
|
+
function parseIncidentState(candidate) {
|
|
95133
|
+
if (!isRecord(candidate)) {
|
|
95134
|
+
return null;
|
|
95135
|
+
}
|
|
95136
|
+
if (candidate["source"] !== "local" || candidate["status"] !== "open" && candidate["status"] !== "resolved") {
|
|
95137
|
+
return null;
|
|
95138
|
+
}
|
|
95139
|
+
const sourceEvents = candidate["source_events"];
|
|
95140
|
+
if (!Array.isArray(sourceEvents)) {
|
|
95141
|
+
return null;
|
|
95142
|
+
}
|
|
95143
|
+
const validatedSourceEvents = [];
|
|
95144
|
+
for (const sourceEvent of sourceEvents) {
|
|
95145
|
+
const validated = validateEvent(sourceEvent);
|
|
95146
|
+
if (!validated.success) {
|
|
95147
|
+
return null;
|
|
95148
|
+
}
|
|
95149
|
+
validatedSourceEvents.push(validated.data);
|
|
95150
|
+
}
|
|
95151
|
+
const matchedFields = candidate["matched_fields"];
|
|
95152
|
+
const sourceEventTypes = candidate["source_event_types"];
|
|
95153
|
+
if (!Array.isArray(matchedFields) || !matchedFields.every((value) => typeof value === "string")) {
|
|
95154
|
+
return null;
|
|
95155
|
+
}
|
|
95156
|
+
if (!Array.isArray(sourceEventTypes) || !sourceEventTypes.every(isEventType)) {
|
|
95157
|
+
return null;
|
|
95158
|
+
}
|
|
95159
|
+
const severity = candidate["severity"];
|
|
95160
|
+
if (severity !== "low" && severity !== "medium" && severity !== "high" && severity !== "critical") {
|
|
95161
|
+
return null;
|
|
95162
|
+
}
|
|
95163
|
+
const status = candidate["status"];
|
|
95164
|
+
if (status !== "open" && status !== "resolved") {
|
|
95165
|
+
return null;
|
|
95166
|
+
}
|
|
95167
|
+
const requiredStringKeys = [
|
|
95168
|
+
"incident_id",
|
|
95169
|
+
"project_id",
|
|
95170
|
+
"service_id",
|
|
95171
|
+
"service_name",
|
|
95172
|
+
"environment",
|
|
95173
|
+
"fingerprint",
|
|
95174
|
+
"fingerprint_version",
|
|
95175
|
+
"title",
|
|
95176
|
+
"first_seen_at",
|
|
95177
|
+
"last_seen_at",
|
|
95178
|
+
"source_event_id",
|
|
95179
|
+
"source_occurred_at",
|
|
95180
|
+
"bundle_path",
|
|
95181
|
+
"reproduction_path"
|
|
95182
|
+
];
|
|
95183
|
+
for (const key of requiredStringKeys) {
|
|
95184
|
+
if (typeof candidate[key] !== "string") {
|
|
95185
|
+
return null;
|
|
95186
|
+
}
|
|
95187
|
+
}
|
|
95188
|
+
if (typeof candidate["occurrence_count"] !== "number" || typeof candidate["generation_number"] !== "number") {
|
|
95189
|
+
return null;
|
|
95190
|
+
}
|
|
95191
|
+
const serviceRuntime = candidate["service_runtime"];
|
|
95192
|
+
const serviceFramework = candidate["service_framework"];
|
|
95193
|
+
if (serviceRuntime !== null && typeof serviceRuntime !== "string") {
|
|
95194
|
+
return null;
|
|
95195
|
+
}
|
|
95196
|
+
if (serviceFramework !== null && typeof serviceFramework !== "string") {
|
|
95197
|
+
return null;
|
|
95198
|
+
}
|
|
95199
|
+
const incidentId = candidate["incident_id"];
|
|
95200
|
+
const projectId = candidate["project_id"];
|
|
95201
|
+
const serviceId = candidate["service_id"];
|
|
95202
|
+
const serviceName = candidate["service_name"];
|
|
95203
|
+
const environment = candidate["environment"];
|
|
95204
|
+
const incidentFingerprint = candidate["fingerprint"];
|
|
95205
|
+
const fingerprintVersion2 = candidate["fingerprint_version"];
|
|
95206
|
+
const title = candidate["title"];
|
|
95207
|
+
const firstSeenAt = candidate["first_seen_at"];
|
|
95208
|
+
const lastSeenAt = candidate["last_seen_at"];
|
|
95209
|
+
const occurrenceCount = candidate["occurrence_count"];
|
|
95210
|
+
const sourceEventId = candidate["source_event_id"];
|
|
95211
|
+
const sourceOccurredAt = candidate["source_occurred_at"];
|
|
95212
|
+
const bundlePath = candidate["bundle_path"];
|
|
95213
|
+
const reproductionPath = candidate["reproduction_path"];
|
|
95214
|
+
const generationNumber = candidate["generation_number"];
|
|
95215
|
+
const normalizedSourceEventTypes = [...sourceEventTypes].sort();
|
|
95216
|
+
return {
|
|
95217
|
+
incident_id: incidentId,
|
|
95218
|
+
source: "local",
|
|
95219
|
+
project_id: projectId,
|
|
95220
|
+
service_id: serviceId,
|
|
95221
|
+
service_name: serviceName,
|
|
95222
|
+
service_runtime: serviceRuntime,
|
|
95223
|
+
service_framework: serviceFramework,
|
|
95224
|
+
environment,
|
|
95225
|
+
fingerprint: incidentFingerprint,
|
|
95226
|
+
fingerprint_version: fingerprintVersion2,
|
|
95227
|
+
title,
|
|
95228
|
+
severity,
|
|
95229
|
+
status,
|
|
95230
|
+
first_seen_at: firstSeenAt,
|
|
95231
|
+
last_seen_at: lastSeenAt,
|
|
95232
|
+
occurrence_count: occurrenceCount,
|
|
95233
|
+
source_event_id: sourceEventId,
|
|
95234
|
+
source_occurred_at: sourceOccurredAt,
|
|
95235
|
+
source_event_types: normalizedSourceEventTypes,
|
|
95236
|
+
matched_fields: [...matchedFields].sort(),
|
|
95237
|
+
bundle_path: bundlePath,
|
|
95238
|
+
reproduction_path: reproductionPath,
|
|
95239
|
+
generation_number: generationNumber,
|
|
95240
|
+
source_events: validatedSourceEvents.sort(compareEventEnvelopes)
|
|
95241
|
+
};
|
|
95242
|
+
}
|
|
95243
|
+
function parseState(rawState) {
|
|
95244
|
+
const parsed = JSON.parse(rawState);
|
|
95245
|
+
if (!isRecord(parsed) || parsed["version"] !== 1) {
|
|
95246
|
+
return null;
|
|
95247
|
+
}
|
|
95248
|
+
const lastProcessedEventFile = parsed["last_processed_event_file"];
|
|
95249
|
+
if (lastProcessedEventFile !== null && typeof lastProcessedEventFile !== "string") {
|
|
95250
|
+
return null;
|
|
95251
|
+
}
|
|
95252
|
+
const incidents = parsed["incidents"];
|
|
95253
|
+
if (!isRecord(incidents)) {
|
|
95254
|
+
return null;
|
|
95255
|
+
}
|
|
95256
|
+
const parsedIncidents = {};
|
|
95257
|
+
for (const [incidentId, incidentValue] of Object.entries(incidents).sort(
|
|
95258
|
+
([left], [right]) => left.localeCompare(right)
|
|
95259
|
+
)) {
|
|
95260
|
+
const incident = parseIncidentState(incidentValue);
|
|
95261
|
+
if (incident === null || incident.incident_id !== incidentId) {
|
|
95262
|
+
return null;
|
|
95263
|
+
}
|
|
95264
|
+
parsedIncidents[incidentId] = incident;
|
|
95265
|
+
}
|
|
95266
|
+
return {
|
|
95267
|
+
version: 1,
|
|
95268
|
+
last_processed_event_file: lastProcessedEventFile,
|
|
95269
|
+
incidents: parsedIncidents
|
|
95270
|
+
};
|
|
95271
|
+
}
|
|
95272
|
+
function compareEventEnvelopes(left, right) {
|
|
95273
|
+
const occurredAtComparison = left.occurred_at.localeCompare(right.occurred_at);
|
|
95274
|
+
if (occurredAtComparison !== 0) {
|
|
95275
|
+
return occurredAtComparison;
|
|
95276
|
+
}
|
|
95277
|
+
return left.event_id.localeCompare(right.event_id);
|
|
95278
|
+
}
|
|
95279
|
+
|
|
94930
95280
|
// src/process-command.ts
|
|
94931
95281
|
var LOCAL_EVENTS_DIRECTORY_PATH2 = ".debugbundle/local/events";
|
|
94932
95282
|
var LOCAL_STATE_FILE_PATH = ".debugbundle/local/state.json";
|
|
@@ -94937,10 +95287,6 @@ var CLI_SDK = {
|
|
|
94937
95287
|
name: "debugbundle-cli",
|
|
94938
95288
|
version: "0.1.0"
|
|
94939
95289
|
};
|
|
94940
|
-
var EVENT_TYPE_SET = new Set(EventTypeValues);
|
|
94941
|
-
function isEventType(value) {
|
|
94942
|
-
return typeof value === "string" && EVENT_TYPE_SET.has(value);
|
|
94943
|
-
}
|
|
94944
95290
|
function inferSeverity2(event, capturePreset, incidentKind = "immediate") {
|
|
94945
95291
|
if (incidentKind === "request_anomaly") {
|
|
94946
95292
|
return "medium";
|
|
@@ -94948,7 +95294,8 @@ function inferSeverity2(event, capturePreset, incidentKind = "immediate") {
|
|
|
94948
95294
|
if (event.event_type === "request_event") {
|
|
94949
95295
|
return classifyRequestStatus({ responseStatus: event.payload.response_status, capturePreset }) === "incident_signal" ? "high" : "low";
|
|
94950
95296
|
}
|
|
94951
|
-
if (event.event_type === "
|
|
95297
|
+
if (event.event_type === "frontend_exception") return inferFrontendExceptionSeverity(event);
|
|
95298
|
+
if (event.event_type === "backend_exception") {
|
|
94952
95299
|
return "high";
|
|
94953
95300
|
}
|
|
94954
95301
|
if (event.event_type === "error_suppressed") {
|
|
@@ -94968,13 +95315,6 @@ function severityRank(severity) {
|
|
|
94968
95315
|
return 1;
|
|
94969
95316
|
}
|
|
94970
95317
|
}
|
|
94971
|
-
function compareEventEnvelopes(left, right) {
|
|
94972
|
-
const occurredAtComparison = left.occurred_at.localeCompare(right.occurred_at);
|
|
94973
|
-
if (occurredAtComparison !== 0) {
|
|
94974
|
-
return occurredAtComparison;
|
|
94975
|
-
}
|
|
94976
|
-
return left.event_id.localeCompare(right.event_id);
|
|
94977
|
-
}
|
|
94978
95318
|
function classifyEnvelope(envelope, capturePreset) {
|
|
94979
95319
|
return classifyEvent(
|
|
94980
95320
|
envelope.event_type,
|
|
@@ -95066,9 +95406,9 @@ function stableJson3(value) {
|
|
|
95066
95406
|
if (Array.isArray(value)) {
|
|
95067
95407
|
return `[${value.map((entry) => stableJson3(entry)).join(",")}]`;
|
|
95068
95408
|
}
|
|
95069
|
-
const
|
|
95070
|
-
const keys2 = Object.keys(
|
|
95071
|
-
return `{${keys2.map((key) => `${JSON.stringify(key)}:${stableJson3(
|
|
95409
|
+
const record2 = value;
|
|
95410
|
+
const keys2 = Object.keys(record2).sort();
|
|
95411
|
+
return `{${keys2.map((key) => `${JSON.stringify(key)}:${stableJson3(record2[key])}`).join(",")}}`;
|
|
95072
95412
|
}
|
|
95073
95413
|
function buildRequestAnomalyFingerprint(input3) {
|
|
95074
95414
|
return (0, import_node_crypto10.createHash)("sha256").update(
|
|
@@ -95221,144 +95561,6 @@ async function pathExists4(path, stat) {
|
|
|
95221
95561
|
throw error;
|
|
95222
95562
|
}
|
|
95223
95563
|
}
|
|
95224
|
-
function parseIncidentState(candidate) {
|
|
95225
|
-
if (!isRecord(candidate)) {
|
|
95226
|
-
return null;
|
|
95227
|
-
}
|
|
95228
|
-
if (candidate["source"] !== "local" || candidate["status"] !== "open" && candidate["status"] !== "resolved") {
|
|
95229
|
-
return null;
|
|
95230
|
-
}
|
|
95231
|
-
const sourceEvents = candidate["source_events"];
|
|
95232
|
-
if (!Array.isArray(sourceEvents)) {
|
|
95233
|
-
return null;
|
|
95234
|
-
}
|
|
95235
|
-
const validatedSourceEvents = [];
|
|
95236
|
-
for (const sourceEvent of sourceEvents) {
|
|
95237
|
-
const validated = validateEvent(sourceEvent);
|
|
95238
|
-
if (!validated.success) {
|
|
95239
|
-
return null;
|
|
95240
|
-
}
|
|
95241
|
-
validatedSourceEvents.push(validated.data);
|
|
95242
|
-
}
|
|
95243
|
-
const matchedFields = candidate["matched_fields"];
|
|
95244
|
-
const sourceEventTypes = candidate["source_event_types"];
|
|
95245
|
-
if (!Array.isArray(matchedFields) || !matchedFields.every((value) => typeof value === "string")) {
|
|
95246
|
-
return null;
|
|
95247
|
-
}
|
|
95248
|
-
if (!Array.isArray(sourceEventTypes) || !sourceEventTypes.every(isEventType)) {
|
|
95249
|
-
return null;
|
|
95250
|
-
}
|
|
95251
|
-
const severity = candidate["severity"];
|
|
95252
|
-
if (severity !== "low" && severity !== "medium" && severity !== "high" && severity !== "critical") {
|
|
95253
|
-
return null;
|
|
95254
|
-
}
|
|
95255
|
-
const status = candidate["status"];
|
|
95256
|
-
if (status !== "open" && status !== "resolved") {
|
|
95257
|
-
return null;
|
|
95258
|
-
}
|
|
95259
|
-
const requiredStringKeys = [
|
|
95260
|
-
"incident_id",
|
|
95261
|
-
"project_id",
|
|
95262
|
-
"service_id",
|
|
95263
|
-
"service_name",
|
|
95264
|
-
"environment",
|
|
95265
|
-
"fingerprint",
|
|
95266
|
-
"fingerprint_version",
|
|
95267
|
-
"title",
|
|
95268
|
-
"first_seen_at",
|
|
95269
|
-
"last_seen_at",
|
|
95270
|
-
"source_event_id",
|
|
95271
|
-
"source_occurred_at",
|
|
95272
|
-
"bundle_path",
|
|
95273
|
-
"reproduction_path"
|
|
95274
|
-
];
|
|
95275
|
-
for (const key of requiredStringKeys) {
|
|
95276
|
-
if (typeof candidate[key] !== "string") {
|
|
95277
|
-
return null;
|
|
95278
|
-
}
|
|
95279
|
-
}
|
|
95280
|
-
if (typeof candidate["occurrence_count"] !== "number" || typeof candidate["generation_number"] !== "number") {
|
|
95281
|
-
return null;
|
|
95282
|
-
}
|
|
95283
|
-
const serviceRuntime = candidate["service_runtime"];
|
|
95284
|
-
const serviceFramework = candidate["service_framework"];
|
|
95285
|
-
if (serviceRuntime !== null && typeof serviceRuntime !== "string") {
|
|
95286
|
-
return null;
|
|
95287
|
-
}
|
|
95288
|
-
if (serviceFramework !== null && typeof serviceFramework !== "string") {
|
|
95289
|
-
return null;
|
|
95290
|
-
}
|
|
95291
|
-
const incidentId = candidate["incident_id"];
|
|
95292
|
-
const projectId = candidate["project_id"];
|
|
95293
|
-
const serviceId = candidate["service_id"];
|
|
95294
|
-
const serviceName = candidate["service_name"];
|
|
95295
|
-
const environment = candidate["environment"];
|
|
95296
|
-
const incidentFingerprint = candidate["fingerprint"];
|
|
95297
|
-
const fingerprintVersion = candidate["fingerprint_version"];
|
|
95298
|
-
const title = candidate["title"];
|
|
95299
|
-
const firstSeenAt = candidate["first_seen_at"];
|
|
95300
|
-
const lastSeenAt = candidate["last_seen_at"];
|
|
95301
|
-
const occurrenceCount = candidate["occurrence_count"];
|
|
95302
|
-
const sourceEventId = candidate["source_event_id"];
|
|
95303
|
-
const sourceOccurredAt = candidate["source_occurred_at"];
|
|
95304
|
-
const bundlePath = candidate["bundle_path"];
|
|
95305
|
-
const reproductionPath = candidate["reproduction_path"];
|
|
95306
|
-
const generationNumber = candidate["generation_number"];
|
|
95307
|
-
const normalizedSourceEventTypes = [...sourceEventTypes].sort();
|
|
95308
|
-
return {
|
|
95309
|
-
incident_id: incidentId,
|
|
95310
|
-
source: "local",
|
|
95311
|
-
project_id: projectId,
|
|
95312
|
-
service_id: serviceId,
|
|
95313
|
-
service_name: serviceName,
|
|
95314
|
-
service_runtime: serviceRuntime,
|
|
95315
|
-
service_framework: serviceFramework,
|
|
95316
|
-
environment,
|
|
95317
|
-
fingerprint: incidentFingerprint,
|
|
95318
|
-
fingerprint_version: fingerprintVersion,
|
|
95319
|
-
title,
|
|
95320
|
-
severity,
|
|
95321
|
-
status,
|
|
95322
|
-
first_seen_at: firstSeenAt,
|
|
95323
|
-
last_seen_at: lastSeenAt,
|
|
95324
|
-
occurrence_count: occurrenceCount,
|
|
95325
|
-
source_event_id: sourceEventId,
|
|
95326
|
-
source_occurred_at: sourceOccurredAt,
|
|
95327
|
-
source_event_types: normalizedSourceEventTypes,
|
|
95328
|
-
matched_fields: [...matchedFields].sort(),
|
|
95329
|
-
bundle_path: bundlePath,
|
|
95330
|
-
reproduction_path: reproductionPath,
|
|
95331
|
-
generation_number: generationNumber,
|
|
95332
|
-
source_events: validatedSourceEvents.sort(compareEventEnvelopes)
|
|
95333
|
-
};
|
|
95334
|
-
}
|
|
95335
|
-
function parseState(rawState) {
|
|
95336
|
-
const parsed = JSON.parse(rawState);
|
|
95337
|
-
if (!isRecord(parsed) || parsed["version"] !== 1) {
|
|
95338
|
-
return null;
|
|
95339
|
-
}
|
|
95340
|
-
const lastProcessedEventFile = parsed["last_processed_event_file"];
|
|
95341
|
-
if (lastProcessedEventFile !== null && typeof lastProcessedEventFile !== "string") {
|
|
95342
|
-
return null;
|
|
95343
|
-
}
|
|
95344
|
-
const incidents = parsed["incidents"];
|
|
95345
|
-
if (!isRecord(incidents)) {
|
|
95346
|
-
return null;
|
|
95347
|
-
}
|
|
95348
|
-
const parsedIncidents = {};
|
|
95349
|
-
for (const [incidentId, incidentValue] of Object.entries(incidents).sort(([left], [right]) => left.localeCompare(right))) {
|
|
95350
|
-
const incident = parseIncidentState(incidentValue);
|
|
95351
|
-
if (incident === null || incident.incident_id !== incidentId) {
|
|
95352
|
-
return null;
|
|
95353
|
-
}
|
|
95354
|
-
parsedIncidents[incidentId] = incident;
|
|
95355
|
-
}
|
|
95356
|
-
return {
|
|
95357
|
-
version: 1,
|
|
95358
|
-
last_processed_event_file: lastProcessedEventFile,
|
|
95359
|
-
incidents: parsedIncidents
|
|
95360
|
-
};
|
|
95361
|
-
}
|
|
95362
95564
|
async function readState(statePath, readFile, stat) {
|
|
95363
95565
|
if (!await pathExists4(statePath, stat)) {
|
|
95364
95566
|
return null;
|
|
@@ -95492,7 +95694,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95492
95694
|
mergedIncidentIds: /* @__PURE__ */ new Set([incidentId]),
|
|
95493
95695
|
signalEventTypes: /* @__PURE__ */ new Set(),
|
|
95494
95696
|
traceIds: /* @__PURE__ */ new Set(),
|
|
95495
|
-
title: normalizedEvent.normalized_message,
|
|
95697
|
+
title: normalizedEvent.incident_title ?? normalizedEvent.normalized_message,
|
|
95496
95698
|
kind: "immediate",
|
|
95497
95699
|
severity: inferSeverity2(event, capturePreset)
|
|
95498
95700
|
};
|
|
@@ -95502,7 +95704,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95502
95704
|
aggregate.newEvents.push(event);
|
|
95503
95705
|
aggregate.signalEventTypes.add(event.event_type);
|
|
95504
95706
|
const traceId = getTraceId(event);
|
|
95505
|
-
if (traceId !== null) {
|
|
95707
|
+
if (traceId !== null && normalizedEvent.resource_type === void 0) {
|
|
95506
95708
|
aggregate.traceIds.add(traceId);
|
|
95507
95709
|
const traceCorrelationGroup = traceCorrelationGroups.get(traceId) ?? {
|
|
95508
95710
|
incidentIds: /* @__PURE__ */ new Set(),
|
|
@@ -95594,7 +95796,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95594
95796
|
service_framework: latestSignalEvent.service.framework ?? existing?.service_framework ?? null,
|
|
95595
95797
|
environment: aggregate.environment,
|
|
95596
95798
|
fingerprint: aggregate.fingerprint,
|
|
95597
|
-
fingerprint_version: FINGERPRINT_VERSION,
|
|
95799
|
+
fingerprint_version: aggregate.kind === "request_anomaly" ? FINGERPRINT_VERSION : fingerprintVersion(normalizeEvent(latestSignalEvent)),
|
|
95598
95800
|
title: aggregate.title,
|
|
95599
95801
|
severity,
|
|
95600
95802
|
status: existingIncidents.some((incidentState) => incidentState.status === "resolved") ? "open" : existing?.status ?? "open",
|
|
@@ -107980,7 +108182,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
107980
108182
|
// package.json
|
|
107981
108183
|
var package_default = {
|
|
107982
108184
|
name: "@debugbundle/cli",
|
|
107983
|
-
version: "1.
|
|
108185
|
+
version: "1.9.0",
|
|
107984
108186
|
private: false,
|
|
107985
108187
|
description: "Command-line interface for DebugBundle",
|
|
107986
108188
|
license: "Apache-2.0",
|