@debugbundle/cli 1.8.0 → 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 +791 -472
- 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(),
|
|
@@ -64642,7 +64796,9 @@ var CaptureRuleEvaluationContextSchema = external_exports.object({
|
|
|
64642
64796
|
resource_url: CaptureRuleEvaluationUrlSchema.optional(),
|
|
64643
64797
|
request_url: CaptureRuleEvaluationUrlSchema.optional(),
|
|
64644
64798
|
status_code: external_exports.number().int().min(0).max(599).optional(),
|
|
64645
|
-
fingerprint: CaptureRuleFingerprintSchema.optional()
|
|
64799
|
+
fingerprint: CaptureRuleFingerprintSchema.optional(),
|
|
64800
|
+
// Server-derived prior versions keep installed exact-match rules effective.
|
|
64801
|
+
fingerprint_aliases: external_exports.array(CaptureRuleFingerprintSchema).max(2).optional()
|
|
64646
64802
|
});
|
|
64647
64803
|
function classifyCaptureRuleClientFromUserAgent(userAgent) {
|
|
64648
64804
|
if (userAgent === null || userAgent === void 0) {
|
|
@@ -64685,6 +64841,7 @@ var CaptureRuleSuggestionSchema = external_exports.object({
|
|
|
64685
64841
|
rule: CaptureRuleCreateSchema
|
|
64686
64842
|
});
|
|
64687
64843
|
var CaptureRuleSuggestionsResponseSchema = external_exports.object({
|
|
64844
|
+
access_mode: external_exports.enum(["manage", "preview"]).optional(),
|
|
64688
64845
|
suggestions: external_exports.array(CaptureRuleSuggestionSchema),
|
|
64689
64846
|
bundle_status: external_exports.enum(["ready", "pending", "failed"]).optional(),
|
|
64690
64847
|
bundle_reason: external_exports.string().nullable().optional()
|
|
@@ -65180,6 +65337,14 @@ function looksSensitiveCustomDimensionValue(value) {
|
|
|
65180
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);
|
|
65181
65338
|
}
|
|
65182
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
|
+
|
|
65183
65348
|
// ../../packages/shared-types/src/analytics-product.ts
|
|
65184
65349
|
var AnalyticsOpportunityStatusValues = ["open", "resolved", "snoozed"];
|
|
65185
65350
|
var AnalyticsOpportunityStatusSchema = external_exports.enum(AnalyticsOpportunityStatusValues);
|
|
@@ -65754,6 +65919,7 @@ var ContextDeviceSchema = external_exports.object({
|
|
|
65754
65919
|
color_scheme_preference: external_exports.enum(["light", "dark", "no-preference"]).nullable()
|
|
65755
65920
|
});
|
|
65756
65921
|
var BundleContextSchema = external_exports.object({
|
|
65922
|
+
resource_failure: BrowserResourceContextSchema.optional(),
|
|
65757
65923
|
error: ContextErrorSchema.nullable().optional(),
|
|
65758
65924
|
request: ContextRequestSchema.nullable().optional(),
|
|
65759
65925
|
response: ContextResponseSchema.nullable().optional(),
|
|
@@ -84216,8 +84382,57 @@ var WINDOW_RETENTION_SECONDS = WINDOW_24H_SECONDS + WINDOW_1H_SECONDS;
|
|
|
84216
84382
|
// ../../packages/storage/src/ingestion-rate-limiter.ts
|
|
84217
84383
|
var import_ioredis3 = __toESM(require_built3(), 1);
|
|
84218
84384
|
|
|
84219
|
-
// ../../packages/event-normalizer/src/
|
|
84220
|
-
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
|
+
}
|
|
84221
84436
|
|
|
84222
84437
|
// ../../packages/redaction/src/index.ts
|
|
84223
84438
|
var DEFAULT_SENSITIVE_KEYS = [
|
|
@@ -84316,7 +84531,7 @@ function redact(payload2, options) {
|
|
|
84316
84531
|
}
|
|
84317
84532
|
|
|
84318
84533
|
// ../../packages/event-normalizer/src/mobile-event-compatibility.ts
|
|
84319
|
-
var
|
|
84534
|
+
var import_node_crypto5 = require("node:crypto");
|
|
84320
84535
|
var MOBILE_SDKS = /* @__PURE__ */ new Set(["@debugbundle/sdk-android", "@debugbundle/sdk-swift"]);
|
|
84321
84536
|
function isRecord3(candidate) {
|
|
84322
84537
|
return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
|
|
@@ -84343,8 +84558,8 @@ function readInteger(candidate) {
|
|
|
84343
84558
|
function readBoolean2(candidate) {
|
|
84344
84559
|
return typeof candidate === "boolean" ? candidate : null;
|
|
84345
84560
|
}
|
|
84346
|
-
function readField(
|
|
84347
|
-
return
|
|
84561
|
+
function readField(record2, snakeCase, camelCase) {
|
|
84562
|
+
return record2[snakeCase] ?? record2[camelCase];
|
|
84348
84563
|
}
|
|
84349
84564
|
function stableValue(candidate) {
|
|
84350
84565
|
if (Array.isArray(candidate)) {
|
|
@@ -84358,7 +84573,7 @@ function stableValue(candidate) {
|
|
|
84358
84573
|
);
|
|
84359
84574
|
}
|
|
84360
84575
|
function deterministicEventId(candidate) {
|
|
84361
|
-
const digest2 = (0,
|
|
84576
|
+
const digest2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify(stableValue(candidate))).digest("hex");
|
|
84362
84577
|
const chars = digest2.slice(0, 32).split("");
|
|
84363
84578
|
chars[12] = "5";
|
|
84364
84579
|
chars[16] = ["8", "9", "a", "b"][Number.parseInt(chars[16] ?? "0", 16) % 4] ?? "8";
|
|
@@ -84716,8 +84931,14 @@ function normalizeInstalledJavaEvent(candidate) {
|
|
|
84716
84931
|
};
|
|
84717
84932
|
}
|
|
84718
84933
|
|
|
84934
|
+
// ../../packages/event-normalizer/src/java-timer-message.ts
|
|
84935
|
+
var TIMER_DIAGNOSTIC = /^WFLYEJB002(?:0|2):[^\n]*\[id=[^\]\n]*\btimedObjectId=/;
|
|
84936
|
+
var JAVA_TIMER_DATE = /\b(previousRun|initialExpiration|nextExpiration)=((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+[A-Za-z][A-Za-z0-9:+-]{0,15}\s+\d{4})\b/g;
|
|
84937
|
+
function normalizeJavaTimerMessage(message3) {
|
|
84938
|
+
return TIMER_DIAGNOSTIC.test(message3) ? message3.replace(JAVA_TIMER_DATE, "$1={dynamic}") : message3;
|
|
84939
|
+
}
|
|
84940
|
+
|
|
84719
84941
|
// ../../packages/event-normalizer/src/index.ts
|
|
84720
|
-
var FINGERPRINT_VERSION = "v1";
|
|
84721
84942
|
var PAYLOAD_ALLOWED_KEYS = {
|
|
84722
84943
|
backend_exception: /* @__PURE__ */ new Set([
|
|
84723
84944
|
"name",
|
|
@@ -84900,34 +85121,6 @@ function normalizeCompatibleEventCandidate(candidate) {
|
|
|
84900
85121
|
}
|
|
84901
85122
|
return event;
|
|
84902
85123
|
}
|
|
84903
|
-
function inferMatchedFields(event) {
|
|
84904
|
-
const matchedFields = ["environment", "normalized_message"];
|
|
84905
|
-
if (event.error_type !== null) {
|
|
84906
|
-
matchedFields.push("error_type");
|
|
84907
|
-
}
|
|
84908
|
-
if (event.route_template !== null) {
|
|
84909
|
-
matchedFields.push("route_template");
|
|
84910
|
-
}
|
|
84911
|
-
if (event.top_frames.length > 0) {
|
|
84912
|
-
matchedFields.push("top_frames");
|
|
84913
|
-
}
|
|
84914
|
-
if (event.browser_event_kind != null) {
|
|
84915
|
-
matchedFields.push("browser_event_kind");
|
|
84916
|
-
}
|
|
84917
|
-
if (event.resource_host != null) {
|
|
84918
|
-
matchedFields.push("resource_host");
|
|
84919
|
-
}
|
|
84920
|
-
if (event.resource_path != null) {
|
|
84921
|
-
matchedFields.push("resource_path");
|
|
84922
|
-
}
|
|
84923
|
-
if (event.http_method !== null) {
|
|
84924
|
-
matchedFields.push("http_method");
|
|
84925
|
-
}
|
|
84926
|
-
if (event.http_status !== null) {
|
|
84927
|
-
matchedFields.push("http_status");
|
|
84928
|
-
}
|
|
84929
|
-
return matchedFields;
|
|
84930
|
-
}
|
|
84931
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;
|
|
84932
85125
|
var EMAIL_PATTERN = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
84933
85126
|
var ISO_TIMESTAMP_PATTERN = /\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z\b/g;
|
|
@@ -85051,12 +85244,12 @@ function normalizeKnownDatabaseMessage(message3) {
|
|
|
85051
85244
|
}
|
|
85052
85245
|
return null;
|
|
85053
85246
|
}
|
|
85054
|
-
function normalizeMessage(message3) {
|
|
85247
|
+
function normalizeMessage(message3, version2) {
|
|
85055
85248
|
const knownDatabaseMessage = normalizeKnownDatabaseMessage(message3);
|
|
85056
85249
|
if (knownDatabaseMessage !== null) {
|
|
85057
85250
|
return knownDatabaseMessage;
|
|
85058
85251
|
}
|
|
85059
|
-
return collapseWhitespace(normalizeScalarTokens(message3));
|
|
85252
|
+
return collapseWhitespace(normalizeScalarTokens(version2 === "v1" ? message3 : normalizeJavaTimerMessage(message3)));
|
|
85060
85253
|
}
|
|
85061
85254
|
function normalizeRoute(path) {
|
|
85062
85255
|
if (path === null || path.length === 0) {
|
|
@@ -85131,29 +85324,17 @@ function normalizeResourceIdentity(value) {
|
|
|
85131
85324
|
};
|
|
85132
85325
|
}
|
|
85133
85326
|
}
|
|
85134
|
-
function stableJson(value) {
|
|
85135
|
-
if (value === null || typeof value !== "object") {
|
|
85136
|
-
return JSON.stringify(value);
|
|
85137
|
-
}
|
|
85138
|
-
if (Array.isArray(value)) {
|
|
85139
|
-
return `[${value.map((entry) => stableJson(entry)).join(",")}]`;
|
|
85140
|
-
}
|
|
85141
|
-
const record = value;
|
|
85142
|
-
const keys2 = Object.keys(record).sort();
|
|
85143
|
-
const pairs = keys2.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`);
|
|
85144
|
-
return `{${pairs.join(",")}}`;
|
|
85145
|
-
}
|
|
85146
85327
|
function validateEvent(candidate) {
|
|
85147
85328
|
return EventEnvelopeSchema.safeParse(normalizeCompatibleEventCandidate(candidate));
|
|
85148
85329
|
}
|
|
85149
|
-
function normalizeEvent(event) {
|
|
85330
|
+
function normalizeEvent(event, version2 = RESOURCE_FINGERPRINT_VERSION) {
|
|
85150
85331
|
const redactedPayload = redact(event.payload).redacted;
|
|
85151
85332
|
if (event.event_type === "backend_exception") {
|
|
85152
85333
|
return {
|
|
85153
85334
|
event_type: event.event_type,
|
|
85154
85335
|
environment: event.service.environment,
|
|
85155
85336
|
error_type: event.payload.name,
|
|
85156
|
-
normalized_message: normalizeMessage(event.payload.message),
|
|
85337
|
+
normalized_message: normalizeMessage(event.payload.message, version2),
|
|
85157
85338
|
route_template: normalizeRoute(event.payload.request.path),
|
|
85158
85339
|
http_method: event.payload.request.method,
|
|
85159
85340
|
http_status: event.payload.response.status_code,
|
|
@@ -85185,7 +85366,7 @@ function normalizeEvent(event) {
|
|
|
85185
85366
|
event_type: event.event_type,
|
|
85186
85367
|
environment: event.service.environment,
|
|
85187
85368
|
error_type: null,
|
|
85188
|
-
normalized_message: normalizeMessage(event.payload.message),
|
|
85369
|
+
normalized_message: normalizeMessage(event.payload.message, version2),
|
|
85189
85370
|
route_template: null,
|
|
85190
85371
|
http_method: null,
|
|
85191
85372
|
http_status: null,
|
|
@@ -85200,18 +85381,22 @@ function normalizeEvent(event) {
|
|
|
85200
85381
|
const browserEvent = event.payload.browser_event;
|
|
85201
85382
|
const resourceIdentity = browserEvent?.kind === "resource_error" ? normalizeResourceIdentity(browserEvent.target?.source_url ?? browserEvent.file_name) : { host: null, path: null };
|
|
85202
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;
|
|
85203
85386
|
return {
|
|
85204
85387
|
event_type: event.event_type,
|
|
85205
85388
|
environment: event.service.environment,
|
|
85206
85389
|
error_type: event.payload.name,
|
|
85207
|
-
normalized_message: normalizeMessage(event.payload.message),
|
|
85390
|
+
normalized_message: normalizeMessage(event.payload.message, version2),
|
|
85208
85391
|
route_template: normalizeRoute(event.payload.route ?? null),
|
|
85209
85392
|
http_method: null,
|
|
85210
85393
|
http_status: null,
|
|
85211
85394
|
top_frames: topFrames,
|
|
85212
85395
|
browser_event_kind: browserEvent?.kind ?? null,
|
|
85213
|
-
resource_host: resourceIdentity.host,
|
|
85214
|
-
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 },
|
|
85215
85400
|
payload: redactedPayload
|
|
85216
85401
|
};
|
|
85217
85402
|
}
|
|
@@ -85230,21 +85415,6 @@ function normalizeEvent(event) {
|
|
|
85230
85415
|
payload: redactedPayload
|
|
85231
85416
|
};
|
|
85232
85417
|
}
|
|
85233
|
-
function fingerprint(event) {
|
|
85234
|
-
const canonical = {
|
|
85235
|
-
error_type: event.error_type,
|
|
85236
|
-
normalized_message: event.normalized_message,
|
|
85237
|
-
top_frames: event.top_frames,
|
|
85238
|
-
route_template: event.route_template,
|
|
85239
|
-
browser_event_kind: event.browser_event_kind,
|
|
85240
|
-
resource_host: event.resource_host,
|
|
85241
|
-
resource_path: event.resource_path,
|
|
85242
|
-
http_method: event.http_method,
|
|
85243
|
-
http_status: event.http_status,
|
|
85244
|
-
environment: event.environment
|
|
85245
|
-
};
|
|
85246
|
-
return (0, import_node_crypto5.createHash)("sha256").update(stableJson(canonical)).digest("hex");
|
|
85247
|
-
}
|
|
85248
85418
|
var INCIDENT_LOG_LEVELS = /* @__PURE__ */ new Set(["error", "fatal", "critical"]);
|
|
85249
85419
|
function getRequestResponseStatus(payload2) {
|
|
85250
85420
|
const status = payload2?.["response_status"];
|
|
@@ -85937,6 +86107,54 @@ var ANALYTICS_BOOTSTRAP_STATEMENTS = [
|
|
|
85937
86107
|
`
|
|
85938
86108
|
];
|
|
85939
86109
|
|
|
86110
|
+
// ../../packages/storage/src/schema-migration-definition.ts
|
|
86111
|
+
var import_node_crypto6 = require("node:crypto");
|
|
86112
|
+
function defineStorageSchemaMigration(input3) {
|
|
86113
|
+
return {
|
|
86114
|
+
...input3,
|
|
86115
|
+
checksum: (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify(input3)).digest("hex")
|
|
86116
|
+
};
|
|
86117
|
+
}
|
|
86118
|
+
|
|
86119
|
+
// ../../packages/storage/src/worker-job-schema.ts
|
|
86120
|
+
var WORKER_JOB_SCHEMA_STATEMENTS = [
|
|
86121
|
+
`CREATE TABLE IF NOT EXISTS worker_jobs (
|
|
86122
|
+
id text PRIMARY KEY,
|
|
86123
|
+
job_name text NOT NULL,
|
|
86124
|
+
project_id uuid REFERENCES projects(id) ON DELETE CASCADE,
|
|
86125
|
+
payload jsonb,
|
|
86126
|
+
depends_on text REFERENCES worker_jobs(id) ON DELETE RESTRICT,
|
|
86127
|
+
status text NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running', 'completed', 'failed', 'skipped')),
|
|
86128
|
+
attempts integer NOT NULL DEFAULT 0 CHECK (attempts >= 0),
|
|
86129
|
+
operator_retries integer NOT NULL DEFAULT 0 CHECK (operator_retries >= 0),
|
|
86130
|
+
available_at timestamptz NOT NULL DEFAULT now(),
|
|
86131
|
+
lease_token uuid,
|
|
86132
|
+
lease_expires_at timestamptz,
|
|
86133
|
+
last_error_code text,
|
|
86134
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86135
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86136
|
+
expires_at timestamptz NOT NULL DEFAULT now() + interval '7 days',
|
|
86137
|
+
CHECK ((status = 'running') = (lease_token IS NOT NULL AND lease_expires_at IS NOT NULL)),
|
|
86138
|
+
CHECK (payload IS NULL OR jsonb_typeof(payload) = 'object')
|
|
86139
|
+
)`,
|
|
86140
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_pending_idx ON worker_jobs(job_name, available_at, created_at, id) WHERE status = 'pending'`,
|
|
86141
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_running_idx ON worker_jobs(lease_expires_at) WHERE status = 'running'`,
|
|
86142
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_expiry_idx ON worker_jobs(expires_at)`,
|
|
86143
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_project_idx ON worker_jobs(project_id)`,
|
|
86144
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_dependency_idx ON worker_jobs(depends_on) WHERE depends_on IS NOT NULL`,
|
|
86145
|
+
`CREATE INDEX IF NOT EXISTS worker_jobs_status_idx ON worker_jobs(status, created_at) WHERE status IN ('pending', 'running', 'failed')`
|
|
86146
|
+
];
|
|
86147
|
+
var WORKER_JOB_SCHEMA_MIGRATIONS = [
|
|
86148
|
+
defineStorageSchemaMigration({
|
|
86149
|
+
id: "202609130001_add_durable_worker_jobs",
|
|
86150
|
+
description: "Persist worker handoffs, bounded retries, and fenced processing leases",
|
|
86151
|
+
statements: WORKER_JOB_SCHEMA_STATEMENTS
|
|
86152
|
+
})
|
|
86153
|
+
];
|
|
86154
|
+
var WORKER_JOB_BOOTSTRAP_STATEMENTS = WORKER_JOB_SCHEMA_STATEMENTS.map(
|
|
86155
|
+
(statement) => statement.replaceAll(" IF NOT EXISTS", "")
|
|
86156
|
+
);
|
|
86157
|
+
|
|
85940
86158
|
// ../../packages/storage/src/openai-oauth-bootstrap-statements.ts
|
|
85941
86159
|
var OPENAI_OAUTH_BOOTSTRAP_STATEMENTS = [
|
|
85942
86160
|
`
|
|
@@ -86023,6 +86241,192 @@ var OPENAI_OAUTH_BOOTSTRAP_STATEMENTS = [
|
|
|
86023
86241
|
`CREATE INDEX oauth_provider_artifacts_expires_idx ON oauth_provider_artifacts (expires_at, model, provider_id_hash)`
|
|
86024
86242
|
];
|
|
86025
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
|
+
|
|
86026
86430
|
// ../../packages/storage/src/storage-bootstrap-account-analytics-statements.ts
|
|
86027
86431
|
var STORAGE_BOOTSTRAP_ACCOUNT_ANALYTICS_STATEMENTS = [
|
|
86028
86432
|
`
|
|
@@ -86543,187 +86947,7 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
|
|
|
86543
86947
|
CREATE INDEX deployments_project_service_env_deployed_idx
|
|
86544
86948
|
ON deployments (project_id, service_id, environment, deployed_at DESC)
|
|
86545
86949
|
`,
|
|
86546
|
-
|
|
86547
|
-
CREATE TABLE incidents (
|
|
86548
|
-
id uuid PRIMARY KEY,
|
|
86549
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86550
|
-
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86551
|
-
environment text NOT NULL DEFAULT 'production',
|
|
86552
|
-
fingerprint text NOT NULL,
|
|
86553
|
-
fingerprint_version text NOT NULL DEFAULT 'v1',
|
|
86554
|
-
title text NOT NULL,
|
|
86555
|
-
severity text NOT NULL,
|
|
86556
|
-
status text NOT NULL DEFAULT 'open',
|
|
86557
|
-
first_seen_at timestamptz NOT NULL,
|
|
86558
|
-
last_seen_at timestamptz NOT NULL,
|
|
86559
|
-
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86560
|
-
matched_fields text[],
|
|
86561
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86562
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86563
|
-
regressed_at timestamptz,
|
|
86564
|
-
spike_detected_at timestamptz,
|
|
86565
|
-
frequency_occurrences_1m integer,
|
|
86566
|
-
frequency_occurrences_5m integer,
|
|
86567
|
-
frequency_occurrences_1h integer,
|
|
86568
|
-
frequency_occurrences_24h integer,
|
|
86569
|
-
frequency_baseline_1h_per_5m double precision,
|
|
86570
|
-
frequency_spike_ratio_5m_to_1h double precision,
|
|
86571
|
-
frequency_has_sufficient_baseline boolean,
|
|
86572
|
-
frequency_is_spiking boolean,
|
|
86573
|
-
frequency_snapshot_at timestamptz,
|
|
86574
|
-
latest_deployment_id uuid REFERENCES deployments(id) ON DELETE SET NULL,
|
|
86575
|
-
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86576
|
-
bundle_created_at timestamptz,
|
|
86577
|
-
bundle_updated_at timestamptz,
|
|
86578
|
-
bundle_source_event_id uuid,
|
|
86579
|
-
bundle_source_occurred_at timestamptz,
|
|
86580
|
-
bundle_trigger text,
|
|
86581
|
-
bundle_failure_reason text,
|
|
86582
|
-
resolved_at timestamptz,
|
|
86583
|
-
resolved_by_member_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86584
|
-
UNIQUE (project_id, environment, service_id, fingerprint)
|
|
86585
|
-
)
|
|
86586
|
-
`,
|
|
86587
|
-
`
|
|
86588
|
-
CREATE TABLE processed_events (
|
|
86589
|
-
event_id uuid PRIMARY KEY,
|
|
86590
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86591
|
-
event_type text NOT NULL,
|
|
86592
|
-
fingerprint text NOT NULL,
|
|
86593
|
-
normalized_message text NOT NULL,
|
|
86594
|
-
processed_at timestamptz NOT NULL DEFAULT now()
|
|
86595
|
-
)
|
|
86596
|
-
`,
|
|
86597
|
-
`
|
|
86598
|
-
CREATE TABLE improvement_opportunities (
|
|
86599
|
-
id uuid PRIMARY KEY,
|
|
86600
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86601
|
-
service_id uuid REFERENCES services(id) ON DELETE SET NULL,
|
|
86602
|
-
service_name text NOT NULL,
|
|
86603
|
-
environment text NOT NULL DEFAULT 'production',
|
|
86604
|
-
kind text NOT NULL,
|
|
86605
|
-
status text NOT NULL DEFAULT 'open',
|
|
86606
|
-
severity text NOT NULL,
|
|
86607
|
-
confidence numeric NOT NULL,
|
|
86608
|
-
fingerprint text NOT NULL,
|
|
86609
|
-
title text NOT NULL,
|
|
86610
|
-
summary text NOT NULL,
|
|
86611
|
-
occurrence_count integer NOT NULL DEFAULT 1,
|
|
86612
|
-
evidence jsonb NOT NULL,
|
|
86613
|
-
first_detected_at timestamptz NOT NULL,
|
|
86614
|
-
last_detected_at timestamptz NOT NULL,
|
|
86615
|
-
last_source_event_id uuid,
|
|
86616
|
-
related_incident_ids uuid[] NOT NULL DEFAULT '{}',
|
|
86617
|
-
bundle_generation_number integer NOT NULL DEFAULT 0,
|
|
86618
|
-
bundle_created_at timestamptz,
|
|
86619
|
-
bundle_updated_at timestamptz,
|
|
86620
|
-
bundle_source_event_id uuid,
|
|
86621
|
-
bundle_failure_reason text,
|
|
86622
|
-
resolved_at timestamptz,
|
|
86623
|
-
resolved_by_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
|
|
86624
|
-
snoozed_until timestamptz,
|
|
86625
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
86626
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
86627
|
-
UNIQUE (project_id, fingerprint)
|
|
86628
|
-
)
|
|
86629
|
-
`,
|
|
86630
|
-
`
|
|
86631
|
-
CREATE INDEX improvement_opportunities_project_status_detected_idx
|
|
86632
|
-
ON improvement_opportunities (project_id, status, last_detected_at DESC)
|
|
86633
|
-
`,
|
|
86634
|
-
`
|
|
86635
|
-
CREATE INDEX improvement_opportunities_project_kind_detected_idx
|
|
86636
|
-
ON improvement_opportunities (project_id, kind, last_detected_at DESC)
|
|
86637
|
-
`,
|
|
86638
|
-
`
|
|
86639
|
-
CREATE INDEX improvement_opportunities_project_service_env_idx
|
|
86640
|
-
ON improvement_opportunities (project_id, service_id, environment)
|
|
86641
|
-
`,
|
|
86642
|
-
`
|
|
86643
|
-
CREATE TABLE improvement_opportunity_events (
|
|
86644
|
-
improvement_opportunity_id uuid NOT NULL REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86645
|
-
event_id uuid NOT NULL,
|
|
86646
|
-
event_type text NOT NULL,
|
|
86647
|
-
occurred_at timestamptz NOT NULL,
|
|
86648
|
-
PRIMARY KEY (improvement_opportunity_id, event_id)
|
|
86649
|
-
)
|
|
86650
|
-
`,
|
|
86651
|
-
`
|
|
86652
|
-
CREATE INDEX improvement_opportunity_events_detected_idx
|
|
86653
|
-
ON improvement_opportunity_events (improvement_opportunity_id, occurred_at DESC, event_id DESC)
|
|
86654
|
-
`,
|
|
86655
|
-
`
|
|
86656
|
-
CREATE TABLE bundle_generations (
|
|
86657
|
-
id uuid PRIMARY KEY,
|
|
86658
|
-
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
86659
|
-
incident_id uuid REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86660
|
-
improvement_opportunity_id uuid REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
86661
|
-
bundle_type text NOT NULL,
|
|
86662
|
-
generation_number integer NOT NULL,
|
|
86663
|
-
source_event_id uuid NOT NULL,
|
|
86664
|
-
source_occurred_at timestamptz NOT NULL,
|
|
86665
|
-
trigger text NOT NULL,
|
|
86666
|
-
created_at timestamptz NOT NULL,
|
|
86667
|
-
updated_at timestamptz NOT NULL,
|
|
86668
|
-
CHECK (
|
|
86669
|
-
(incident_id IS NOT NULL AND improvement_opportunity_id IS NULL AND bundle_type = 'failure')
|
|
86670
|
-
OR (incident_id IS NULL AND improvement_opportunity_id IS NOT NULL AND bundle_type = 'improvement')
|
|
86671
|
-
)
|
|
86672
|
-
)
|
|
86673
|
-
`,
|
|
86674
|
-
`
|
|
86675
|
-
CREATE UNIQUE INDEX bundle_generations_incident_source_idx
|
|
86676
|
-
ON bundle_generations (incident_id, source_event_id)
|
|
86677
|
-
WHERE incident_id IS NOT NULL
|
|
86678
|
-
`,
|
|
86679
|
-
`
|
|
86680
|
-
CREATE UNIQUE INDEX bundle_generations_improvement_source_idx
|
|
86681
|
-
ON bundle_generations (improvement_opportunity_id, source_event_id)
|
|
86682
|
-
WHERE improvement_opportunity_id IS NOT NULL
|
|
86683
|
-
`,
|
|
86684
|
-
`
|
|
86685
|
-
CREATE INDEX bundle_generations_project_created_idx
|
|
86686
|
-
ON bundle_generations (project_id, created_at DESC, bundle_type)
|
|
86687
|
-
`,
|
|
86688
|
-
`
|
|
86689
|
-
CREATE INDEX bundle_generations_incident_generation_idx
|
|
86690
|
-
ON bundle_generations (incident_id, generation_number DESC)
|
|
86691
|
-
`,
|
|
86692
|
-
`
|
|
86693
|
-
CREATE INDEX bundle_generations_improvement_generation_idx
|
|
86694
|
-
ON bundle_generations (improvement_opportunity_id, generation_number DESC)
|
|
86695
|
-
WHERE improvement_opportunity_id IS NOT NULL
|
|
86696
|
-
`,
|
|
86697
|
-
`
|
|
86698
|
-
CREATE TABLE incident_events (
|
|
86699
|
-
incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE,
|
|
86700
|
-
event_id uuid NOT NULL,
|
|
86701
|
-
event_type text NOT NULL,
|
|
86702
|
-
event_class text NOT NULL DEFAULT 'context_signal',
|
|
86703
|
-
occurred_at timestamptz NOT NULL,
|
|
86704
|
-
is_sampled boolean NOT NULL DEFAULT false,
|
|
86705
|
-
level text,
|
|
86706
|
-
retain_first boolean NOT NULL DEFAULT false,
|
|
86707
|
-
retain_latest boolean NOT NULL DEFAULT false,
|
|
86708
|
-
retain_after_deploy boolean NOT NULL DEFAULT false,
|
|
86709
|
-
retain_highest_severity boolean NOT NULL DEFAULT false,
|
|
86710
|
-
retain_deploy_metadata boolean NOT NULL DEFAULT false,
|
|
86711
|
-
severity_rank integer NOT NULL DEFAULT 0,
|
|
86712
|
-
PRIMARY KEY (incident_id, event_id)
|
|
86713
|
-
)
|
|
86714
|
-
`,
|
|
86715
|
-
`
|
|
86716
|
-
CREATE INDEX incident_events_incident_occurred_event_idx
|
|
86717
|
-
ON incident_events (incident_id, occurred_at DESC, event_id DESC)
|
|
86718
|
-
`,
|
|
86719
|
-
`
|
|
86720
|
-
CREATE INDEX incident_events_incident_level_occurred_event_idx
|
|
86721
|
-
ON incident_events (incident_id, level, occurred_at DESC, event_id DESC)
|
|
86722
|
-
`,
|
|
86723
|
-
`
|
|
86724
|
-
CREATE INDEX incident_events_incident_sampled_idx
|
|
86725
|
-
ON incident_events (incident_id, is_sampled, occurred_at ASC, event_id ASC)
|
|
86726
|
-
`,
|
|
86950
|
+
...STORAGE_BOOTSTRAP_INCIDENT_STATEMENTS,
|
|
86727
86951
|
`
|
|
86728
86952
|
CREATE TABLE weekly_report_channels (
|
|
86729
86953
|
id uuid PRIMARY KEY,
|
|
@@ -87177,18 +87401,19 @@ var STORAGE_BOOTSTRAP_STATEMENTS2 = [
|
|
|
87177
87401
|
...STORAGE_BOOTSTRAP_STATEMENTS,
|
|
87178
87402
|
...OPENAI_OAUTH_BOOTSTRAP_STATEMENTS,
|
|
87179
87403
|
...AVAILABILITY_CHECK_BOOTSTRAP_STATEMENTS,
|
|
87180
|
-
...ANALYTICS_BOOTSTRAP_STATEMENTS
|
|
87404
|
+
...ANALYTICS_BOOTSTRAP_STATEMENTS,
|
|
87405
|
+
...WORKER_JOB_BOOTSTRAP_STATEMENTS
|
|
87181
87406
|
];
|
|
87182
87407
|
|
|
87183
87408
|
// ../../packages/storage/src/migrations.ts
|
|
87184
87409
|
var STORAGE_BOOTSTRAP_SQL = STORAGE_BOOTSTRAP_STATEMENTS2.join(";\n\n");
|
|
87185
87410
|
|
|
87186
87411
|
// ../../packages/storage/src/availability-check-schema-migrations.ts
|
|
87187
|
-
var
|
|
87412
|
+
var import_node_crypto7 = require("node:crypto");
|
|
87188
87413
|
function defineAvailabilityCheckStorageSchemaMigration(input3) {
|
|
87189
87414
|
return {
|
|
87190
87415
|
...input3,
|
|
87191
|
-
checksum: (0,
|
|
87416
|
+
checksum: (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify(input3)).digest("hex")
|
|
87192
87417
|
};
|
|
87193
87418
|
}
|
|
87194
87419
|
var AVAILABILITY_CHECK_STORAGE_SCHEMA_MIGRATIONS = [
|
|
@@ -87432,11 +87657,11 @@ var AVAILABILITY_CHECK_STORAGE_SCHEMA_MIGRATIONS = [
|
|
|
87432
87657
|
];
|
|
87433
87658
|
|
|
87434
87659
|
// ../../packages/storage/src/analytics-schema-migrations.ts
|
|
87435
|
-
var
|
|
87660
|
+
var import_node_crypto8 = require("node:crypto");
|
|
87436
87661
|
function defineAnalyticsStorageSchemaMigration(input3) {
|
|
87437
87662
|
return {
|
|
87438
87663
|
...input3,
|
|
87439
|
-
checksum: (0,
|
|
87664
|
+
checksum: (0, import_node_crypto8.createHash)("sha256").update(JSON.stringify(input3)).digest("hex")
|
|
87440
87665
|
};
|
|
87441
87666
|
}
|
|
87442
87667
|
var analyticsAnalysisKindCheck2 = "('usage_summary', 'route_health', 'funnel_dropoff', 'journey_friction', 'feature_usage', 'incident_impact', 'deploy_comparison', 'conversion_path')";
|
|
@@ -88224,15 +88449,6 @@ var ANALYTICS_STORAGE_SCHEMA_MIGRATIONS = [
|
|
|
88224
88449
|
})
|
|
88225
88450
|
];
|
|
88226
88451
|
|
|
88227
|
-
// ../../packages/storage/src/schema-migration-definition.ts
|
|
88228
|
-
var import_node_crypto8 = require("node:crypto");
|
|
88229
|
-
function defineStorageSchemaMigration(input3) {
|
|
88230
|
-
return {
|
|
88231
|
-
...input3,
|
|
88232
|
-
checksum: (0, import_node_crypto8.createHash)("sha256").update(JSON.stringify(input3)).digest("hex")
|
|
88233
|
-
};
|
|
88234
|
-
}
|
|
88235
|
-
|
|
88236
88452
|
// ../../packages/storage/src/openai-oauth-schema-migrations.ts
|
|
88237
88453
|
var OPENAI_OAUTH_STORAGE_SCHEMA_MIGRATIONS = [
|
|
88238
88454
|
defineStorageSchemaMigration({
|
|
@@ -89320,7 +89536,12 @@ var LATE_STORAGE_SCHEMA_MIGRATIONS = [
|
|
|
89320
89536
|
// ../../packages/storage/src/schema-migrations-catalog.ts
|
|
89321
89537
|
var STORAGE_SCHEMA_MIGRATIONS = [
|
|
89322
89538
|
...EARLY_STORAGE_SCHEMA_MIGRATIONS,
|
|
89323
|
-
...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
|
+
})
|
|
89324
89545
|
];
|
|
89325
89546
|
|
|
89326
89547
|
// ../../packages/storage/src/schema-migrations.ts
|
|
@@ -89328,7 +89549,8 @@ var STORAGE_SCHEMA_MIGRATIONS2 = [
|
|
|
89328
89549
|
...STORAGE_SCHEMA_MIGRATIONS,
|
|
89329
89550
|
...AVAILABILITY_CHECK_STORAGE_SCHEMA_MIGRATIONS,
|
|
89330
89551
|
...ANALYTICS_STORAGE_SCHEMA_MIGRATIONS,
|
|
89331
|
-
...OPENAI_OAUTH_STORAGE_SCHEMA_MIGRATIONS
|
|
89552
|
+
...OPENAI_OAUTH_STORAGE_SCHEMA_MIGRATIONS,
|
|
89553
|
+
...WORKER_JOB_SCHEMA_MIGRATIONS
|
|
89332
89554
|
].sort((left, right) => left.id.localeCompare(right.id));
|
|
89333
89555
|
|
|
89334
89556
|
// src/local-retrieval-store.ts
|
|
@@ -93695,6 +93917,39 @@ var import_node_crypto10 = require("node:crypto");
|
|
|
93695
93917
|
var import_promises10 = require("node:fs/promises");
|
|
93696
93918
|
var import_node_path11 = require("node:path");
|
|
93697
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
|
+
|
|
93941
|
+
// ../../packages/bundle-engine/src/deployment-context.ts
|
|
93942
|
+
function selectScopedDeployments(input3) {
|
|
93943
|
+
const cutoff = Date.parse(input3.occurredAt);
|
|
93944
|
+
const configuredAt = Date.parse(input3.configuredDeployedAt ?? "");
|
|
93945
|
+
return input3.envelopes.filter(
|
|
93946
|
+
(event) => event.event_type === "deploy_metadata" && event.service.name === input3.service && event.service.environment === input3.environment && event.payload.environment === input3.environment && Date.parse(event.payload.deployed_at) <= cutoff && // A caller-provided workload history row can be newer than the raw window.
|
|
93947
|
+
(!(configuredAt <= cutoff) || Date.parse(event.payload.deployed_at) >= configuredAt)
|
|
93948
|
+
).sort(
|
|
93949
|
+
(left, right) => Date.parse(left.payload.deployed_at) - Date.parse(right.payload.deployed_at) || left.event_id.localeCompare(right.event_id)
|
|
93950
|
+
);
|
|
93951
|
+
}
|
|
93952
|
+
|
|
93698
93953
|
// ../../packages/bundle-engine/src/frontend-context.ts
|
|
93699
93954
|
function toIsoTimestamp(value) {
|
|
93700
93955
|
return new Date(value).toISOString();
|
|
@@ -93768,9 +94023,9 @@ function stableJson2(value) {
|
|
|
93768
94023
|
if (Array.isArray(value)) {
|
|
93769
94024
|
return `[${value.map((entry) => stableJson2(entry)).join(",")}]`;
|
|
93770
94025
|
}
|
|
93771
|
-
const
|
|
93772
|
-
const keys2 = Object.keys(
|
|
93773
|
-
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(",")}}`;
|
|
93774
94029
|
}
|
|
93775
94030
|
function buildFrontendBreadcrumbKey(input3) {
|
|
93776
94031
|
return `${input3.breadcrumb_type}:${input3.ts}:${input3.route ?? ""}:${stableJson2(input3.data)}`;
|
|
@@ -94080,6 +94335,7 @@ function buildRequestContext(envelopes) {
|
|
|
94080
94335
|
if (exceptionEvent === null) {
|
|
94081
94336
|
return null;
|
|
94082
94337
|
}
|
|
94338
|
+
if (exceptionEvent.payload.request.method.toUpperCase() === "UNKNOWN") return null;
|
|
94083
94339
|
return {
|
|
94084
94340
|
version: 1,
|
|
94085
94341
|
method: exceptionEvent.payload.request.method,
|
|
@@ -94143,10 +94399,11 @@ function buildSummaryGuidance(input3) {
|
|
|
94143
94399
|
}
|
|
94144
94400
|
if (input3.opaqueBrowserError) {
|
|
94145
94401
|
if (input3.browserEvent?.kind === "resource_error") {
|
|
94402
|
+
const resource = describeBrowserResource(input3.browserEvent);
|
|
94146
94403
|
return {
|
|
94147
|
-
likely_cause:
|
|
94404
|
+
likely_cause: browserResourceDiagnosis(resource),
|
|
94148
94405
|
confidence: 0.35,
|
|
94149
|
-
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.")
|
|
94150
94407
|
};
|
|
94151
94408
|
}
|
|
94152
94409
|
return {
|
|
@@ -94400,21 +94657,30 @@ function buildBundle(input3) {
|
|
|
94400
94657
|
const responseContext = buildResponseContext(sourceEnvelopes);
|
|
94401
94658
|
const logsContext = buildLogsContext(sourceEnvelopes);
|
|
94402
94659
|
const frontendContext = buildFrontendContext(sourceEnvelopes);
|
|
94660
|
+
const deploymentEnvelopes = selectScopedDeployments({
|
|
94661
|
+
envelopes: sourceEnvelopes,
|
|
94662
|
+
service: input3.incident.service_name,
|
|
94663
|
+
environment: input3.incident.environment,
|
|
94664
|
+
occurredAt: input3.bundleMetadata.source_occurred_at,
|
|
94665
|
+
configuredDeployedAt: input3.configuredDeploy?.deployed_at ?? null
|
|
94666
|
+
});
|
|
94403
94667
|
const deployContext = buildDeployContext(
|
|
94404
|
-
|
|
94668
|
+
deploymentEnvelopes,
|
|
94405
94669
|
input3.job.trigger,
|
|
94406
94670
|
input3.configuredDeploy
|
|
94407
94671
|
);
|
|
94408
94672
|
const runtimeContext = buildRuntimeContext(sourceEnvelopes);
|
|
94409
|
-
const gitContext = buildGitContext(
|
|
94673
|
+
const gitContext = buildGitContext(deploymentEnvelopes, input3.configuredDeploy);
|
|
94410
94674
|
const deviceContext = buildDeviceContext(sourceEnvelopes);
|
|
94411
94675
|
const dependenciesContext = buildDependenciesContext(
|
|
94412
94676
|
input3.incident,
|
|
94413
94677
|
errorContext,
|
|
94414
94678
|
requestContext
|
|
94415
94679
|
);
|
|
94416
|
-
const
|
|
94680
|
+
const browserEventCandidate = getPrimaryBrowserExceptionEvent(sourceEnvelopes, primarySignalEnvelope);
|
|
94681
|
+
const browserEvent = browserEventCandidate?.kind === "resource_error" && primarySignalEnvelope !== null && !isFrontendExceptionEnvelope(primarySignalEnvelope) ? null : browserEventCandidate;
|
|
94417
94682
|
const opaqueBrowserError = isOpaqueBrowserError(errorContext, browserEvent);
|
|
94683
|
+
const resourceContext = buildBrowserResourceContext(browserEvent, input3.incident, sourceEnvelopes);
|
|
94418
94684
|
const primarySignalType = primarySignalEnvelope !== null ? mapSignalType(primarySignalEnvelope.event_type) : inferSignalTypeFromSourceEventTypes(sourceEventTypes);
|
|
94419
94685
|
const primarySourceEvent = errorContext?.name ?? sourceEventTypes[0] ?? "backend_exception";
|
|
94420
94686
|
const firstSeenAt = new Date(input3.incident.first_seen_at).toISOString();
|
|
@@ -94488,6 +94754,7 @@ function buildBundle(input3) {
|
|
|
94488
94754
|
regression_suspected: input3.job.trigger === "regression_reopen"
|
|
94489
94755
|
},
|
|
94490
94756
|
context: {
|
|
94757
|
+
...resourceContext === void 0 ? {} : { resource_failure: resourceContext },
|
|
94491
94758
|
error: errorContext,
|
|
94492
94759
|
request: requestContext,
|
|
94493
94760
|
response: responseContext,
|
|
@@ -94541,7 +94808,9 @@ function stableStringify(value) {
|
|
|
94541
94808
|
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
94542
94809
|
}
|
|
94543
94810
|
if (value !== null && typeof value === "object") {
|
|
94544
|
-
const entries = Object.entries(value).sort(
|
|
94811
|
+
const entries = Object.entries(value).sort(
|
|
94812
|
+
([left], [right]) => left.localeCompare(right)
|
|
94813
|
+
);
|
|
94545
94814
|
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`).join(",")}}`;
|
|
94546
94815
|
}
|
|
94547
94816
|
return JSON.stringify(value);
|
|
@@ -94549,8 +94818,8 @@ function stableStringify(value) {
|
|
|
94549
94818
|
function shellQuote(value) {
|
|
94550
94819
|
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
94551
94820
|
}
|
|
94552
|
-
function sortRecordEntries(
|
|
94553
|
-
return Object.entries(
|
|
94821
|
+
function sortRecordEntries(record2) {
|
|
94822
|
+
return Object.entries(record2).sort(([left], [right]) => left.localeCompare(right));
|
|
94554
94823
|
}
|
|
94555
94824
|
var REPLAY_HEADER_PRIORITY = [
|
|
94556
94825
|
"authorization",
|
|
@@ -94620,7 +94889,10 @@ function normalizeReplayJsonValue(value) {
|
|
|
94620
94889
|
}
|
|
94621
94890
|
if (value !== null && typeof value === "object") {
|
|
94622
94891
|
return Object.fromEntries(
|
|
94623
|
-
Object.entries(value).map(([key, entryValue]) => [
|
|
94892
|
+
Object.entries(value).map(([key, entryValue]) => [
|
|
94893
|
+
key,
|
|
94894
|
+
normalizeReplayJsonValue(entryValue)
|
|
94895
|
+
])
|
|
94624
94896
|
);
|
|
94625
94897
|
}
|
|
94626
94898
|
return value;
|
|
@@ -94641,7 +94913,10 @@ function normalizeReplayQueryValue(value) {
|
|
|
94641
94913
|
}
|
|
94642
94914
|
if (value !== null && typeof value === "object") {
|
|
94643
94915
|
return Object.fromEntries(
|
|
94644
|
-
sortRecordEntries(value).map(([key, entryValue]) => [
|
|
94916
|
+
sortRecordEntries(value).map(([key, entryValue]) => [
|
|
94917
|
+
key,
|
|
94918
|
+
normalizeReplayQueryValue(entryValue)
|
|
94919
|
+
])
|
|
94645
94920
|
);
|
|
94646
94921
|
}
|
|
94647
94922
|
return value;
|
|
@@ -94657,7 +94932,9 @@ function hasStructuredQueryAmbiguity(value) {
|
|
|
94657
94932
|
return value.some((item) => hasStructuredQueryAmbiguity(item));
|
|
94658
94933
|
}
|
|
94659
94934
|
if (value !== null && typeof value === "object") {
|
|
94660
|
-
return Object.values(value).some(
|
|
94935
|
+
return Object.values(value).some(
|
|
94936
|
+
(item) => hasStructuredQueryAmbiguity(item)
|
|
94937
|
+
);
|
|
94661
94938
|
}
|
|
94662
94939
|
return false;
|
|
94663
94940
|
}
|
|
@@ -94668,7 +94945,9 @@ function buildStructuredReplayQuery(query) {
|
|
|
94668
94945
|
return hasStructuredQueryAmbiguity(normalizedQuery) ? normalizedQuery : void 0;
|
|
94669
94946
|
}
|
|
94670
94947
|
function buildReplayHeaders(headers) {
|
|
94671
|
-
const entries = sortRecordEntries(headers).filter(([headerName]) => !DROPPED_REPLAY_HEADERS.has(headerName.toLowerCase())).map(
|
|
94948
|
+
const entries = sortRecordEntries(headers).filter(([headerName]) => !DROPPED_REPLAY_HEADERS.has(headerName.toLowerCase())).map(
|
|
94949
|
+
([headerName, headerValue]) => [headerName, normalizeHeaderValue(headerValue)]
|
|
94950
|
+
);
|
|
94672
94951
|
entries.sort(([left], [right]) => {
|
|
94673
94952
|
const leftPriority = REPLAY_HEADER_PRIORITY.indexOf(left.toLowerCase());
|
|
94674
94953
|
const rightPriority = REPLAY_HEADER_PRIORITY.indexOf(right.toLowerCase());
|
|
@@ -94694,7 +94973,9 @@ function expandHeaderValues(headers) {
|
|
|
94694
94973
|
});
|
|
94695
94974
|
}
|
|
94696
94975
|
function getHeaderValues(headers, headerName) {
|
|
94697
|
-
const matchedEntry = sortRecordEntries(headers).find(
|
|
94976
|
+
const matchedEntry = sortRecordEntries(headers).find(
|
|
94977
|
+
([candidateName]) => candidateName.toLowerCase() === headerName.toLowerCase()
|
|
94978
|
+
);
|
|
94698
94979
|
if (matchedEntry === void 0) {
|
|
94699
94980
|
return [];
|
|
94700
94981
|
}
|
|
@@ -94756,6 +95037,9 @@ function buildDeterministicRequestUrl(request) {
|
|
|
94756
95037
|
const protocol = typeof protoHeader === "string" && protoHeader.length > 0 ? protoHeader : "https";
|
|
94757
95038
|
const host = typeof forwardedHostHeader === "string" && forwardedHostHeader.length > 0 ? forwardedHostHeader : typeof hostHeader === "string" && hostHeader.length > 0 ? hostHeader : "example.invalid";
|
|
94758
95039
|
const url = new URL(request.path, `${protocol}://${host}`);
|
|
95040
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
|
|
95041
|
+
throw new Error("request_url_invalid");
|
|
95042
|
+
}
|
|
94759
95043
|
for (const [key, rawValue] of sortRecordEntries(request.query)) {
|
|
94760
95044
|
if (Array.isArray(rawValue)) {
|
|
94761
95045
|
for (const item of rawValue) {
|
|
@@ -94779,22 +95063,52 @@ function buildReproduction(bundle) {
|
|
|
94779
95063
|
};
|
|
94780
95064
|
}
|
|
94781
95065
|
const method = request.method.toUpperCase();
|
|
94782
|
-
|
|
95066
|
+
if (!/^[A-Z][A-Z0-9_-]{0,31}$/.test(method) || method === "UNKNOWN") {
|
|
95067
|
+
return {
|
|
95068
|
+
possible: false,
|
|
95069
|
+
confidence: 0.1,
|
|
95070
|
+
reason: "request_method_unavailable",
|
|
95071
|
+
artifacts: null,
|
|
95072
|
+
feasibility_reference: null
|
|
95073
|
+
};
|
|
95074
|
+
}
|
|
95075
|
+
let url;
|
|
95076
|
+
try {
|
|
95077
|
+
url = buildDeterministicRequestUrl(request);
|
|
95078
|
+
} catch {
|
|
95079
|
+
return {
|
|
95080
|
+
possible: false,
|
|
95081
|
+
confidence: 0.1,
|
|
95082
|
+
reason: "request_url_invalid",
|
|
95083
|
+
artifacts: null,
|
|
95084
|
+
feasibility_reference: null
|
|
95085
|
+
};
|
|
95086
|
+
}
|
|
94783
95087
|
const replayHeaders = buildReplayHeaders(request.headers);
|
|
94784
95088
|
const contentType = getPrimaryContentType(replayHeaders);
|
|
94785
95089
|
const structuredReplayQuery = buildStructuredReplayQuery(request.query);
|
|
94786
|
-
const headerParts = expandHeaderValues(replayHeaders).map(
|
|
94787
|
-
|
|
95090
|
+
const headerParts = expandHeaderValues(replayHeaders).map(
|
|
95091
|
+
([headerName, headerValue]) => `${headerName}:${headerValue}`
|
|
95092
|
+
);
|
|
95093
|
+
const curlHeaderParts = headerParts.map(
|
|
95094
|
+
(header2) => `-H ${shellQuote(header2.replace(":", ": "))}`
|
|
95095
|
+
);
|
|
94788
95096
|
const requestBody = buildReplayBody(request.body, replayHeaders);
|
|
94789
95097
|
const jsonSpecBody = contentType === "application/json" ? request.body === void 0 ? null : normalizeReplayJsonValue(request.body) : typeof request.body === "string" ? requestBody : request.body === null || request.body === void 0 ? null : request.body;
|
|
94790
95098
|
const curlBodyPart = requestBody === null ? [] : [`--data-raw ${shellQuote(requestBody)}`];
|
|
94791
|
-
const curl = [`curl -X ${method} ${shellQuote(url)}`, ...curlHeaderParts, ...curlBodyPart].join(
|
|
94792
|
-
|
|
95099
|
+
const curl = [`curl -X ${method} ${shellQuote(url)}`, ...curlHeaderParts, ...curlBodyPart].join(
|
|
95100
|
+
" "
|
|
95101
|
+
);
|
|
95102
|
+
const httpieBase = [
|
|
95103
|
+
`http ${method} ${shellQuote(url)}`,
|
|
95104
|
+
...headerParts.map((header2) => shellQuote(header2))
|
|
95105
|
+
].join(" ");
|
|
94793
95106
|
const httpie = requestBody === null ? httpieBase : `printf '%s' ${shellQuote(requestBody)} | ${httpieBase}`;
|
|
95107
|
+
const hasRequestTarget = new URL(url).hostname !== "example.invalid";
|
|
94794
95108
|
return {
|
|
94795
|
-
possible:
|
|
94796
|
-
confidence: 0.8,
|
|
94797
|
-
reason: "request_context_available",
|
|
95109
|
+
possible: hasRequestTarget,
|
|
95110
|
+
confidence: hasRequestTarget ? 0.8 : 0.1,
|
|
95111
|
+
reason: hasRequestTarget ? "request_context_available" : "request_target_unavailable",
|
|
94798
95112
|
artifacts: {
|
|
94799
95113
|
curl,
|
|
94800
95114
|
httpie,
|
|
@@ -94810,6 +95124,159 @@ function buildReproduction(bundle) {
|
|
|
94810
95124
|
};
|
|
94811
95125
|
}
|
|
94812
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
|
+
|
|
94813
95280
|
// src/process-command.ts
|
|
94814
95281
|
var LOCAL_EVENTS_DIRECTORY_PATH2 = ".debugbundle/local/events";
|
|
94815
95282
|
var LOCAL_STATE_FILE_PATH = ".debugbundle/local/state.json";
|
|
@@ -94820,10 +95287,6 @@ var CLI_SDK = {
|
|
|
94820
95287
|
name: "debugbundle-cli",
|
|
94821
95288
|
version: "0.1.0"
|
|
94822
95289
|
};
|
|
94823
|
-
var EVENT_TYPE_SET = new Set(EventTypeValues);
|
|
94824
|
-
function isEventType(value) {
|
|
94825
|
-
return typeof value === "string" && EVENT_TYPE_SET.has(value);
|
|
94826
|
-
}
|
|
94827
95290
|
function inferSeverity2(event, capturePreset, incidentKind = "immediate") {
|
|
94828
95291
|
if (incidentKind === "request_anomaly") {
|
|
94829
95292
|
return "medium";
|
|
@@ -94831,7 +95294,8 @@ function inferSeverity2(event, capturePreset, incidentKind = "immediate") {
|
|
|
94831
95294
|
if (event.event_type === "request_event") {
|
|
94832
95295
|
return classifyRequestStatus({ responseStatus: event.payload.response_status, capturePreset }) === "incident_signal" ? "high" : "low";
|
|
94833
95296
|
}
|
|
94834
|
-
if (event.event_type === "
|
|
95297
|
+
if (event.event_type === "frontend_exception") return inferFrontendExceptionSeverity(event);
|
|
95298
|
+
if (event.event_type === "backend_exception") {
|
|
94835
95299
|
return "high";
|
|
94836
95300
|
}
|
|
94837
95301
|
if (event.event_type === "error_suppressed") {
|
|
@@ -94851,13 +95315,6 @@ function severityRank(severity) {
|
|
|
94851
95315
|
return 1;
|
|
94852
95316
|
}
|
|
94853
95317
|
}
|
|
94854
|
-
function compareEventEnvelopes(left, right) {
|
|
94855
|
-
const occurredAtComparison = left.occurred_at.localeCompare(right.occurred_at);
|
|
94856
|
-
if (occurredAtComparison !== 0) {
|
|
94857
|
-
return occurredAtComparison;
|
|
94858
|
-
}
|
|
94859
|
-
return left.event_id.localeCompare(right.event_id);
|
|
94860
|
-
}
|
|
94861
95318
|
function classifyEnvelope(envelope, capturePreset) {
|
|
94862
95319
|
return classifyEvent(
|
|
94863
95320
|
envelope.event_type,
|
|
@@ -94949,9 +95406,9 @@ function stableJson3(value) {
|
|
|
94949
95406
|
if (Array.isArray(value)) {
|
|
94950
95407
|
return `[${value.map((entry) => stableJson3(entry)).join(",")}]`;
|
|
94951
95408
|
}
|
|
94952
|
-
const
|
|
94953
|
-
const keys2 = Object.keys(
|
|
94954
|
-
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(",")}}`;
|
|
94955
95412
|
}
|
|
94956
95413
|
function buildRequestAnomalyFingerprint(input3) {
|
|
94957
95414
|
return (0, import_node_crypto10.createHash)("sha256").update(
|
|
@@ -95104,144 +95561,6 @@ async function pathExists4(path, stat) {
|
|
|
95104
95561
|
throw error;
|
|
95105
95562
|
}
|
|
95106
95563
|
}
|
|
95107
|
-
function parseIncidentState(candidate) {
|
|
95108
|
-
if (!isRecord(candidate)) {
|
|
95109
|
-
return null;
|
|
95110
|
-
}
|
|
95111
|
-
if (candidate["source"] !== "local" || candidate["status"] !== "open" && candidate["status"] !== "resolved") {
|
|
95112
|
-
return null;
|
|
95113
|
-
}
|
|
95114
|
-
const sourceEvents = candidate["source_events"];
|
|
95115
|
-
if (!Array.isArray(sourceEvents)) {
|
|
95116
|
-
return null;
|
|
95117
|
-
}
|
|
95118
|
-
const validatedSourceEvents = [];
|
|
95119
|
-
for (const sourceEvent of sourceEvents) {
|
|
95120
|
-
const validated = validateEvent(sourceEvent);
|
|
95121
|
-
if (!validated.success) {
|
|
95122
|
-
return null;
|
|
95123
|
-
}
|
|
95124
|
-
validatedSourceEvents.push(validated.data);
|
|
95125
|
-
}
|
|
95126
|
-
const matchedFields = candidate["matched_fields"];
|
|
95127
|
-
const sourceEventTypes = candidate["source_event_types"];
|
|
95128
|
-
if (!Array.isArray(matchedFields) || !matchedFields.every((value) => typeof value === "string")) {
|
|
95129
|
-
return null;
|
|
95130
|
-
}
|
|
95131
|
-
if (!Array.isArray(sourceEventTypes) || !sourceEventTypes.every(isEventType)) {
|
|
95132
|
-
return null;
|
|
95133
|
-
}
|
|
95134
|
-
const severity = candidate["severity"];
|
|
95135
|
-
if (severity !== "low" && severity !== "medium" && severity !== "high" && severity !== "critical") {
|
|
95136
|
-
return null;
|
|
95137
|
-
}
|
|
95138
|
-
const status = candidate["status"];
|
|
95139
|
-
if (status !== "open" && status !== "resolved") {
|
|
95140
|
-
return null;
|
|
95141
|
-
}
|
|
95142
|
-
const requiredStringKeys = [
|
|
95143
|
-
"incident_id",
|
|
95144
|
-
"project_id",
|
|
95145
|
-
"service_id",
|
|
95146
|
-
"service_name",
|
|
95147
|
-
"environment",
|
|
95148
|
-
"fingerprint",
|
|
95149
|
-
"fingerprint_version",
|
|
95150
|
-
"title",
|
|
95151
|
-
"first_seen_at",
|
|
95152
|
-
"last_seen_at",
|
|
95153
|
-
"source_event_id",
|
|
95154
|
-
"source_occurred_at",
|
|
95155
|
-
"bundle_path",
|
|
95156
|
-
"reproduction_path"
|
|
95157
|
-
];
|
|
95158
|
-
for (const key of requiredStringKeys) {
|
|
95159
|
-
if (typeof candidate[key] !== "string") {
|
|
95160
|
-
return null;
|
|
95161
|
-
}
|
|
95162
|
-
}
|
|
95163
|
-
if (typeof candidate["occurrence_count"] !== "number" || typeof candidate["generation_number"] !== "number") {
|
|
95164
|
-
return null;
|
|
95165
|
-
}
|
|
95166
|
-
const serviceRuntime = candidate["service_runtime"];
|
|
95167
|
-
const serviceFramework = candidate["service_framework"];
|
|
95168
|
-
if (serviceRuntime !== null && typeof serviceRuntime !== "string") {
|
|
95169
|
-
return null;
|
|
95170
|
-
}
|
|
95171
|
-
if (serviceFramework !== null && typeof serviceFramework !== "string") {
|
|
95172
|
-
return null;
|
|
95173
|
-
}
|
|
95174
|
-
const incidentId = candidate["incident_id"];
|
|
95175
|
-
const projectId = candidate["project_id"];
|
|
95176
|
-
const serviceId = candidate["service_id"];
|
|
95177
|
-
const serviceName = candidate["service_name"];
|
|
95178
|
-
const environment = candidate["environment"];
|
|
95179
|
-
const incidentFingerprint = candidate["fingerprint"];
|
|
95180
|
-
const fingerprintVersion = candidate["fingerprint_version"];
|
|
95181
|
-
const title = candidate["title"];
|
|
95182
|
-
const firstSeenAt = candidate["first_seen_at"];
|
|
95183
|
-
const lastSeenAt = candidate["last_seen_at"];
|
|
95184
|
-
const occurrenceCount = candidate["occurrence_count"];
|
|
95185
|
-
const sourceEventId = candidate["source_event_id"];
|
|
95186
|
-
const sourceOccurredAt = candidate["source_occurred_at"];
|
|
95187
|
-
const bundlePath = candidate["bundle_path"];
|
|
95188
|
-
const reproductionPath = candidate["reproduction_path"];
|
|
95189
|
-
const generationNumber = candidate["generation_number"];
|
|
95190
|
-
const normalizedSourceEventTypes = [...sourceEventTypes].sort();
|
|
95191
|
-
return {
|
|
95192
|
-
incident_id: incidentId,
|
|
95193
|
-
source: "local",
|
|
95194
|
-
project_id: projectId,
|
|
95195
|
-
service_id: serviceId,
|
|
95196
|
-
service_name: serviceName,
|
|
95197
|
-
service_runtime: serviceRuntime,
|
|
95198
|
-
service_framework: serviceFramework,
|
|
95199
|
-
environment,
|
|
95200
|
-
fingerprint: incidentFingerprint,
|
|
95201
|
-
fingerprint_version: fingerprintVersion,
|
|
95202
|
-
title,
|
|
95203
|
-
severity,
|
|
95204
|
-
status,
|
|
95205
|
-
first_seen_at: firstSeenAt,
|
|
95206
|
-
last_seen_at: lastSeenAt,
|
|
95207
|
-
occurrence_count: occurrenceCount,
|
|
95208
|
-
source_event_id: sourceEventId,
|
|
95209
|
-
source_occurred_at: sourceOccurredAt,
|
|
95210
|
-
source_event_types: normalizedSourceEventTypes,
|
|
95211
|
-
matched_fields: [...matchedFields].sort(),
|
|
95212
|
-
bundle_path: bundlePath,
|
|
95213
|
-
reproduction_path: reproductionPath,
|
|
95214
|
-
generation_number: generationNumber,
|
|
95215
|
-
source_events: validatedSourceEvents.sort(compareEventEnvelopes)
|
|
95216
|
-
};
|
|
95217
|
-
}
|
|
95218
|
-
function parseState(rawState) {
|
|
95219
|
-
const parsed = JSON.parse(rawState);
|
|
95220
|
-
if (!isRecord(parsed) || parsed["version"] !== 1) {
|
|
95221
|
-
return null;
|
|
95222
|
-
}
|
|
95223
|
-
const lastProcessedEventFile = parsed["last_processed_event_file"];
|
|
95224
|
-
if (lastProcessedEventFile !== null && typeof lastProcessedEventFile !== "string") {
|
|
95225
|
-
return null;
|
|
95226
|
-
}
|
|
95227
|
-
const incidents = parsed["incidents"];
|
|
95228
|
-
if (!isRecord(incidents)) {
|
|
95229
|
-
return null;
|
|
95230
|
-
}
|
|
95231
|
-
const parsedIncidents = {};
|
|
95232
|
-
for (const [incidentId, incidentValue] of Object.entries(incidents).sort(([left], [right]) => left.localeCompare(right))) {
|
|
95233
|
-
const incident = parseIncidentState(incidentValue);
|
|
95234
|
-
if (incident === null || incident.incident_id !== incidentId) {
|
|
95235
|
-
return null;
|
|
95236
|
-
}
|
|
95237
|
-
parsedIncidents[incidentId] = incident;
|
|
95238
|
-
}
|
|
95239
|
-
return {
|
|
95240
|
-
version: 1,
|
|
95241
|
-
last_processed_event_file: lastProcessedEventFile,
|
|
95242
|
-
incidents: parsedIncidents
|
|
95243
|
-
};
|
|
95244
|
-
}
|
|
95245
95564
|
async function readState(statePath, readFile, stat) {
|
|
95246
95565
|
if (!await pathExists4(statePath, stat)) {
|
|
95247
95566
|
return null;
|
|
@@ -95375,7 +95694,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95375
95694
|
mergedIncidentIds: /* @__PURE__ */ new Set([incidentId]),
|
|
95376
95695
|
signalEventTypes: /* @__PURE__ */ new Set(),
|
|
95377
95696
|
traceIds: /* @__PURE__ */ new Set(),
|
|
95378
|
-
title: normalizedEvent.normalized_message,
|
|
95697
|
+
title: normalizedEvent.incident_title ?? normalizedEvent.normalized_message,
|
|
95379
95698
|
kind: "immediate",
|
|
95380
95699
|
severity: inferSeverity2(event, capturePreset)
|
|
95381
95700
|
};
|
|
@@ -95385,7 +95704,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95385
95704
|
aggregate.newEvents.push(event);
|
|
95386
95705
|
aggregate.signalEventTypes.add(event.event_type);
|
|
95387
95706
|
const traceId = getTraceId(event);
|
|
95388
|
-
if (traceId !== null) {
|
|
95707
|
+
if (traceId !== null && normalizedEvent.resource_type === void 0) {
|
|
95389
95708
|
aggregate.traceIds.add(traceId);
|
|
95390
95709
|
const traceCorrelationGroup = traceCorrelationGroups.get(traceId) ?? {
|
|
95391
95710
|
incidentIds: /* @__PURE__ */ new Set(),
|
|
@@ -95477,7 +95796,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
95477
95796
|
service_framework: latestSignalEvent.service.framework ?? existing?.service_framework ?? null,
|
|
95478
95797
|
environment: aggregate.environment,
|
|
95479
95798
|
fingerprint: aggregate.fingerprint,
|
|
95480
|
-
fingerprint_version: FINGERPRINT_VERSION,
|
|
95799
|
+
fingerprint_version: aggregate.kind === "request_anomaly" ? FINGERPRINT_VERSION : fingerprintVersion(normalizeEvent(latestSignalEvent)),
|
|
95481
95800
|
title: aggregate.title,
|
|
95482
95801
|
severity,
|
|
95483
95802
|
status: existingIncidents.some((incidentState) => incidentState.status === "resolved") ? "open" : existing?.status ?? "open",
|
|
@@ -107863,7 +108182,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
107863
108182
|
// package.json
|
|
107864
108183
|
var package_default = {
|
|
107865
108184
|
name: "@debugbundle/cli",
|
|
107866
|
-
version: "1.
|
|
108185
|
+
version: "1.9.0",
|
|
107867
108186
|
private: false,
|
|
107868
108187
|
description: "Command-line interface for DebugBundle",
|
|
107869
108188
|
license: "Apache-2.0",
|