@genesislcap/foundation-utils 15.55.0 → 15.57.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/custom-elements.json +53 -53
- package/dist/dts/error-monitoring/error-monitoring.d.ts +77 -9
- package/dist/dts/error-monitoring/error-monitoring.d.ts.map +1 -1
- package/dist/esm/error-monitoring/error-monitoring.js +105 -11
- package/dist/foundation-utils.api.json +760 -14
- package/dist/foundation-utils.d.ts +80 -9
- package/package.json +9 -9
|
@@ -681,59 +681,6 @@
|
|
|
681
681
|
}
|
|
682
682
|
]
|
|
683
683
|
},
|
|
684
|
-
{
|
|
685
|
-
"kind": "javascript-module",
|
|
686
|
-
"path": "src/decorators/index.ts",
|
|
687
|
-
"declarations": [],
|
|
688
|
-
"exports": [
|
|
689
|
-
{
|
|
690
|
-
"kind": "js",
|
|
691
|
-
"name": "*",
|
|
692
|
-
"declaration": {
|
|
693
|
-
"name": "*",
|
|
694
|
-
"package": "./renderOnChange"
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
]
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
"kind": "javascript-module",
|
|
701
|
-
"path": "src/decorators/renderOnChange.ts",
|
|
702
|
-
"declarations": [
|
|
703
|
-
{
|
|
704
|
-
"kind": "function",
|
|
705
|
-
"name": "renderOnChange",
|
|
706
|
-
"parameters": [
|
|
707
|
-
{
|
|
708
|
-
"name": "target",
|
|
709
|
-
"type": {
|
|
710
|
-
"text": "FASTElement & { render(): void }"
|
|
711
|
-
},
|
|
712
|
-
"description": "The target to define the property change handler on."
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
"name": "name",
|
|
716
|
-
"type": {
|
|
717
|
-
"text": "string"
|
|
718
|
-
},
|
|
719
|
-
"description": "The property name."
|
|
720
|
-
}
|
|
721
|
-
],
|
|
722
|
-
"description": "Defines a property changed handler that calls a render() method on the target as an internal observation enhancement.",
|
|
723
|
-
"privacy": "public"
|
|
724
|
-
}
|
|
725
|
-
],
|
|
726
|
-
"exports": [
|
|
727
|
-
{
|
|
728
|
-
"kind": "js",
|
|
729
|
-
"name": "renderOnChange",
|
|
730
|
-
"declaration": {
|
|
731
|
-
"name": "renderOnChange",
|
|
732
|
-
"module": "src/decorators/renderOnChange.ts"
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
]
|
|
736
|
-
},
|
|
737
684
|
{
|
|
738
685
|
"kind": "javascript-module",
|
|
739
686
|
"path": "src/encoding/index.ts",
|
|
@@ -1248,6 +1195,59 @@
|
|
|
1248
1195
|
}
|
|
1249
1196
|
]
|
|
1250
1197
|
},
|
|
1198
|
+
{
|
|
1199
|
+
"kind": "javascript-module",
|
|
1200
|
+
"path": "src/decorators/index.ts",
|
|
1201
|
+
"declarations": [],
|
|
1202
|
+
"exports": [
|
|
1203
|
+
{
|
|
1204
|
+
"kind": "js",
|
|
1205
|
+
"name": "*",
|
|
1206
|
+
"declaration": {
|
|
1207
|
+
"name": "*",
|
|
1208
|
+
"package": "./renderOnChange"
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
]
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
"kind": "javascript-module",
|
|
1215
|
+
"path": "src/decorators/renderOnChange.ts",
|
|
1216
|
+
"declarations": [
|
|
1217
|
+
{
|
|
1218
|
+
"kind": "function",
|
|
1219
|
+
"name": "renderOnChange",
|
|
1220
|
+
"parameters": [
|
|
1221
|
+
{
|
|
1222
|
+
"name": "target",
|
|
1223
|
+
"type": {
|
|
1224
|
+
"text": "FASTElement & { render(): void }"
|
|
1225
|
+
},
|
|
1226
|
+
"description": "The target to define the property change handler on."
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"name": "name",
|
|
1230
|
+
"type": {
|
|
1231
|
+
"text": "string"
|
|
1232
|
+
},
|
|
1233
|
+
"description": "The property name."
|
|
1234
|
+
}
|
|
1235
|
+
],
|
|
1236
|
+
"description": "Defines a property changed handler that calls a render() method on the target as an internal observation enhancement.",
|
|
1237
|
+
"privacy": "public"
|
|
1238
|
+
}
|
|
1239
|
+
],
|
|
1240
|
+
"exports": [
|
|
1241
|
+
{
|
|
1242
|
+
"kind": "js",
|
|
1243
|
+
"name": "renderOnChange",
|
|
1244
|
+
"declaration": {
|
|
1245
|
+
"name": "renderOnChange",
|
|
1246
|
+
"module": "src/decorators/renderOnChange.ts"
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
]
|
|
1250
|
+
},
|
|
1251
1251
|
{
|
|
1252
1252
|
"kind": "javascript-module",
|
|
1253
1253
|
"path": "src/error/errorMap.ts",
|
|
@@ -28,6 +28,34 @@ export interface ErrorMonitoringBreadcrumb {
|
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
30
|
export type ErrorMonitoringBreadcrumbHint = Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* An event about to be sent, with the page it happened on.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export interface ErrorMonitoringEvent {
|
|
36
|
+
request?: {
|
|
37
|
+
url?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A tracing span about to be sent: its `attributes` when spans are streamed, or its `data` inside a
|
|
42
|
+
* transaction.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export interface ErrorMonitoringSpan {
|
|
46
|
+
name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
op?: string;
|
|
49
|
+
attributes?: Record<string, unknown>;
|
|
50
|
+
data?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* An SDK integration, such as one of Sentry's default integrations.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export interface ErrorMonitoringIntegration {
|
|
57
|
+
name: string;
|
|
58
|
+
}
|
|
31
59
|
/**
|
|
32
60
|
* Options {@link setupErrorMonitoring} passes to the client's `init`.
|
|
33
61
|
*
|
|
@@ -38,8 +66,22 @@ export type ErrorMonitoringBreadcrumbHint = Record<string, unknown>;
|
|
|
38
66
|
export interface ErrorMonitoringInitOptions {
|
|
39
67
|
dsn: string;
|
|
40
68
|
environment: string;
|
|
41
|
-
/**
|
|
69
|
+
/** Turns off Sentry 11's user info, cookies, headers but `User-Agent`, bodies and URL queries. */
|
|
70
|
+
dataCollection: Record<string, unknown>;
|
|
71
|
+
/** Keeps only the SDK's default integrations that send nothing from the page, plus the app's. */
|
|
72
|
+
integrations: <I extends ErrorMonitoringIntegration>(defaults: I[]) => I[];
|
|
73
|
+
/** Drops console, click and input breadcrumbs, and strips queries and fragments from URLs. */
|
|
42
74
|
beforeBreadcrumb?: <B extends ErrorMonitoringBreadcrumb>(breadcrumb: B, hint?: ErrorMonitoringBreadcrumbHint) => B | null;
|
|
75
|
+
/** Strips the query string and fragment from the page URL. */
|
|
76
|
+
beforeSend: <E extends ErrorMonitoringEvent>(event: E, hint?: unknown) => E | null | PromiseLike<E | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Strips the query string and fragment from the page URL on transactions. Set only with
|
|
79
|
+
* `traceLifecycle: 'static'`: streamed spans, Sentry 11's default, send no transactions, and
|
|
80
|
+
* Sentry warns on every page load when the option is set without them.
|
|
81
|
+
*/
|
|
82
|
+
beforeSendTransaction?: <E extends ErrorMonitoringEvent>(event: E, hint?: unknown) => E | null | PromiseLike<E | null>;
|
|
83
|
+
/** Strips queries and fragments from span URLs and resource span names, when tracing is on. */
|
|
84
|
+
beforeSendSpan: <S extends ErrorMonitoringSpan>(span: S) => S;
|
|
43
85
|
[key: string]: unknown;
|
|
44
86
|
}
|
|
45
87
|
/**
|
|
@@ -47,8 +89,24 @@ export interface ErrorMonitoringInitOptions {
|
|
|
47
89
|
* @public
|
|
48
90
|
*/
|
|
49
91
|
export interface ErrorMonitoringExtraInitOptions {
|
|
92
|
+
/**
|
|
93
|
+
* Merged over the defaults, which turn off user info, cookies, headers other than `User-Agent`,
|
|
94
|
+
* bodies and URL query strings. Other settings keep the SDK's defaults.
|
|
95
|
+
*/
|
|
96
|
+
dataCollection?: Record<string, unknown>;
|
|
97
|
+
/**
|
|
98
|
+
* Added to the default integrations that are kept, replacing any of the same name. A function
|
|
99
|
+
* receives those kept defaults instead and returns the full list.
|
|
100
|
+
*/
|
|
101
|
+
integrations?: ErrorMonitoringIntegration[] | ((defaults: ErrorMonitoringIntegration[]) => ErrorMonitoringIntegration[]);
|
|
50
102
|
/** Runs after the built-in filter, for breadcrumbs it keeps, with the SDK's hint. */
|
|
51
103
|
beforeBreadcrumb?: (breadcrumb: ErrorMonitoringBreadcrumb, hint?: ErrorMonitoringBreadcrumbHint) => ErrorMonitoringBreadcrumb | null;
|
|
104
|
+
/** Runs after the page URL's query string and fragment are stripped, with the SDK's hint. */
|
|
105
|
+
beforeSend?(event: ErrorMonitoringEvent, hint?: unknown): ErrorMonitoringEvent | null | PromiseLike<ErrorMonitoringEvent | null>;
|
|
106
|
+
/** Like `beforeSend`, for transactions. Wrapped only with `traceLifecycle: 'static'`. */
|
|
107
|
+
beforeSendTransaction?(event: ErrorMonitoringEvent, hint?: unknown): ErrorMonitoringEvent | null | PromiseLike<ErrorMonitoringEvent | null>;
|
|
108
|
+
/** Runs after span URLs and resource span names lose their query string and fragment. */
|
|
109
|
+
beforeSendSpan?(span: ErrorMonitoringSpan): ErrorMonitoringSpan;
|
|
52
110
|
[key: string]: unknown;
|
|
53
111
|
}
|
|
54
112
|
/**
|
|
@@ -84,9 +142,12 @@ export interface ErrorMonitoringOptions {
|
|
|
84
142
|
* and shared (`100.64.0.0/10`, as Tailscale uses) IP addresses, IPv4-mapped IPv6 included.
|
|
85
143
|
*/
|
|
86
144
|
environment?: string | ErrorMonitoringEnvironmentResolver;
|
|
87
|
-
/** Extra options
|
|
145
|
+
/** Extra options for the client's `init`, combined with the defaults as each one describes. */
|
|
88
146
|
initOptions?: ErrorMonitoringExtraInitOptions;
|
|
89
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Initialises the client in place of calling `client.init`. Set `traceLifecycle` in
|
|
149
|
+
* `initOptions`, not here: the defaults for tracing depend on it.
|
|
150
|
+
*/
|
|
90
151
|
init?: (options: ErrorMonitoringInitOptions) => unknown;
|
|
91
152
|
/** Records non-error foundation logs as breadcrumbs. Defaults to `true`. */
|
|
92
153
|
breadcrumbs?: boolean;
|
|
@@ -134,12 +195,18 @@ export declare const isFoundationLoggerConsoleBreadcrumb: (breadcrumb: ErrorMoni
|
|
|
134
195
|
* @remarks
|
|
135
196
|
* Without a DSN, or when no environment applies (by default on local hosts such as `localhost` or
|
|
136
197
|
* a private IP address), it does nothing and resolves `false`. The environment defaults to the
|
|
137
|
-
* page's hostname, so one image promoted across environments reports each under its own name
|
|
138
|
-
*
|
|
198
|
+
* page's hostname, so one image promoted across environments reports each under its own name. To
|
|
199
|
+
* use names such as `uat`, read one the deployment sets rather than listing hostnames, which would
|
|
200
|
+
* show everyone who loads the bundle where the other environments are. Otherwise it:
|
|
139
201
|
*
|
|
140
|
-
* - initialises the client (`client.init`, or `options.init`) with the DSN, environment,
|
|
141
|
-
* `
|
|
142
|
-
*
|
|
202
|
+
* - initialises the client (`client.init`, or `options.init`) with the DSN, the environment, any
|
|
203
|
+
* `initOptions`, and defaults that keep page data out of what the SDK collects by itself: Sentry
|
|
204
|
+
* 11's `dataCollection` off for user info, cookies, headers but `User-Agent`, bodies and URL
|
|
205
|
+
* queries; only the default integrations that send nothing from the page (so not `Console`); no
|
|
206
|
+
* console, click or input breadcrumbs; and no query strings or fragments in breadcrumb URLs, the
|
|
207
|
+
* page URL, or span URLs and resource span names when tracing is on. The app's
|
|
208
|
+
* `beforeBreadcrumb`, `beforeSend`, `beforeSendTransaction` and `beforeSendSpan` run after
|
|
209
|
+
* these, and its `integrations` are added;
|
|
143
210
|
* - registers a global log reporter ({@link createErrorMonitoringReporter}), so errors logged by
|
|
144
211
|
* every foundation logger, including those Genesis packages create at import time, are reported,
|
|
145
212
|
* and other logs become breadcrumbs. Only log messages and exceptions are sent, never logged data.
|
|
@@ -164,7 +231,8 @@ export declare const isFoundationLoggerConsoleBreadcrumb: (breadcrumb: ErrorMoni
|
|
|
164
231
|
*
|
|
165
232
|
* setupErrorMonitoring(Sentry, {
|
|
166
233
|
* dsn: 'https://<key>@<org>.ingest.sentry.io/<project>',
|
|
167
|
-
* environment: (
|
|
234
|
+
* environment: () =>
|
|
235
|
+
* document.querySelector<HTMLMetaElement>('meta[name="error-monitoring-environment"]')?.content,
|
|
168
236
|
* });
|
|
169
237
|
* ```
|
|
170
238
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-monitoring.d.ts","sourceRoot":"","sources":["../../../src/error-monitoring/error-monitoring.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IACzC,GAAG,E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EAAqE;IACrE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,kCAAkC,CAAC;IAC1D,+FAA+F;IAC/F,WAAW,CAAC,EAAE,+BAA+B,CAAC;IAC9C;;;OAGG;IACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC;IACxD,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAsKD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACxC,QAAQ,qBAAqB,EAC7B,kBAAwB,IAAI,CAAC,sBAAsB,EAAE,aAAa,CAAM,KACvE,eA2BD,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mCAAmC,GAC9C,YAAY,yBAAyB,KACpC,OAYF,CAAC;AAkBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,OAAO,CAAC,CAsGlB"}
|
|
@@ -2,6 +2,61 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { addGlobalLogReporter } from '@genesislcap/foundation-logger';
|
|
3
3
|
const REPORTED_LOG_TYPES = new Set(['error', 'fatal']);
|
|
4
4
|
const MAX_BUFFERED_LOGS = 100;
|
|
5
|
+
/**
|
|
6
|
+
* Sentry's default integrations that send nothing from the page beyond the error and the browser.
|
|
7
|
+
* Others, such as `Console`, and any a later SDK adds by default, stay off unless the app adds
|
|
8
|
+
* them. Taken from `@sentry/browser` 11.1.0 and matched by name, so a renamed one is dropped.
|
|
9
|
+
*/
|
|
10
|
+
const KEPT_DEFAULT_INTEGRATIONS = new Set([
|
|
11
|
+
'EventFilters',
|
|
12
|
+
'InboundFilters',
|
|
13
|
+
'FunctionToString',
|
|
14
|
+
'BrowserApiErrors',
|
|
15
|
+
'Breadcrumbs',
|
|
16
|
+
'GlobalHandlers',
|
|
17
|
+
'LinkedErrors',
|
|
18
|
+
'Dedupe',
|
|
19
|
+
'HttpContext',
|
|
20
|
+
'CultureContext',
|
|
21
|
+
'BrowserSession',
|
|
22
|
+
]);
|
|
23
|
+
/**
|
|
24
|
+
* Console breadcrumbs carry the logged arguments; click and input ones the element's title and
|
|
25
|
+
* labels.
|
|
26
|
+
*/
|
|
27
|
+
const DROPPED_BREADCRUMB_CATEGORIES = new Set(['console', 'ui.click', 'ui.input']);
|
|
28
|
+
const BREADCRUMB_URL_KEYS = ['url', 'from', 'to'];
|
|
29
|
+
const SPAN_URL_KEYS = new Set(['url.full', 'http.url']);
|
|
30
|
+
const SPAN_URL_PART_KEYS = new Set(['url.query', 'url.fragment', 'http.query', 'http.fragment']);
|
|
31
|
+
const DEFAULT_DATA_COLLECTION = {
|
|
32
|
+
userInfo: false,
|
|
33
|
+
cookies: false,
|
|
34
|
+
// Sentry reads the browser and OS from User-Agent; Referer can hold the previous page's query.
|
|
35
|
+
httpHeaders: { request: { allow: ['user-agent'] }, response: false },
|
|
36
|
+
httpBodies: [],
|
|
37
|
+
urlQueryParams: false,
|
|
38
|
+
};
|
|
39
|
+
const withoutQuery = (url) => url.split(/[?#]/, 1)[0];
|
|
40
|
+
const withoutUrlQueries = (breadcrumb) => {
|
|
41
|
+
const { data } = breadcrumb;
|
|
42
|
+
const urls = BREADCRUMB_URL_KEYS.flatMap((key) => {
|
|
43
|
+
const value = data === null || data === void 0 ? void 0 : data[key];
|
|
44
|
+
return typeof value === 'string' ? [[key, withoutQuery(value)]] : [];
|
|
45
|
+
});
|
|
46
|
+
return urls.length
|
|
47
|
+
? Object.assign(Object.assign({}, breadcrumb), { data: Object.assign(Object.assign({}, data), Object.fromEntries(urls)) }) : breadcrumb;
|
|
48
|
+
};
|
|
49
|
+
const withoutSpanUrlParts = (values) => Object.fromEntries(Object.entries(values)
|
|
50
|
+
.filter(([key]) => !SPAN_URL_PART_KEYS.has(key))
|
|
51
|
+
.map(([key, value]) => [
|
|
52
|
+
key,
|
|
53
|
+
SPAN_URL_KEYS.has(key) && typeof value === 'string' ? withoutQuery(value) : value,
|
|
54
|
+
]));
|
|
55
|
+
const spanOp = ({ op, attributes, data }) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const value = (_a = op !== null && op !== void 0 ? op : attributes === null || attributes === void 0 ? void 0 : attributes['sentry.op']) !== null && _a !== void 0 ? _a : data === null || data === void 0 ? void 0 : data['sentry.op'];
|
|
58
|
+
return typeof value === 'string' ? value : undefined;
|
|
59
|
+
};
|
|
5
60
|
const LOCAL_HOSTNAMES = new Set(['localhost', '0.0.0.0', 'host.docker.internal']);
|
|
6
61
|
const LOCAL_HOSTNAME_SUFFIXES = ['.localhost', '.local'];
|
|
7
62
|
const IPV4 = /^\d{1,3}(\.\d{1,3}){3}$/;
|
|
@@ -170,12 +225,18 @@ const bufferLogs = () => {
|
|
|
170
225
|
* @remarks
|
|
171
226
|
* Without a DSN, or when no environment applies (by default on local hosts such as `localhost` or
|
|
172
227
|
* a private IP address), it does nothing and resolves `false`. The environment defaults to the
|
|
173
|
-
* page's hostname, so one image promoted across environments reports each under its own name
|
|
174
|
-
*
|
|
228
|
+
* page's hostname, so one image promoted across environments reports each under its own name. To
|
|
229
|
+
* use names such as `uat`, read one the deployment sets rather than listing hostnames, which would
|
|
230
|
+
* show everyone who loads the bundle where the other environments are. Otherwise it:
|
|
175
231
|
*
|
|
176
|
-
* - initialises the client (`client.init`, or `options.init`) with the DSN, environment,
|
|
177
|
-
* `
|
|
178
|
-
*
|
|
232
|
+
* - initialises the client (`client.init`, or `options.init`) with the DSN, the environment, any
|
|
233
|
+
* `initOptions`, and defaults that keep page data out of what the SDK collects by itself: Sentry
|
|
234
|
+
* 11's `dataCollection` off for user info, cookies, headers but `User-Agent`, bodies and URL
|
|
235
|
+
* queries; only the default integrations that send nothing from the page (so not `Console`); no
|
|
236
|
+
* console, click or input breadcrumbs; and no query strings or fragments in breadcrumb URLs, the
|
|
237
|
+
* page URL, or span URLs and resource span names when tracing is on. The app's
|
|
238
|
+
* `beforeBreadcrumb`, `beforeSend`, `beforeSendTransaction` and `beforeSendSpan` run after
|
|
239
|
+
* these, and its `integrations` are added;
|
|
179
240
|
* - registers a global log reporter ({@link createErrorMonitoringReporter}), so errors logged by
|
|
180
241
|
* every foundation logger, including those Genesis packages create at import time, are reported,
|
|
181
242
|
* and other logs become breadcrumbs. Only log messages and exceptions are sent, never logged data.
|
|
@@ -200,7 +261,8 @@ const bufferLogs = () => {
|
|
|
200
261
|
*
|
|
201
262
|
* setupErrorMonitoring(Sentry, {
|
|
202
263
|
* dsn: 'https://<key>@<org>.ingest.sentry.io/<project>',
|
|
203
|
-
* environment: (
|
|
264
|
+
* environment: () =>
|
|
265
|
+
* document.querySelector<HTMLMetaElement>('meta[name="error-monitoring-environment"]')?.content,
|
|
204
266
|
* });
|
|
205
267
|
* ```
|
|
206
268
|
*
|
|
@@ -227,14 +289,46 @@ export function setupErrorMonitoring(client, options) {
|
|
|
227
289
|
try {
|
|
228
290
|
const appBeforeBreadcrumb = initOptions.beforeBreadcrumb;
|
|
229
291
|
const beforeBreadcrumb = (breadcrumb, hint) => {
|
|
230
|
-
|
|
292
|
+
var _a;
|
|
293
|
+
if (DROPPED_BREADCRUMB_CATEGORIES.has((_a = breadcrumb.category) !== null && _a !== void 0 ? _a : '')) {
|
|
231
294
|
return null;
|
|
232
295
|
}
|
|
233
|
-
|
|
296
|
+
const kept = withoutUrlQueries(breadcrumb);
|
|
297
|
+
return appBeforeBreadcrumb ? appBeforeBreadcrumb(kept, hint) : kept;
|
|
298
|
+
};
|
|
299
|
+
const withPageUrlStripped = (hook) => (event, hint) => {
|
|
300
|
+
var _a;
|
|
301
|
+
const url = (_a = event.request) === null || _a === void 0 ? void 0 : _a.url;
|
|
302
|
+
const kept = typeof url === 'string'
|
|
303
|
+
? Object.assign(Object.assign({}, event), { request: Object.assign(Object.assign({}, event.request), { url: withoutQuery(url) }) }) : event;
|
|
304
|
+
return (initOptions[hook] ? initOptions[hook](kept, hint) : kept);
|
|
305
|
+
};
|
|
306
|
+
const beforeSendSpan = (span) => {
|
|
307
|
+
var _a;
|
|
308
|
+
const isResource = (_a = spanOp(span)) === null || _a === void 0 ? void 0 : _a.startsWith('resource.');
|
|
309
|
+
const kept = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, span), (span.attributes && { attributes: withoutSpanUrlParts(span.attributes) })), (span.data && { data: withoutSpanUrlParts(span.data) })), (isResource && span.name && { name: withoutQuery(span.name) })), (isResource && span.description && { description: withoutQuery(span.description) }));
|
|
310
|
+
return (initOptions.beforeSendSpan ? initOptions.beforeSendSpan(kept) : kept);
|
|
311
|
+
};
|
|
312
|
+
const isStaticLifecycle = initOptions.traceLifecycle === 'static';
|
|
313
|
+
if (isStaticLifecycle) {
|
|
314
|
+
// Sentry.withStaticSpan's marker; Sentry skips unmarked callbacks in static mode.
|
|
315
|
+
Object.defineProperty(beforeSendSpan, '_static', { value: true });
|
|
316
|
+
}
|
|
317
|
+
const appIntegrations = initOptions.integrations;
|
|
318
|
+
const integrations = (defaults) => {
|
|
319
|
+
const kept = defaults.filter(({ name }) => KEPT_DEFAULT_INTEGRATIONS.has(name));
|
|
320
|
+
if (typeof appIntegrations === 'function') {
|
|
321
|
+
return appIntegrations(kept);
|
|
322
|
+
}
|
|
323
|
+
const added = (appIntegrations !== null && appIntegrations !== void 0 ? appIntegrations : []);
|
|
324
|
+
const addedNames = new Set(added.map(({ name }) => name));
|
|
325
|
+
return [...kept.filter(({ name }) => !addedNames.has(name)), ...added];
|
|
234
326
|
};
|
|
235
|
-
const resolvedInitOptions = Object.assign(Object.assign({}, initOptions), { dsn,
|
|
236
|
-
environment,
|
|
237
|
-
beforeBreadcrumb })
|
|
327
|
+
const resolvedInitOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, initOptions), { dsn,
|
|
328
|
+
environment, dataCollection: Object.assign(Object.assign({}, DEFAULT_DATA_COLLECTION), initOptions.dataCollection), integrations,
|
|
329
|
+
beforeBreadcrumb, beforeSend: withPageUrlStripped('beforeSend') }), (isStaticLifecycle && {
|
|
330
|
+
beforeSendTransaction: withPageUrlStripped('beforeSendTransaction'),
|
|
331
|
+
})), { beforeSendSpan });
|
|
238
332
|
try {
|
|
239
333
|
yield (init ? init(resolvedInitOptions) : (_a = client.init) === null || _a === void 0 ? void 0 : _a.call(client, resolvedInitOptions));
|
|
240
334
|
}
|