@debugbundle/shared-types 1.7.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/browser-resource-context.d.ts +90 -0
  2. package/dist/browser-resource-context.d.ts.map +1 -0
  3. package/dist/browser-resource-context.js +23 -0
  4. package/dist/browser-resource-context.js.map +1 -0
  5. package/dist/browser-resource-routes.d.ts +40 -0
  6. package/dist/browser-resource-routes.d.ts.map +1 -0
  7. package/dist/browser-resource-routes.js +64 -0
  8. package/dist/browser-resource-routes.js.map +1 -0
  9. package/dist/browser-resource-suggestions.d.ts +8 -0
  10. package/dist/browser-resource-suggestions.d.ts.map +1 -0
  11. package/dist/browser-resource-suggestions.js +46 -0
  12. package/dist/browser-resource-suggestions.js.map +1 -0
  13. package/dist/browser-resource.d.ts +20 -0
  14. package/dist/browser-resource.d.ts.map +1 -0
  15. package/dist/browser-resource.js +116 -0
  16. package/dist/browser-resource.js.map +1 -0
  17. package/dist/capture-rule-evaluation.d.ts +6 -6
  18. package/dist/capture-rule-evaluation.d.ts.map +1 -1
  19. package/dist/capture-rule-evaluation.js +6 -2
  20. package/dist/capture-rule-evaluation.js.map +1 -1
  21. package/dist/capture-rule-schemas.d.ts +132 -132
  22. package/dist/capture-rule-suggestions.d.ts +60 -51
  23. package/dist/capture-rule-suggestions.d.ts.map +1 -1
  24. package/dist/capture-rule-suggestions.js +47 -115
  25. package/dist/capture-rule-suggestions.js.map +1 -1
  26. package/dist/event-envelope.d.ts +56 -56
  27. package/dist/frontend-severity.d.ts +6 -0
  28. package/dist/frontend-severity.d.ts.map +1 -0
  29. package/dist/frontend-severity.js +8 -0
  30. package/dist/frontend-severity.js.map +1 -0
  31. package/dist/index.d.ts +265 -86
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -0
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ export declare const BrowserResourceContextSchema: z.ZodObject<{
3
+ version: z.ZodLiteral<1>;
4
+ host: z.ZodNullable<z.ZodString>;
5
+ path: z.ZodString;
6
+ type: z.ZodNullable<z.ZodString>;
7
+ first_party: z.ZodNullable<z.ZodBoolean>;
8
+ role: z.ZodEnum<["analytics", "advertising", "tag_manager", "authentication", "application_asset", "unknown"]>;
9
+ provider: z.ZodNullable<z.ZodString>;
10
+ title: z.ZodString;
11
+ optional_candidate: z.ZodBoolean;
12
+ diagnosis: z.ZodString;
13
+ routes: z.ZodObject<{
14
+ items: z.ZodArray<z.ZodObject<{
15
+ route: z.ZodString;
16
+ occurrences: z.ZodNumber;
17
+ }, "strip", z.ZodTypeAny, {
18
+ route: string;
19
+ occurrences: number;
20
+ }, {
21
+ route: string;
22
+ occurrences: number;
23
+ }>, "many">;
24
+ recorded_occurrences: z.ZodNumber;
25
+ unattributed_occurrences: z.ZodNumber;
26
+ omitted_routes: z.ZodNumber;
27
+ coverage: z.ZodEnum<["occurrence_metadata", "retained_samples"]>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ items: {
30
+ route: string;
31
+ occurrences: number;
32
+ }[];
33
+ recorded_occurrences: number;
34
+ unattributed_occurrences: number;
35
+ omitted_routes: number;
36
+ coverage: "occurrence_metadata" | "retained_samples";
37
+ }, {
38
+ items: {
39
+ route: string;
40
+ occurrences: number;
41
+ }[];
42
+ recorded_occurrences: number;
43
+ unattributed_occurrences: number;
44
+ omitted_routes: number;
45
+ coverage: "occurrence_metadata" | "retained_samples";
46
+ }>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ path: string;
49
+ type: string | null;
50
+ title: string;
51
+ routes: {
52
+ items: {
53
+ route: string;
54
+ occurrences: number;
55
+ }[];
56
+ recorded_occurrences: number;
57
+ unattributed_occurrences: number;
58
+ omitted_routes: number;
59
+ coverage: "occurrence_metadata" | "retained_samples";
60
+ };
61
+ version: 1;
62
+ host: string | null;
63
+ first_party: boolean | null;
64
+ role: "unknown" | "analytics" | "advertising" | "tag_manager" | "authentication" | "application_asset";
65
+ provider: string | null;
66
+ optional_candidate: boolean;
67
+ diagnosis: string;
68
+ }, {
69
+ path: string;
70
+ type: string | null;
71
+ title: string;
72
+ routes: {
73
+ items: {
74
+ route: string;
75
+ occurrences: number;
76
+ }[];
77
+ recorded_occurrences: number;
78
+ unattributed_occurrences: number;
79
+ omitted_routes: number;
80
+ coverage: "occurrence_metadata" | "retained_samples";
81
+ };
82
+ version: 1;
83
+ host: string | null;
84
+ first_party: boolean | null;
85
+ role: "unknown" | "analytics" | "advertising" | "tag_manager" | "authentication" | "application_asset";
86
+ provider: string | null;
87
+ optional_candidate: boolean;
88
+ diagnosis: string;
89
+ }>;
90
+ //# sourceMappingURL=browser-resource-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-context.d.ts","sourceRoot":"","sources":["../src/browser-resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBvC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ import { BrowserResourceRoutesSchema } from "./browser-resource-routes.js";
3
+ export const BrowserResourceContextSchema = z.object({
4
+ version: z.literal(1),
5
+ host: z.string().max(255).nullable(),
6
+ path: z.string().max(1024),
7
+ type: z.string().nullable(),
8
+ first_party: z.boolean().nullable(),
9
+ role: z.enum([
10
+ "analytics",
11
+ "advertising",
12
+ "tag_manager",
13
+ "authentication",
14
+ "application_asset",
15
+ "unknown"
16
+ ]),
17
+ provider: z.string().nullable(),
18
+ title: z.string(),
19
+ optional_candidate: z.boolean(),
20
+ diagnosis: z.string(),
21
+ routes: BrowserResourceRoutesSchema
22
+ });
23
+ //# sourceMappingURL=browser-resource-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-context.js","sourceRoot":"","sources":["../src/browser-resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAE3E,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QACX,WAAW;QACX,aAAa;QACb,aAAa;QACb,gBAAgB;QAChB,mBAAmB;QACnB,SAAS;KACV,CAAC;IACF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,2BAA2B;CACpC,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ export declare const BrowserResourceRoutesSchema: z.ZodObject<{
3
+ items: z.ZodArray<z.ZodObject<{
4
+ route: z.ZodString;
5
+ occurrences: z.ZodNumber;
6
+ }, "strip", z.ZodTypeAny, {
7
+ route: string;
8
+ occurrences: number;
9
+ }, {
10
+ route: string;
11
+ occurrences: number;
12
+ }>, "many">;
13
+ recorded_occurrences: z.ZodNumber;
14
+ unattributed_occurrences: z.ZodNumber;
15
+ omitted_routes: z.ZodNumber;
16
+ coverage: z.ZodEnum<["occurrence_metadata", "retained_samples"]>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ items: {
19
+ route: string;
20
+ occurrences: number;
21
+ }[];
22
+ recorded_occurrences: number;
23
+ unattributed_occurrences: number;
24
+ omitted_routes: number;
25
+ coverage: "occurrence_metadata" | "retained_samples";
26
+ }, {
27
+ items: {
28
+ route: string;
29
+ occurrences: number;
30
+ }[];
31
+ recorded_occurrences: number;
32
+ unattributed_occurrences: number;
33
+ omitted_routes: number;
34
+ coverage: "occurrence_metadata" | "retained_samples";
35
+ }>;
36
+ export type BrowserResourceRoutes = z.infer<typeof BrowserResourceRoutesSchema>;
37
+ /** Strip query/fragment and normalize recognizable dynamic segments before retaining route context. */
38
+ export declare function normalizeResourceRoute(value: unknown): string | null;
39
+ export declare function summarizeResourceRoutes(routes: readonly (string | null)[], occurrenceCount: number): BrowserResourceRoutes;
40
+ //# sourceMappingURL=browser-resource-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-routes.d.ts","sourceRoot":"","sources":["../src/browser-resource-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,uGAAuG;AACvG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CA+BpE;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EAClC,eAAe,EAAE,MAAM,GACtB,qBAAqB,CAoBvB"}
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ export const BrowserResourceRoutesSchema = z.object({
3
+ items: z
4
+ .array(z.object({ route: z.string().max(1024), occurrences: z.number().int().positive() }))
5
+ .max(20),
6
+ recorded_occurrences: z.number().int().nonnegative(),
7
+ unattributed_occurrences: z.number().int().nonnegative(),
8
+ omitted_routes: z.number().int().nonnegative(),
9
+ coverage: z.enum(["occurrence_metadata", "retained_samples"])
10
+ });
11
+ /** Strip query/fragment and normalize recognizable dynamic segments before retaining route context. */
12
+ export function normalizeResourceRoute(value) {
13
+ if (typeof value !== "string" ||
14
+ !value.startsWith("/") ||
15
+ value.startsWith("//") ||
16
+ value.length > 4096)
17
+ return null;
18
+ const path = value.split(/[?#]/, 1)[0];
19
+ if (/[\u0000-\u0020\u007f\\]/.test(path))
20
+ return null;
21
+ const segments = path
22
+ .split("/")
23
+ .filter(Boolean)
24
+ .map((segment) => {
25
+ let decoded;
26
+ try {
27
+ decoded = decodeURIComponent(segment);
28
+ }
29
+ catch {
30
+ return "{param}";
31
+ }
32
+ if (decoded === "{param}" || /^:[A-Za-z_][A-Za-z_0-9]*$/.test(decoded))
33
+ return "{param}";
34
+ return /^\d+$/.test(decoded) ||
35
+ /^[a-f0-9-]{16,}$/i.test(decoded) ||
36
+ /^[A-Za-z0-9_-]{24,}$/.test(decoded) ||
37
+ (decoded.length >= 16 && /[A-Za-z]/.test(decoded) && /\d/.test(decoded)) ||
38
+ /[@/\\\u0000-\u0020\u007f]/.test(decoded)
39
+ ? "{param}"
40
+ : segment;
41
+ });
42
+ const route = `/${segments.join("/")}`;
43
+ return route.length <= 1024 ? route : null;
44
+ }
45
+ export function summarizeResourceRoutes(routes, occurrenceCount) {
46
+ const counts = new Map();
47
+ for (const raw of routes) {
48
+ const route = normalizeResourceRoute(raw);
49
+ if (route !== null)
50
+ counts.set(route, (counts.get(route) ?? 0) + 1);
51
+ }
52
+ const items = [...counts]
53
+ .map(([route, occurrences]) => ({ route, occurrences }))
54
+ .sort((a, b) => b.occurrences - a.occurrences || (a.route < b.route ? -1 : a.route > b.route ? 1 : 0));
55
+ const recorded = items.reduce((total, item) => total + item.occurrences, 0);
56
+ return {
57
+ items: items.slice(0, 20),
58
+ recorded_occurrences: recorded,
59
+ unattributed_occurrences: Math.max(0, occurrenceCount - recorded),
60
+ omitted_routes: Math.max(0, items.length - 20),
61
+ coverage: "retained_samples"
62
+ };
63
+ }
64
+ //# sourceMappingURL=browser-resource-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-routes.js","sourceRoot":"","sources":["../src/browser-resource-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,KAAK,EAAE,CAAC;SACL,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;SAC1F,GAAG,CAAC,EAAE,CAAC;IACV,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACpD,wBAAwB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACxD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC9C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;CAC9D,CAAC,CAAC;AAGH,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,KAAK,CAAC,UAAU,CAAC,IAAI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AG,EAAE,CAAC;QAC9C,QAAQ,EAAE,kBAAkB;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CaptureRuleSuggestion, CaptureRuleSuggestionIncident } from "./capture-rule-suggestions.js";
2
+ export declare function buildBrowserResourceSuggestions(input: {
3
+ browserEvent: unknown;
4
+ service: string | undefined;
5
+ environment: string | undefined;
6
+ incident: CaptureRuleSuggestionIncident;
7
+ }): CaptureRuleSuggestion[];
8
+ //# sourceMappingURL=browser-resource-suggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-suggestions.d.ts","sourceRoot":"","sources":["../src/browser-resource-suggestions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,6BAA6B,CAAC;CACzC,GAAG,qBAAqB,EAAE,CA+C1B"}
@@ -0,0 +1,46 @@
1
+ import { describeBrowserResource } from "./browser-resource.js";
2
+ export function buildBrowserResourceSuggestions(input) {
3
+ const resource = describeBrowserResource(input.browserEvent);
4
+ if (!resource?.optional_candidate ||
5
+ resource.host === null ||
6
+ input.service === undefined ||
7
+ input.environment === undefined)
8
+ return [];
9
+ const { service, environment } = input;
10
+ const { host } = resource;
11
+ return ["demote", "drop"].map((action) => ({
12
+ suggestion_id: action === "demote" ? "resource_context" : "resource_drop",
13
+ label: action === "demote"
14
+ ? `Keep ${resource.provider} failures as context`
15
+ : `Stop capturing ${resource.provider} failures`,
16
+ recommended_action: action,
17
+ confidence: "medium",
18
+ reason: action === "demote"
19
+ ? "If this dependency is optional for your app, retain future matching events as context without opening incidents, alerts or automation. Context may still count toward paid usage."
20
+ : "Only use this if this dependency is optional and future matching failures have no diagnostic value. Matching events will be discarded; existing incidents and artifacts are unchanged.",
21
+ requires_confirmation: true,
22
+ created_rule_id: null,
23
+ created_rule_enabled: null,
24
+ rule: {
25
+ name: `${action === "demote" ? "Keep as context" : "Stop capturing"}: ${resource.provider}`,
26
+ description: "Operator-approved resource-specific browser noise policy.",
27
+ enabled: true,
28
+ action,
29
+ matcher: {
30
+ event_types: ["frontend_exception"],
31
+ browser_event_kind: "resource_error",
32
+ browser_event_opaque: true,
33
+ services: [service],
34
+ environments: [environment],
35
+ resource_url: { host, path_equals: resource.path }
36
+ },
37
+ sample_rate: null,
38
+ sample_event_class: null,
39
+ created_by_user_id: null,
40
+ created_from_incident_id: input.incident.incident_id,
41
+ created_from_event_id: null,
42
+ expires_at: null
43
+ }
44
+ }));
45
+ }
46
+ //# sourceMappingURL=browser-resource-suggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource-suggestions.js","sourceRoot":"","sources":["../src/browser-resource-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMhE,MAAM,UAAU,+BAA+B,CAAC,KAK/C;IACC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7D,IACE,CAAC,QAAQ,EAAE,kBAAkB;QAC7B,QAAQ,CAAC,IAAI,KAAK,IAAI;QACtB,KAAK,CAAC,OAAO,KAAK,SAAS;QAC3B,KAAK,CAAC,WAAW,KAAK,SAAS;QAE/B,OAAO,EAAE,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAC1B,OAAQ,CAAC,QAAQ,EAAE,MAAM,CAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACpD,aAAa,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,eAAe;QACzE,KAAK,EACH,MAAM,KAAK,QAAQ;YACjB,CAAC,CAAC,QAAQ,QAAQ,CAAC,QAAQ,sBAAsB;YACjD,CAAC,CAAC,kBAAkB,QAAQ,CAAC,QAAQ,WAAW;QACpD,kBAAkB,EAAE,MAAM;QAC1B,UAAU,EAAE,QAAQ;QACpB,MAAM,EACJ,MAAM,KAAK,QAAQ;YACjB,CAAC,CAAC,mLAAmL;YACrL,CAAC,CAAC,wLAAwL;QAC9L,qBAAqB,EAAE,IAAI;QAC3B,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,IAAI;QAC1B,IAAI,EAAE;YACJ,IAAI,EAAE,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,KAAK,QAAQ,CAAC,QAAQ,EAAE;YAC3F,WAAW,EAAE,2DAA2D;YACxE,OAAO,EAAE,IAAI;YACb,MAAM;YACN,OAAO,EAAE;gBACP,WAAW,EAAE,CAAC,oBAAoB,CAAC;gBACnC,kBAAkB,EAAE,gBAAgB;gBACpC,oBAAoB,EAAE,IAAI;gBAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC;gBACnB,YAAY,EAAE,CAAC,WAAW,CAAC;gBAC3B,YAAY,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE;aACnD;YACD,WAAW,EAAE,IAAI;YACjB,kBAAkB,EAAE,IAAI;YACxB,kBAAkB,EAAE,IAAI;YACxB,wBAAwB,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;YACpD,qBAAqB,EAAE,IAAI;YAC3B,UAAU,EAAE,IAAI;SACjB;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** Resource identity is evidence; dependency importance and failure cause are separate decisions. */
2
+ export interface BrowserResource {
3
+ host: string | null;
4
+ path: string;
5
+ type: string | null;
6
+ first_party: boolean | null;
7
+ role: "analytics" | "advertising" | "tag_manager" | "authentication" | "application_asset" | "unknown";
8
+ provider: string | null;
9
+ title: string;
10
+ optional_candidate: boolean;
11
+ }
12
+ /** Resolve against the browser page, never a backend relay host. Missing origin stays unknown. */
13
+ export declare function browserResourceLocation(source: unknown, page: unknown): {
14
+ host: string | null;
15
+ path: string;
16
+ first_party: boolean | null;
17
+ } | null;
18
+ export declare function describeBrowserResource(value: unknown): BrowserResource | null;
19
+ export declare function browserResourceDiagnosis(resource: BrowserResource | null): string;
20
+ //# sourceMappingURL=browser-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource.d.ts","sourceRoot":"","sources":["../src/browser-resource.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,IAAI,EACA,WAAW,GACX,aAAa,GACb,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,SAAS,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAwBD,kGAAkG;AAClG,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,OAAO,GACZ;IACD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B,GAAG,IAAI,CAuBP;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAqE9E;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,CAIjF"}
@@ -0,0 +1,116 @@
1
+ function record(value) {
2
+ return value !== null && typeof value === "object" && !Array.isArray(value)
3
+ ? value
4
+ : null;
5
+ }
6
+ function httpUrl(value, base) {
7
+ if (typeof value !== "string" ||
8
+ value.length === 0 ||
9
+ value.length > 4096 ||
10
+ /[\u0000-\u0020\u007f]/.test(value))
11
+ return null;
12
+ try {
13
+ const url = base === undefined ? new URL(value) : new URL(value, base);
14
+ return url.protocol === "http:" || url.protocol === "https:" ? url : null;
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ /** Resolve against the browser page, never a backend relay host. Missing origin stays unknown. */
21
+ export function browserResourceLocation(source, page) {
22
+ if (typeof source !== "string")
23
+ return null;
24
+ const pageUrl = httpUrl(page);
25
+ const url = httpUrl(source, pageUrl ?? undefined);
26
+ if (url !== null) {
27
+ if (url.pathname.length > 1024 || url.hostname.length > 255)
28
+ return null;
29
+ return {
30
+ host: url.hostname.toLowerCase(),
31
+ path: url.pathname || "/",
32
+ first_party: pageUrl === null ? null : url.origin === pageUrl.origin
33
+ };
34
+ }
35
+ // A root-relative URL is useful context, but without a page origin it cannot identify a host.
36
+ if (source.startsWith("/") &&
37
+ !source.startsWith("//") &&
38
+ !source.includes("\\") &&
39
+ !/[\u0000-\u0020\u007f]/.test(source)) {
40
+ const path = source.split(/[?#]/, 1)[0];
41
+ if (path.length <= 1024)
42
+ return { host: null, path, first_party: true };
43
+ }
44
+ return null;
45
+ }
46
+ export function describeBrowserResource(value) {
47
+ const event = record(value);
48
+ if (event?.["kind"] !== "resource_error")
49
+ return null;
50
+ const target = record(event["target"]);
51
+ const page = record(event["page"]);
52
+ const location = browserResourceLocation(target?.["source_url"] ?? event["file_name"], page?.["url"]);
53
+ if (location === null)
54
+ return null;
55
+ const tag = typeof target?.["tag_name"] === "string" ? target["tag_name"].toLowerCase() : null;
56
+ const type = tag !== null &&
57
+ [
58
+ "script",
59
+ "link",
60
+ "img",
61
+ "audio",
62
+ "video",
63
+ "source",
64
+ "iframe",
65
+ "object",
66
+ "embed",
67
+ "input"
68
+ ].includes(tag)
69
+ ? tag
70
+ : null;
71
+ let role = location.first_party === true ? "application_asset" : "unknown";
72
+ let provider = null;
73
+ if (type === "script") {
74
+ if (location.host === "www.googletagmanager.com" && location.path === "/gtm.js") {
75
+ provider = "Google Tag Manager";
76
+ role = "tag_manager";
77
+ }
78
+ else if (location.host === "connect.facebook.net" &&
79
+ /^\/[a-z]{2}_[A-Z]{2}\/fbevents\.js$/.test(location.path)) {
80
+ provider = "Meta Pixel";
81
+ role = "advertising";
82
+ }
83
+ else if (location.host === "www.clarity.ms" && /^\/tag\/[A-Za-z0-9]+$/.test(location.path)) {
84
+ provider = "Microsoft Clarity";
85
+ role = "analytics";
86
+ }
87
+ else if (location.host === "accounts.google.com" && location.path === "/gsi/client") {
88
+ provider = "Google sign-in";
89
+ role = "authentication";
90
+ }
91
+ }
92
+ const file = location.path.split("/").filter(Boolean).at(-1) ?? location.path;
93
+ const kind = type === "img"
94
+ ? "Image"
95
+ : type === "script" || /\.m?js$/i.test(file)
96
+ ? "JavaScript asset"
97
+ : "Resource";
98
+ return {
99
+ ...location,
100
+ type,
101
+ role,
102
+ provider,
103
+ title: provider !== null
104
+ ? `${provider} script failed to load`
105
+ : `${kind} failed to load: ${file}${location.host === null ? "" : ` (${location.host})`}`,
106
+ optional_candidate: event["opaque"] === true &&
107
+ location.first_party !== true &&
108
+ ["analytics", "advertising", "tag_manager"].includes(role)
109
+ };
110
+ }
111
+ export function browserResourceDiagnosis(resource) {
112
+ return resource?.optional_candidate === true
113
+ ? "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."
114
+ : "The browser reported that this resource failed to load. The captured event does not identify the cause or establish whether application functionality was affected.";
115
+ }
116
+ //# sourceMappingURL=browser-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-resource.js","sourceRoot":"","sources":["../src/browser-resource.ts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aptureRuleEvaluationContextSchema: z.ZodObject<{
70
70
  event_id: string;
71
71
  project_id: string;
72
72
  runtime: "unknown" | "browser" | "node" | "python" | "php" | "java" | "go" | "ruby";
73
- event_type: "backend_exception" | "frontend_exception" | "deploy_metadata" | "error_suppressed" | "log_event" | "request_event" | "frontend_breadcrumb" | "probe_event";
73
+ event_type: "backend_exception" | "request_event" | "log_event" | "frontend_breadcrumb" | "frontend_exception" | "deploy_metadata" | "error_suppressed" | "probe_event";
74
74
  message?: string | undefined;
75
75
  service?: string | undefined;
76
76
  environment?: string | undefined;
77
- status_code?: number | undefined;
78
77
  first_party?: boolean | undefined;
79
78
  error_name?: string | undefined;
80
- browser_event_kind?: "window_error" | "resource_error" | undefined;
79
+ browser_event_kind?: "resource_error" | "window_error" | undefined;
81
80
  browser_event_opaque?: boolean | undefined;
82
81
  client_kind?: "unknown" | "human" | "bot" | undefined;
83
82
  bot_family?: string | undefined;
@@ -93,6 +92,7 @@ export declare const CaptureRuleEvaluationContextSchema: z.ZodObject<{
93
92
  value: string;
94
93
  version: string;
95
94
  } | undefined;
95
+ status_code?: number | undefined;
96
96
  fingerprint_aliases?: {
97
97
  value: string;
98
98
  version: string;
@@ -101,14 +101,13 @@ export declare const CaptureRuleEvaluationContextSchema: z.ZodObject<{
101
101
  event_id: string;
102
102
  project_id: string;
103
103
  runtime: "unknown" | "browser" | "node" | "python" | "php" | "java" | "go" | "ruby";
104
- event_type: "backend_exception" | "frontend_exception" | "deploy_metadata" | "error_suppressed" | "log_event" | "request_event" | "frontend_breadcrumb" | "probe_event";
104
+ event_type: "backend_exception" | "request_event" | "log_event" | "frontend_breadcrumb" | "frontend_exception" | "deploy_metadata" | "error_suppressed" | "probe_event";
105
105
  message?: string | undefined;
106
106
  service?: string | undefined;
107
107
  environment?: string | undefined;
108
- status_code?: number | undefined;
109
108
  first_party?: boolean | undefined;
110
109
  error_name?: string | undefined;
111
- browser_event_kind?: "window_error" | "resource_error" | undefined;
110
+ browser_event_kind?: "resource_error" | "window_error" | undefined;
112
111
  browser_event_opaque?: boolean | undefined;
113
112
  client_kind?: "unknown" | "human" | "bot" | undefined;
114
113
  bot_family?: string | undefined;
@@ -124,6 +123,7 @@ export declare const CaptureRuleEvaluationContextSchema: z.ZodObject<{
124
123
  value: string;
125
124
  version: string;
126
125
  } | undefined;
126
+ status_code?: number | undefined;
127
127
  fingerprint_aliases?: {
128
128
  value: string;
129
129
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"capture-rule-evaluation.d.ts","sourceRoot":"","sources":["../src/capture-rule-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAE3B,KAAK,2BAA2B,EAEjC,MAAM,2BAA2B,CAAC;AAEnC,QAAA,MAAM,8BAA8B;;;;;;;;;EAGlC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,aAAa,CAAC;IAC1D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kBAAkB,EAAE,2BAA2B,GAAG,IAAI,CAAC;CACxD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,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAWV;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,4BAA4B,EAC1C,GAAG,EAAE,MAAM,GACV,2BAA2B,GAAG,IAAI,CA8CpC"}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { browserResourceLocation } from "./browser-resource.js";
2
3
  import { BrowserEventKindSchema, CaptureRuleClientKindSchema, CaptureRuleEventTypeSchema, CaptureRuleFingerprintSchema, CaptureRuleRuntimeSchema, } from "./capture-rule-schemas.js";
3
4
  const CaptureRuleEvaluationUrlSchema = z.object({
4
5
  host: z.string().min(1).transform((value) => value.toLowerCase()).optional(),
@@ -209,16 +210,19 @@ export function buildCaptureRuleEvaluationContext(input) {
209
210
  ? browserEvent["file_name"]
210
211
  : undefined;
211
212
  const resourceUrl = normalizeEvaluationUrl(resourceSource);
213
+ const resourceLocation = browserResourceLocation(resourceSource, readRecord(browserEvent?.["page"])?.["url"]);
212
214
  return CaptureRuleEvaluationContextSchema.parse({
213
215
  ...context,
214
- ...(resourceUrl.first_party === undefined ? {} : { first_party: resourceUrl.first_party }),
216
+ ...(resourceLocation?.first_party == null ? {} : { first_party: resourceLocation.first_party }),
215
217
  error_name: readString(input.event.payload["name"]),
216
218
  message: readString(input.event.payload["message"]),
217
219
  browser_event_kind: browserEventKind === "window_error" || browserEventKind === "resource_error"
218
220
  ? browserEventKind
219
221
  : undefined,
220
222
  browser_event_opaque: typeof browserEvent?.["opaque"] === "boolean" ? browserEvent["opaque"] : undefined,
221
- resource_url: resourceUrl.url,
223
+ resource_url: resourceLocation === null ? resourceUrl.url : {
224
+ ...(resourceLocation.host === null ? {} : { host: resourceLocation.host }), path: resourceLocation.path
225
+ },
222
226
  });
223
227
  }
224
228
  case "frontend_breadcrumb": {