@hardfin/cli 0.1.0-dev.26 → 0.1.0-dev.27
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/README.md +30 -0
- package/dist/cli.js +25 -5
- package/dist/completion-tree.json +9 -0
- package/dist/{program-C_9qi3K1.js → program-C3SGdPbf.js} +3406 -3114
- package/dist/scrub-VtQmxap1.js +108 -0
- package/dist/sentry-D5lKx0nm.js +4384 -0
- package/package.json +2 -1
|
@@ -0,0 +1,4384 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as toScrubbed } from "./scrub-VtQmxap1.js";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { request } from "node:http";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { request as request$1 } from "node:https";
|
|
7
|
+
//#region node_modules/@sentry/core/build/esm/debug-build.js
|
|
8
|
+
const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region node_modules/@sentry/core/build/esm/utils/worldwide.js
|
|
11
|
+
const GLOBAL_OBJ = globalThis;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region node_modules/@sentry/core/build/esm/utils/version.js
|
|
14
|
+
const SDK_VERSION = "11.1.0";
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region node_modules/@sentry/core/build/esm/carrier.js
|
|
17
|
+
function getMainCarrier() {
|
|
18
|
+
getSentryCarrier(GLOBAL_OBJ);
|
|
19
|
+
return GLOBAL_OBJ;
|
|
20
|
+
}
|
|
21
|
+
function getSentryCarrier(carrier) {
|
|
22
|
+
const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {};
|
|
23
|
+
__SENTRY__.version = __SENTRY__.version || "11.1.0";
|
|
24
|
+
return __SENTRY__[SDK_VERSION] = __SENTRY__["11.1.0"] || {};
|
|
25
|
+
}
|
|
26
|
+
function getGlobalSingleton(name, creator, obj = GLOBAL_OBJ) {
|
|
27
|
+
const __SENTRY__ = obj.__SENTRY__ = obj.__SENTRY__ || {};
|
|
28
|
+
const carrier = __SENTRY__[SDK_VERSION] = __SENTRY__["11.1.0"] || {};
|
|
29
|
+
return carrier[name] || (carrier[name] = creator());
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region node_modules/@sentry/core/build/esm/utils/debug-logger.js
|
|
33
|
+
const PREFIX = "Sentry Logger ";
|
|
34
|
+
const originalConsoleMethods = {};
|
|
35
|
+
function consoleSandbox(callback) {
|
|
36
|
+
if (!("console" in GLOBAL_OBJ)) return callback();
|
|
37
|
+
const console = GLOBAL_OBJ.console;
|
|
38
|
+
const wrappedFuncs = {};
|
|
39
|
+
const wrappedLevels = Object.keys(originalConsoleMethods);
|
|
40
|
+
wrappedLevels.forEach((level) => {
|
|
41
|
+
const originalConsoleMethod = originalConsoleMethods[level];
|
|
42
|
+
wrappedFuncs[level] = console[level];
|
|
43
|
+
console[level] = originalConsoleMethod;
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
return callback();
|
|
47
|
+
} finally {
|
|
48
|
+
wrappedLevels.forEach((level) => {
|
|
49
|
+
console[level] = wrappedFuncs[level];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function enable() {
|
|
54
|
+
_getLoggerSettings().enabled = true;
|
|
55
|
+
}
|
|
56
|
+
function disable() {
|
|
57
|
+
_getLoggerSettings().enabled = false;
|
|
58
|
+
}
|
|
59
|
+
function isEnabled() {
|
|
60
|
+
return _getLoggerSettings().enabled;
|
|
61
|
+
}
|
|
62
|
+
function log(...args) {
|
|
63
|
+
_maybeLog("log", ...args);
|
|
64
|
+
}
|
|
65
|
+
function warn(...args) {
|
|
66
|
+
_maybeLog("warn", ...args);
|
|
67
|
+
}
|
|
68
|
+
function error(...args) {
|
|
69
|
+
_maybeLog("error", ...args);
|
|
70
|
+
}
|
|
71
|
+
function _maybeLog(level, ...args) {
|
|
72
|
+
if (!DEBUG_BUILD) return;
|
|
73
|
+
if (isEnabled()) consoleSandbox(() => {
|
|
74
|
+
GLOBAL_OBJ.console[level](`${PREFIX}[${level}]:`, ...args);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function _getLoggerSettings() {
|
|
78
|
+
if (!DEBUG_BUILD) return { enabled: false };
|
|
79
|
+
return getGlobalSingleton("loggerSettings", () => ({ enabled: false }));
|
|
80
|
+
}
|
|
81
|
+
const debug = {
|
|
82
|
+
/** Enable logging. */
|
|
83
|
+
enable,
|
|
84
|
+
/** Disable logging. */
|
|
85
|
+
disable,
|
|
86
|
+
/** Check if logging is enabled. */
|
|
87
|
+
isEnabled,
|
|
88
|
+
/** Log a message. */
|
|
89
|
+
log,
|
|
90
|
+
/** Log a warning. */
|
|
91
|
+
warn,
|
|
92
|
+
/** Log an error. */
|
|
93
|
+
error
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region node_modules/@sentry/core/build/esm/utils/stacktrace.js
|
|
97
|
+
const STACKTRACE_FRAME_LIMIT = 50;
|
|
98
|
+
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
99
|
+
const STRIP_FRAME_REGEXP = /captureMessage|captureException/;
|
|
100
|
+
function createStackParser(...parsers) {
|
|
101
|
+
const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map((p) => p[1]);
|
|
102
|
+
return (stack, skipFirstLines = 0, framesToPop = 0) => {
|
|
103
|
+
const frames = [];
|
|
104
|
+
const lines = stack.split("\n");
|
|
105
|
+
for (let i = skipFirstLines; i < lines.length; i++) {
|
|
106
|
+
let line = lines[i];
|
|
107
|
+
if (line.length > 1024) line = line.slice(0, 1024);
|
|
108
|
+
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
|
|
109
|
+
if (cleanedLine.includes("Error: ")) continue;
|
|
110
|
+
for (const parser of sortedParsers) {
|
|
111
|
+
const frame = parser(cleanedLine);
|
|
112
|
+
if (frame) {
|
|
113
|
+
frames.push(frame);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (frames.length >= STACKTRACE_FRAME_LIMIT + framesToPop) break;
|
|
118
|
+
}
|
|
119
|
+
return stripSentryFramesAndReverse(frames.slice(framesToPop));
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function stripSentryFramesAndReverse(stack) {
|
|
123
|
+
if (!stack.length) return [];
|
|
124
|
+
const localStack = Array.from(stack);
|
|
125
|
+
if (/sentryWrapped/.test(getLastStackFrame(localStack).function || "")) localStack.pop();
|
|
126
|
+
localStack.reverse();
|
|
127
|
+
if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || "")) {
|
|
128
|
+
localStack.pop();
|
|
129
|
+
if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || "")) localStack.pop();
|
|
130
|
+
}
|
|
131
|
+
return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame) => ({
|
|
132
|
+
...frame,
|
|
133
|
+
filename: frame.filename || getLastStackFrame(localStack).filename,
|
|
134
|
+
function: frame.function || "?"
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
function getLastStackFrame(arr) {
|
|
138
|
+
return arr[arr.length - 1] || {};
|
|
139
|
+
}
|
|
140
|
+
const defaultFunctionName = "<anonymous>";
|
|
141
|
+
function getFunctionName(fn) {
|
|
142
|
+
try {
|
|
143
|
+
if (!fn || typeof fn !== "function") return defaultFunctionName;
|
|
144
|
+
return fn.name || defaultFunctionName;
|
|
145
|
+
} catch {
|
|
146
|
+
return defaultFunctionName;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function normalizeStackTracePath(path) {
|
|
150
|
+
let filename = path?.startsWith("file://") ? path.slice(7) : path;
|
|
151
|
+
if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
|
|
152
|
+
return filename;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region node_modules/@sentry/core/build/esm/utils/is.js
|
|
156
|
+
const objectToString = Object.prototype.toString;
|
|
157
|
+
function isError(wat) {
|
|
158
|
+
switch (objectToString.call(wat)) {
|
|
159
|
+
case "[object Error]":
|
|
160
|
+
case "[object Exception]":
|
|
161
|
+
case "[object DOMException]":
|
|
162
|
+
case "[object WebAssembly.Exception]": return true;
|
|
163
|
+
default: return isInstanceOf(wat, Error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function isBuiltin(wat, className) {
|
|
167
|
+
return objectToString.call(wat) === `[object ${className}]`;
|
|
168
|
+
}
|
|
169
|
+
function isErrorEvent$1(wat) {
|
|
170
|
+
return isBuiltin(wat, "ErrorEvent");
|
|
171
|
+
}
|
|
172
|
+
function isString(wat) {
|
|
173
|
+
return isBuiltin(wat, "String");
|
|
174
|
+
}
|
|
175
|
+
function isParameterizedString(wat) {
|
|
176
|
+
return typeof wat === "object" && wat !== null && "__sentry_template_string__" in wat && "__sentry_template_values__" in wat;
|
|
177
|
+
}
|
|
178
|
+
function isPrimitive(wat) {
|
|
179
|
+
return wat === null || isParameterizedString(wat) || typeof wat !== "object" && typeof wat !== "function";
|
|
180
|
+
}
|
|
181
|
+
function isPlainObject(wat) {
|
|
182
|
+
return isBuiltin(wat, "Object");
|
|
183
|
+
}
|
|
184
|
+
function isObjectLike(wat) {
|
|
185
|
+
return typeof wat === "object" && wat !== null;
|
|
186
|
+
}
|
|
187
|
+
function isEvent(wat) {
|
|
188
|
+
return typeof Event !== "undefined" && isInstanceOf(wat, Event);
|
|
189
|
+
}
|
|
190
|
+
function isRegExp(wat) {
|
|
191
|
+
return isBuiltin(wat, "RegExp");
|
|
192
|
+
}
|
|
193
|
+
function isThenable(wat) {
|
|
194
|
+
return Boolean(wat?.then && typeof wat.then === "function");
|
|
195
|
+
}
|
|
196
|
+
function isInstanceOf(wat, base) {
|
|
197
|
+
try {
|
|
198
|
+
return wat instanceof base;
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region node_modules/@sentry/core/build/esm/utils/object.js
|
|
205
|
+
function addNonEnumerableProperty(obj, name, value) {
|
|
206
|
+
try {
|
|
207
|
+
Object.defineProperty(obj, name, {
|
|
208
|
+
value,
|
|
209
|
+
writable: true,
|
|
210
|
+
configurable: true
|
|
211
|
+
});
|
|
212
|
+
} catch {
|
|
213
|
+
DEBUG_BUILD && debug.log(`Failed to add non-enumerable property "${String(name)}" to object`, obj);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function convertToPlainObject(value) {
|
|
217
|
+
if (isError(value)) return {
|
|
218
|
+
message: value.message,
|
|
219
|
+
name: value.name,
|
|
220
|
+
stack: value.stack,
|
|
221
|
+
...getOwnProperties(value)
|
|
222
|
+
};
|
|
223
|
+
if (isEvent(value)) {
|
|
224
|
+
const { type, target, currentTarget, detail } = value;
|
|
225
|
+
return {
|
|
226
|
+
type,
|
|
227
|
+
target,
|
|
228
|
+
currentTarget,
|
|
229
|
+
...detail ? { detail } : {},
|
|
230
|
+
...getOwnProperties(value)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
function getOwnProperties(obj) {
|
|
236
|
+
if (isObjectLike(obj)) return Object.fromEntries(Object.entries(obj));
|
|
237
|
+
return {};
|
|
238
|
+
}
|
|
239
|
+
function extractExceptionKeysForMessage(exception) {
|
|
240
|
+
const keys = Object.keys(convertToPlainObject(exception));
|
|
241
|
+
keys.sort();
|
|
242
|
+
return !keys[0] ? "[object has no keys]" : keys.join(", ");
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region node_modules/@sentry/core/build/esm/utils/randomSafeContext.js
|
|
246
|
+
let RESOLVED_RUNNER;
|
|
247
|
+
function withRandomSafeContext(cb) {
|
|
248
|
+
if (RESOLVED_RUNNER !== void 0) return RESOLVED_RUNNER ? RESOLVED_RUNNER(cb) : cb();
|
|
249
|
+
const sym = /* @__PURE__ */ Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__");
|
|
250
|
+
const globalWithSymbol = GLOBAL_OBJ;
|
|
251
|
+
if (sym in globalWithSymbol && typeof globalWithSymbol[sym] === "function") {
|
|
252
|
+
RESOLVED_RUNNER = globalWithSymbol[sym];
|
|
253
|
+
return RESOLVED_RUNNER(cb);
|
|
254
|
+
}
|
|
255
|
+
RESOLVED_RUNNER = null;
|
|
256
|
+
return cb();
|
|
257
|
+
}
|
|
258
|
+
function safeMathRandom() {
|
|
259
|
+
return withRandomSafeContext(() => Math.random());
|
|
260
|
+
}
|
|
261
|
+
function safeDateNow() {
|
|
262
|
+
return withRandomSafeContext(() => Date.now());
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region node_modules/@sentry/core/build/esm/utils/normalizationHints.js
|
|
266
|
+
const SENTRY_SKIP_NORMALIZATION = /* @__PURE__ */ Symbol.for("sentry.skipNormalization");
|
|
267
|
+
const SENTRY_OVERRIDE_NORMALIZATION_DEPTH = /* @__PURE__ */ Symbol.for("sentry.overrideNormalizationDepth");
|
|
268
|
+
function hasSkipNormalizationHint(value) {
|
|
269
|
+
return Boolean(value[SENTRY_SKIP_NORMALIZATION]);
|
|
270
|
+
}
|
|
271
|
+
function getNormalizationDepthOverrideHint(value) {
|
|
272
|
+
const v = value[SENTRY_OVERRIDE_NORMALIZATION_DEPTH];
|
|
273
|
+
return typeof v === "number" ? v : void 0;
|
|
274
|
+
}
|
|
275
|
+
function normalize(input, depth = 100, maxProperties = Infinity) {
|
|
276
|
+
try {
|
|
277
|
+
return visit("", input, depth, maxProperties);
|
|
278
|
+
} catch (err) {
|
|
279
|
+
return { ERROR: `**non-serializable** (${err})` };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function normalizeToSize(object, depth = 3, maxSize = 102400) {
|
|
283
|
+
const normalized = normalize(object, depth);
|
|
284
|
+
if (jsonSize(normalized) > maxSize) return normalizeToSize(object, depth - 1, maxSize);
|
|
285
|
+
return normalized;
|
|
286
|
+
}
|
|
287
|
+
function visit(key, value, depth = Infinity, maxProperties = Infinity, memo = memoBuilder()) {
|
|
288
|
+
const [memoize, unmemoize] = memo;
|
|
289
|
+
if (value == null || ["boolean", "string"].includes(typeof value) || typeof value === "number" && Number.isFinite(value)) return value;
|
|
290
|
+
const stringified = stringifyValue(key, value);
|
|
291
|
+
if (!stringified.startsWith("[object ")) return stringified;
|
|
292
|
+
if (hasSkipNormalizationHint(value)) return value;
|
|
293
|
+
const overrideDepth = getNormalizationDepthOverrideHint(value);
|
|
294
|
+
const remainingDepth = overrideDepth !== void 0 ? overrideDepth : depth;
|
|
295
|
+
if (remainingDepth === 0) return stringified.replace("object ", "");
|
|
296
|
+
if (memoize(value)) return "[Circular ~]";
|
|
297
|
+
const valueWithToJSON = value;
|
|
298
|
+
if (valueWithToJSON && typeof valueWithToJSON.toJSON === "function") try {
|
|
299
|
+
return visit("", valueWithToJSON.toJSON(), remainingDepth - 1, maxProperties, memo);
|
|
300
|
+
} catch {}
|
|
301
|
+
const normalized = Array.isArray(value) ? [] : {};
|
|
302
|
+
let numAdded = 0;
|
|
303
|
+
const visitable = convertToPlainObject(value);
|
|
304
|
+
for (const visitKey in visitable) {
|
|
305
|
+
if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) continue;
|
|
306
|
+
if (numAdded >= maxProperties) {
|
|
307
|
+
normalized[visitKey] = "[MaxProperties ~]";
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
const visitValue = visitable[visitKey];
|
|
311
|
+
normalized[visitKey] = visit(visitKey, visitValue, remainingDepth - 1, maxProperties, memo);
|
|
312
|
+
numAdded++;
|
|
313
|
+
}
|
|
314
|
+
unmemoize(value);
|
|
315
|
+
return normalized;
|
|
316
|
+
}
|
|
317
|
+
function stringifyValue(key, value) {
|
|
318
|
+
try {
|
|
319
|
+
if (typeof global !== "undefined" && value === global) return "[Global]";
|
|
320
|
+
if (typeof value === "number" && !Number.isFinite(value)) return `[${value}]`;
|
|
321
|
+
if (typeof value === "function") return `[Function: ${getFunctionName(value)}]`;
|
|
322
|
+
if (typeof value === "symbol") return `[${String(value)}]`;
|
|
323
|
+
if (typeof value === "bigint") return `[BigInt: ${String(value)}]`;
|
|
324
|
+
return `[object ${getConstructorName(value)}]`;
|
|
325
|
+
} catch (err) {
|
|
326
|
+
return `**non-serializable** (${err})`;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function getConstructorName(value) {
|
|
330
|
+
const prototype = Object.getPrototypeOf(value);
|
|
331
|
+
return prototype?.constructor ? prototype.constructor.name : "null prototype";
|
|
332
|
+
}
|
|
333
|
+
function utf8Length(value) {
|
|
334
|
+
return ~-encodeURI(value).split(/%..|./).length;
|
|
335
|
+
}
|
|
336
|
+
function jsonSize(value) {
|
|
337
|
+
return utf8Length(JSON.stringify(value));
|
|
338
|
+
}
|
|
339
|
+
function memoBuilder() {
|
|
340
|
+
const inner = /* @__PURE__ */ new WeakSet();
|
|
341
|
+
function memoize(obj) {
|
|
342
|
+
if (inner.has(obj)) return true;
|
|
343
|
+
inner.add(obj);
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
function unmemoize(obj) {
|
|
347
|
+
inner.delete(obj);
|
|
348
|
+
}
|
|
349
|
+
return [memoize, unmemoize];
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region node_modules/@sentry/core/build/esm/utils/string.js
|
|
353
|
+
function truncate(str, max = 0) {
|
|
354
|
+
if (typeof str !== "string" || max === 0) return str;
|
|
355
|
+
return str.length <= max ? str : `${str.slice(0, max)}...`;
|
|
356
|
+
}
|
|
357
|
+
function isMatchingPattern(value, pattern, requireExactStringMatch = false) {
|
|
358
|
+
if (!isString(value)) return false;
|
|
359
|
+
if (isRegExp(pattern)) return pattern.test(value);
|
|
360
|
+
if (isString(pattern)) return requireExactStringMatch ? value === pattern : value.includes(pattern);
|
|
361
|
+
if (typeof pattern === "function") return pattern(value);
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region node_modules/@sentry/core/build/esm/utils/misc.js
|
|
366
|
+
function getCrypto() {
|
|
367
|
+
const gbl = GLOBAL_OBJ;
|
|
368
|
+
return gbl.crypto || gbl.msCrypto;
|
|
369
|
+
}
|
|
370
|
+
let emptyUuid;
|
|
371
|
+
function getRandomByte() {
|
|
372
|
+
return safeMathRandom() * 16;
|
|
373
|
+
}
|
|
374
|
+
function uuid4(crypto = getCrypto()) {
|
|
375
|
+
try {
|
|
376
|
+
if (crypto?.randomUUID) return withRandomSafeContext(() => crypto.randomUUID()).replace(/-/g, "");
|
|
377
|
+
} catch {}
|
|
378
|
+
if (!emptyUuid) emptyUuid = "10000000100040008000100000000000";
|
|
379
|
+
return emptyUuid.replace(/[018]/g, (c) => (c ^ (getRandomByte() & 15) >> c / 4).toString(16));
|
|
380
|
+
}
|
|
381
|
+
function getFirstException(event) {
|
|
382
|
+
return event.exception?.values?.[0];
|
|
383
|
+
}
|
|
384
|
+
function addExceptionTypeValue(event, value, type) {
|
|
385
|
+
const exception = event.exception = event.exception || {};
|
|
386
|
+
const values = exception.values = exception.values || [];
|
|
387
|
+
const firstException = values[0] = values[0] || {};
|
|
388
|
+
if (!firstException.value) firstException.value = value || "";
|
|
389
|
+
if (!firstException.type) firstException.type = type || "Error";
|
|
390
|
+
}
|
|
391
|
+
function addExceptionMechanism(event, newMechanism) {
|
|
392
|
+
const firstException = getFirstException(event);
|
|
393
|
+
if (!firstException) return;
|
|
394
|
+
applyExceptionMechanism(firstException, newMechanism);
|
|
395
|
+
}
|
|
396
|
+
function addExceptionMechanismToCapturedException(event, newMechanism) {
|
|
397
|
+
const exceptions = event.exception?.values;
|
|
398
|
+
const capturedException = exceptions?.find((exception) => exception.mechanism?.exception_id === 0) ?? exceptions?.[0];
|
|
399
|
+
if (!capturedException) return;
|
|
400
|
+
applyExceptionMechanism(capturedException, newMechanism);
|
|
401
|
+
}
|
|
402
|
+
function applyExceptionMechanism(exception, newMechanism) {
|
|
403
|
+
const defaultMechanism = {
|
|
404
|
+
type: "generic",
|
|
405
|
+
handled: true
|
|
406
|
+
};
|
|
407
|
+
const currentMechanism = exception.mechanism;
|
|
408
|
+
exception.mechanism = {
|
|
409
|
+
...defaultMechanism,
|
|
410
|
+
...currentMechanism,
|
|
411
|
+
...newMechanism
|
|
412
|
+
};
|
|
413
|
+
if (newMechanism && "data" in newMechanism) exception.mechanism.data = {
|
|
414
|
+
...currentMechanism?.data,
|
|
415
|
+
...newMechanism.data
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function checkOrSetAlreadyCaught(exception) {
|
|
419
|
+
if (isAlreadyCaptured(exception)) return true;
|
|
420
|
+
try {
|
|
421
|
+
addNonEnumerableProperty(exception, "__sentry_captured__", true);
|
|
422
|
+
} catch {}
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
function isAlreadyCaptured(exception) {
|
|
426
|
+
try {
|
|
427
|
+
return exception.__sentry_captured__;
|
|
428
|
+
} catch {}
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region node_modules/@sentry/core/build/esm/utils/time.js
|
|
432
|
+
const ONE_SECOND_IN_MS = 1e3;
|
|
433
|
+
function dateTimestampInSeconds() {
|
|
434
|
+
return safeDateNow() / ONE_SECOND_IN_MS;
|
|
435
|
+
}
|
|
436
|
+
function createUnixTimestampInSecondsFunc() {
|
|
437
|
+
const { performance } = GLOBAL_OBJ;
|
|
438
|
+
if (!performance?.now || !performance.timeOrigin) return dateTimestampInSeconds;
|
|
439
|
+
const timeOrigin = performance.timeOrigin;
|
|
440
|
+
return () => {
|
|
441
|
+
return (timeOrigin + withRandomSafeContext(() => performance.now())) / ONE_SECOND_IN_MS;
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
let _cachedTimestampInSeconds;
|
|
445
|
+
function timestampInSeconds() {
|
|
446
|
+
return (_cachedTimestampInSeconds ?? (_cachedTimestampInSeconds = createUnixTimestampInSecondsFunc()))();
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region node_modules/@sentry/core/build/esm/session.js
|
|
450
|
+
function updateSession(session, context = {}) {
|
|
451
|
+
if (context.user) {
|
|
452
|
+
if (!session.ipAddress && context.user.ip_address) session.ipAddress = context.user.ip_address;
|
|
453
|
+
if (!session.did && !context.did) session.did = context.user.id || context.user.email || context.user.username;
|
|
454
|
+
}
|
|
455
|
+
session.timestamp = context.timestamp || timestampInSeconds();
|
|
456
|
+
if (context.abnormal_mechanism) session.abnormal_mechanism = context.abnormal_mechanism;
|
|
457
|
+
if (context.ignoreDuration) session.ignoreDuration = context.ignoreDuration;
|
|
458
|
+
if (context.sid) session.sid = context.sid.length === 32 ? context.sid : uuid4();
|
|
459
|
+
if (context.init !== void 0) session.init = context.init;
|
|
460
|
+
if (!session.did && context.did) session.did = `${context.did}`;
|
|
461
|
+
if (typeof context.started === "number") session.started = context.started;
|
|
462
|
+
if (session.ignoreDuration) session.duration = void 0;
|
|
463
|
+
else if (typeof context.duration === "number") session.duration = context.duration;
|
|
464
|
+
else {
|
|
465
|
+
const duration = session.timestamp - session.started;
|
|
466
|
+
session.duration = duration >= 0 ? duration : 0;
|
|
467
|
+
}
|
|
468
|
+
if (context.release) session.release = context.release;
|
|
469
|
+
if (context.environment) session.environment = context.environment;
|
|
470
|
+
if (!session.ipAddress && context.ipAddress) session.ipAddress = context.ipAddress;
|
|
471
|
+
if (!session.userAgent && context.userAgent) session.userAgent = context.userAgent;
|
|
472
|
+
if (typeof context.errors === "number") session.errors = context.errors;
|
|
473
|
+
if (context.status) session.status = context.status;
|
|
474
|
+
}
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region node_modules/@sentry/core/build/esm/utils/merge.js
|
|
477
|
+
function merge(initialObj, mergeObj, levels = 2) {
|
|
478
|
+
if (!mergeObj || typeof mergeObj !== "object" || levels <= 0) return mergeObj;
|
|
479
|
+
if (initialObj && Object.keys(mergeObj).length === 0) return initialObj;
|
|
480
|
+
const output = { ...initialObj };
|
|
481
|
+
for (const key in mergeObj) if (Object.prototype.hasOwnProperty.call(mergeObj, key)) output[key] = merge(output[key], mergeObj[key], levels - 1);
|
|
482
|
+
return output;
|
|
483
|
+
}
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region node_modules/@sentry/core/build/esm/utils/propagationContext.js
|
|
486
|
+
function generateTraceId() {
|
|
487
|
+
return uuid4();
|
|
488
|
+
}
|
|
489
|
+
function generateSpanId() {
|
|
490
|
+
return uuid4().substring(16);
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region node_modules/@sentry/core/build/esm/scope.js
|
|
494
|
+
const DEFAULT_MAX_BREADCRUMBS = 100;
|
|
495
|
+
var Scope = class Scope {
|
|
496
|
+
constructor() {
|
|
497
|
+
this._notifyingListeners = false;
|
|
498
|
+
this._scopeListeners = [];
|
|
499
|
+
this._eventProcessors = [];
|
|
500
|
+
this._breadcrumbs = [];
|
|
501
|
+
this._attachments = [];
|
|
502
|
+
this._user = {};
|
|
503
|
+
this._tags = {};
|
|
504
|
+
this._attributes = {};
|
|
505
|
+
this._extra = {};
|
|
506
|
+
this._contexts = {};
|
|
507
|
+
this._sdkProcessingMetadata = {};
|
|
508
|
+
addNonEnumerableProperty(this, "refs", {});
|
|
509
|
+
this._propagationContext = {
|
|
510
|
+
traceId: generateTraceId(),
|
|
511
|
+
sampleRand: safeMathRandom()
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Clone all data from this scope into a new scope.
|
|
516
|
+
*/
|
|
517
|
+
clone() {
|
|
518
|
+
const newScope = new Scope();
|
|
519
|
+
newScope._breadcrumbs = [...this._breadcrumbs];
|
|
520
|
+
newScope._tags = { ...this._tags };
|
|
521
|
+
newScope._attributes = { ...this._attributes };
|
|
522
|
+
newScope._extra = { ...this._extra };
|
|
523
|
+
newScope._contexts = { ...this._contexts };
|
|
524
|
+
if (this._contexts.flags) newScope._contexts.flags = { values: [...this._contexts.flags.values] };
|
|
525
|
+
newScope._user = this._user;
|
|
526
|
+
newScope._level = this._level;
|
|
527
|
+
newScope._session = this._session;
|
|
528
|
+
newScope._transactionName = this._transactionName;
|
|
529
|
+
newScope._fingerprint = this._fingerprint;
|
|
530
|
+
newScope._eventProcessors = [...this._eventProcessors];
|
|
531
|
+
newScope._attachments = [...this._attachments];
|
|
532
|
+
newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };
|
|
533
|
+
newScope._propagationContext = { ...this._propagationContext };
|
|
534
|
+
newScope._client = this._client;
|
|
535
|
+
newScope._lastEventId = this._lastEventId;
|
|
536
|
+
newScope._conversationId = this._conversationId;
|
|
537
|
+
newScope.refs = { ...this.refs };
|
|
538
|
+
return newScope;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Update the client assigned to this scope.
|
|
542
|
+
* Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,
|
|
543
|
+
* as well as manually created scopes.
|
|
544
|
+
*/
|
|
545
|
+
setClient(client) {
|
|
546
|
+
this._client = client;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Set the ID of the last captured error event.
|
|
550
|
+
* This is generally only captured on the isolation scope.
|
|
551
|
+
*/
|
|
552
|
+
setLastEventId(lastEventId) {
|
|
553
|
+
this._lastEventId = lastEventId;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Get the client assigned to this scope.
|
|
557
|
+
*/
|
|
558
|
+
getClient() {
|
|
559
|
+
return this._client;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Get the ID of the last captured error event.
|
|
563
|
+
* This is generally only available on the isolation scope.
|
|
564
|
+
*/
|
|
565
|
+
lastEventId() {
|
|
566
|
+
return this._lastEventId;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* @inheritDoc
|
|
570
|
+
*/
|
|
571
|
+
addScopeListener(callback) {
|
|
572
|
+
this._scopeListeners.push(callback);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Add an event processor that will be called before an event is sent.
|
|
576
|
+
*/
|
|
577
|
+
addEventProcessor(callback) {
|
|
578
|
+
this._eventProcessors.push(callback);
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Set the user for this scope.
|
|
583
|
+
* Set to `null` to unset the user.
|
|
584
|
+
*/
|
|
585
|
+
setUser(user) {
|
|
586
|
+
this._user = user || {
|
|
587
|
+
email: void 0,
|
|
588
|
+
id: void 0,
|
|
589
|
+
ip_address: void 0,
|
|
590
|
+
username: void 0
|
|
591
|
+
};
|
|
592
|
+
if (this._session) updateSession(this._session, { user });
|
|
593
|
+
this._notifyScopeListeners();
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Get the user from this scope.
|
|
598
|
+
*/
|
|
599
|
+
getUser() {
|
|
600
|
+
return this._user;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Set the conversation ID for this scope.
|
|
604
|
+
* Set to `null` to unset the conversation ID.
|
|
605
|
+
*/
|
|
606
|
+
setConversationId(conversationId) {
|
|
607
|
+
this._conversationId = conversationId || void 0;
|
|
608
|
+
this._notifyScopeListeners();
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Set an object that will be merged into existing tags on the scope,
|
|
613
|
+
* and will be sent as tags data with the event.
|
|
614
|
+
*/
|
|
615
|
+
setTags(tags) {
|
|
616
|
+
this._tags = {
|
|
617
|
+
...this._tags,
|
|
618
|
+
...tags
|
|
619
|
+
};
|
|
620
|
+
this._notifyScopeListeners();
|
|
621
|
+
return this;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Set a single tag that will be sent as tags data with the event.
|
|
625
|
+
*/
|
|
626
|
+
setTag(key, value) {
|
|
627
|
+
return this.setTags({ [key]: value });
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Sets attributes onto the scope.
|
|
631
|
+
*
|
|
632
|
+
* These attributes are applied to logs, metrics and streamed spans.
|
|
633
|
+
*
|
|
634
|
+
* Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.
|
|
635
|
+
*
|
|
636
|
+
* @param newAttributes - The attributes to set on the scope, as key-value pairs.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* scope.setAttributes({
|
|
641
|
+
* is_admin: true,
|
|
642
|
+
* payment_selection: 'credit_card',
|
|
643
|
+
* render_duration: 150,
|
|
644
|
+
* });
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
setAttributes(newAttributes) {
|
|
648
|
+
this._attributes = {
|
|
649
|
+
...this._attributes,
|
|
650
|
+
...newAttributes
|
|
651
|
+
};
|
|
652
|
+
this._notifyScopeListeners();
|
|
653
|
+
return this;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Sets an attribute onto the scope.
|
|
657
|
+
*
|
|
658
|
+
* These attributes are applied to logs, metrics and streamed spans.
|
|
659
|
+
*
|
|
660
|
+
* Supported attribute value types are `string`, `number`, `boolean`, `string[]`, `number[]` and `boolean[]`.
|
|
661
|
+
*
|
|
662
|
+
* @param key - The attribute key.
|
|
663
|
+
* @param value - The attribute value.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```typescript
|
|
667
|
+
* scope.setAttribute('is_admin', true);
|
|
668
|
+
* scope.setAttribute('render_duration', 150);
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
setAttribute(key, value) {
|
|
672
|
+
return this.setAttributes({ [key]: value });
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Removes the attribute with the given key from the scope.
|
|
676
|
+
*
|
|
677
|
+
* @param key - The attribute key.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* scope.removeAttribute('is_admin');
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
removeAttribute(key) {
|
|
685
|
+
if (key in this._attributes) {
|
|
686
|
+
delete this._attributes[key];
|
|
687
|
+
this._notifyScopeListeners();
|
|
688
|
+
}
|
|
689
|
+
return this;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Set an object that will be merged into existing extra on the scope,
|
|
693
|
+
* and will be sent as extra data with the event.
|
|
694
|
+
*/
|
|
695
|
+
setExtras(extras) {
|
|
696
|
+
this._extra = {
|
|
697
|
+
...this._extra,
|
|
698
|
+
...extras
|
|
699
|
+
};
|
|
700
|
+
this._notifyScopeListeners();
|
|
701
|
+
return this;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Set a single key:value extra entry that will be sent as extra data with the event.
|
|
705
|
+
*/
|
|
706
|
+
setExtra(key, extra) {
|
|
707
|
+
this._extra = {
|
|
708
|
+
...this._extra,
|
|
709
|
+
[key]: extra
|
|
710
|
+
};
|
|
711
|
+
this._notifyScopeListeners();
|
|
712
|
+
return this;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Sets the fingerprint on the scope to send with the events.
|
|
716
|
+
* @param {string[]} fingerprint Fingerprint to group events in Sentry.
|
|
717
|
+
*/
|
|
718
|
+
setFingerprint(fingerprint) {
|
|
719
|
+
this._fingerprint = fingerprint;
|
|
720
|
+
this._notifyScopeListeners();
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Sets the level on the scope for future events.
|
|
725
|
+
*/
|
|
726
|
+
setLevel(level) {
|
|
727
|
+
this._level = level;
|
|
728
|
+
this._notifyScopeListeners();
|
|
729
|
+
return this;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Sets the transaction name on the scope so that the name of e.g. taken server route or
|
|
733
|
+
* the page location is attached to future events.
|
|
734
|
+
*
|
|
735
|
+
* IMPORTANT: Calling this function does NOT change the name of the currently active
|
|
736
|
+
* root span. If you want to change the name of the active root span, use
|
|
737
|
+
* `Sentry.updateSpanName(rootSpan, 'new name')` instead.
|
|
738
|
+
*
|
|
739
|
+
* By default, the SDK updates the scope's transaction name automatically on sensible
|
|
740
|
+
* occasions, such as a page navigation or when handling a new request on the server.
|
|
741
|
+
*/
|
|
742
|
+
setTransactionName(name) {
|
|
743
|
+
this._transactionName = name;
|
|
744
|
+
this._notifyScopeListeners();
|
|
745
|
+
return this;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Sets context data with the given name.
|
|
749
|
+
* Data passed as context will be normalized. You can also pass `null` to unset the context.
|
|
750
|
+
* Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.
|
|
751
|
+
*/
|
|
752
|
+
setContext(key, context) {
|
|
753
|
+
if (context === null) delete this._contexts[key];
|
|
754
|
+
else this._contexts[key] = context;
|
|
755
|
+
this._notifyScopeListeners();
|
|
756
|
+
return this;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Set the session for the scope.
|
|
760
|
+
*/
|
|
761
|
+
setSession(session) {
|
|
762
|
+
if (!session) delete this._session;
|
|
763
|
+
else this._session = session;
|
|
764
|
+
this._notifyScopeListeners();
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Get the session from the scope.
|
|
769
|
+
*/
|
|
770
|
+
getSession() {
|
|
771
|
+
return this._session;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Updates the scope with provided data. Can work in three variations:
|
|
775
|
+
* - plain object containing updatable attributes
|
|
776
|
+
* - Scope instance that'll extract the attributes from
|
|
777
|
+
* - callback function that'll receive the current scope as an argument and allow for modifications
|
|
778
|
+
*/
|
|
779
|
+
update(captureContext) {
|
|
780
|
+
if (!captureContext) return this;
|
|
781
|
+
const scopeToMerge = typeof captureContext === "function" ? captureContext(this) : captureContext;
|
|
782
|
+
const { tags, attributes, extra, user, contexts, level, fingerprint = [], propagationContext, conversationId } = (scopeToMerge instanceof Scope ? scopeToMerge.getScopeData() : isPlainObject(scopeToMerge) ? captureContext : void 0) || {};
|
|
783
|
+
this._tags = {
|
|
784
|
+
...this._tags,
|
|
785
|
+
...tags
|
|
786
|
+
};
|
|
787
|
+
this._attributes = {
|
|
788
|
+
...this._attributes,
|
|
789
|
+
...attributes
|
|
790
|
+
};
|
|
791
|
+
this._extra = {
|
|
792
|
+
...this._extra,
|
|
793
|
+
...extra
|
|
794
|
+
};
|
|
795
|
+
this._contexts = {
|
|
796
|
+
...this._contexts,
|
|
797
|
+
...contexts
|
|
798
|
+
};
|
|
799
|
+
if (user && Object.keys(user).length) this._user = user;
|
|
800
|
+
if (level) this._level = level;
|
|
801
|
+
if (fingerprint.length) this._fingerprint = fingerprint;
|
|
802
|
+
if (propagationContext) this._propagationContext = propagationContext;
|
|
803
|
+
if (conversationId) this._conversationId = conversationId;
|
|
804
|
+
return this;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Adds a breadcrumb to the scope.
|
|
808
|
+
* By default, the last 100 breadcrumbs are kept.
|
|
809
|
+
*/
|
|
810
|
+
addBreadcrumb(breadcrumb, maxBreadcrumbs) {
|
|
811
|
+
const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
|
|
812
|
+
if (maxCrumbs <= 0) return this;
|
|
813
|
+
const mergedBreadcrumb = {
|
|
814
|
+
timestamp: dateTimestampInSeconds(),
|
|
815
|
+
...breadcrumb,
|
|
816
|
+
message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message
|
|
817
|
+
};
|
|
818
|
+
this._breadcrumbs.push(mergedBreadcrumb);
|
|
819
|
+
if (this._breadcrumbs.length > maxCrumbs) this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);
|
|
820
|
+
this._notifyScopeListeners();
|
|
821
|
+
return this;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Get the last breadcrumb of the scope.
|
|
825
|
+
*/
|
|
826
|
+
getLastBreadcrumb() {
|
|
827
|
+
return this._breadcrumbs[this._breadcrumbs.length - 1];
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Clear all breadcrumbs from the scope.
|
|
831
|
+
*/
|
|
832
|
+
clearBreadcrumbs() {
|
|
833
|
+
this._breadcrumbs = [];
|
|
834
|
+
this._notifyScopeListeners();
|
|
835
|
+
return this;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Add an attachment to the scope.
|
|
839
|
+
*/
|
|
840
|
+
addAttachment(attachment) {
|
|
841
|
+
this._attachments.push(attachment);
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Clear all attachments from the scope.
|
|
846
|
+
*/
|
|
847
|
+
clearAttachments() {
|
|
848
|
+
this._attachments = [];
|
|
849
|
+
return this;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Get the data of this scope, which should be applied to an event during processing.
|
|
853
|
+
*/
|
|
854
|
+
getScopeData() {
|
|
855
|
+
return {
|
|
856
|
+
breadcrumbs: this._breadcrumbs,
|
|
857
|
+
attachments: this._attachments,
|
|
858
|
+
contexts: this._contexts,
|
|
859
|
+
tags: this._tags,
|
|
860
|
+
attributes: this._attributes,
|
|
861
|
+
extra: this._extra,
|
|
862
|
+
user: this._user,
|
|
863
|
+
level: this._level,
|
|
864
|
+
fingerprint: this._fingerprint || [],
|
|
865
|
+
eventProcessors: this._eventProcessors,
|
|
866
|
+
propagationContext: this._propagationContext,
|
|
867
|
+
sdkProcessingMetadata: this._sdkProcessingMetadata,
|
|
868
|
+
transactionName: this._transactionName,
|
|
869
|
+
conversationId: this._conversationId
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Add data which will be accessible during event processing but won't get sent to Sentry.
|
|
874
|
+
*/
|
|
875
|
+
setSDKProcessingMetadata(newData) {
|
|
876
|
+
this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);
|
|
877
|
+
return this;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Add propagation context to the scope, used for distributed tracing
|
|
881
|
+
*/
|
|
882
|
+
setPropagationContext(context) {
|
|
883
|
+
this._propagationContext = context;
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Get propagation context from the scope, used for distributed tracing
|
|
888
|
+
*/
|
|
889
|
+
getPropagationContext() {
|
|
890
|
+
return this._propagationContext;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Capture an exception for this scope.
|
|
894
|
+
*
|
|
895
|
+
* @returns {string} The id of the captured Sentry event.
|
|
896
|
+
*/
|
|
897
|
+
captureException(exception, hint) {
|
|
898
|
+
const eventId = hint?.event_id || uuid4();
|
|
899
|
+
if (!this._client) {
|
|
900
|
+
DEBUG_BUILD && debug.warn("No client configured on scope - will not capture exception!");
|
|
901
|
+
return eventId;
|
|
902
|
+
}
|
|
903
|
+
const syntheticException = /* @__PURE__ */ new Error("Sentry syntheticException");
|
|
904
|
+
this._client.captureException(exception, {
|
|
905
|
+
originalException: exception,
|
|
906
|
+
syntheticException,
|
|
907
|
+
...hint,
|
|
908
|
+
event_id: eventId
|
|
909
|
+
}, this);
|
|
910
|
+
return eventId;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Capture a message for this scope.
|
|
914
|
+
*
|
|
915
|
+
* @returns {string} The id of the captured message.
|
|
916
|
+
*/
|
|
917
|
+
captureMessage(message, level, hint) {
|
|
918
|
+
const eventId = hint?.event_id || uuid4();
|
|
919
|
+
if (!this._client) {
|
|
920
|
+
DEBUG_BUILD && debug.warn("No client configured on scope - will not capture message!");
|
|
921
|
+
return eventId;
|
|
922
|
+
}
|
|
923
|
+
const syntheticException = hint?.syntheticException ?? new Error(message);
|
|
924
|
+
this._client.captureMessage(message, level, {
|
|
925
|
+
originalException: message,
|
|
926
|
+
syntheticException,
|
|
927
|
+
...hint,
|
|
928
|
+
event_id: eventId
|
|
929
|
+
}, this);
|
|
930
|
+
return eventId;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Capture a Sentry event for this scope.
|
|
934
|
+
*
|
|
935
|
+
* @returns {string} The id of the captured event.
|
|
936
|
+
*/
|
|
937
|
+
captureEvent(event, hint) {
|
|
938
|
+
const eventId = event.event_id || hint?.event_id || uuid4();
|
|
939
|
+
if (!this._client) {
|
|
940
|
+
DEBUG_BUILD && debug.warn("No client configured on scope - will not capture event!");
|
|
941
|
+
return eventId;
|
|
942
|
+
}
|
|
943
|
+
this._client.captureEvent(event, {
|
|
944
|
+
...hint,
|
|
945
|
+
event_id: eventId
|
|
946
|
+
}, this);
|
|
947
|
+
return eventId;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* This will be called on every set call.
|
|
951
|
+
*/
|
|
952
|
+
_notifyScopeListeners() {
|
|
953
|
+
if (!this._notifyingListeners) {
|
|
954
|
+
this._notifyingListeners = true;
|
|
955
|
+
this._scopeListeners.forEach((callback) => {
|
|
956
|
+
callback(this);
|
|
957
|
+
});
|
|
958
|
+
this._notifyingListeners = false;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
//#endregion
|
|
963
|
+
//#region node_modules/@sentry/core/build/esm/defaultScopes.js
|
|
964
|
+
function getDefaultCurrentScope() {
|
|
965
|
+
return getGlobalSingleton("defaultCurrentScope", () => new Scope());
|
|
966
|
+
}
|
|
967
|
+
function getDefaultIsolationScope() {
|
|
968
|
+
return getGlobalSingleton("defaultIsolationScope", () => new Scope());
|
|
969
|
+
}
|
|
970
|
+
//#endregion
|
|
971
|
+
//#region node_modules/@sentry/core/build/esm/tracing/constants.js
|
|
972
|
+
const SUPPRESS_TRACING_KEY = "__SENTRY_SUPPRESS_TRACING__";
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js
|
|
975
|
+
const isActualPromise = (p) => p instanceof Promise && !p[kChainedCopy];
|
|
976
|
+
const kChainedCopy = /* @__PURE__ */ Symbol("chained PromiseLike");
|
|
977
|
+
const chainAndCopyPromiseLike = (original, onSuccess, onError) => {
|
|
978
|
+
const chained = original.then((value) => {
|
|
979
|
+
onSuccess(value);
|
|
980
|
+
return value;
|
|
981
|
+
}, (err) => {
|
|
982
|
+
onError(err);
|
|
983
|
+
throw err;
|
|
984
|
+
});
|
|
985
|
+
return isActualPromise(chained) && isActualPromise(original) ? chained : copyProps(original, chained);
|
|
986
|
+
};
|
|
987
|
+
const copyProps = (original, chained) => {
|
|
988
|
+
if (!chained) return original;
|
|
989
|
+
let mutated = false;
|
|
990
|
+
for (const key in original) {
|
|
991
|
+
if (key in chained) continue;
|
|
992
|
+
mutated = true;
|
|
993
|
+
const value = original[key];
|
|
994
|
+
if (typeof value === "function") Object.defineProperty(chained, key, {
|
|
995
|
+
value: (...args) => value.apply(original, args),
|
|
996
|
+
enumerable: true,
|
|
997
|
+
configurable: true,
|
|
998
|
+
writable: true
|
|
999
|
+
});
|
|
1000
|
+
else chained[key] = value;
|
|
1001
|
+
}
|
|
1002
|
+
if (mutated) Object.assign(chained, { [kChainedCopy]: true });
|
|
1003
|
+
return chained;
|
|
1004
|
+
};
|
|
1005
|
+
//#endregion
|
|
1006
|
+
//#region node_modules/@sentry/core/build/esm/asyncContext/stackStrategy.js
|
|
1007
|
+
var AsyncContextStack = class {
|
|
1008
|
+
constructor(scope, isolationScope) {
|
|
1009
|
+
let assignedScope;
|
|
1010
|
+
if (!scope) assignedScope = new Scope();
|
|
1011
|
+
else assignedScope = scope;
|
|
1012
|
+
let assignedIsolationScope;
|
|
1013
|
+
if (!isolationScope) assignedIsolationScope = new Scope();
|
|
1014
|
+
else assignedIsolationScope = isolationScope;
|
|
1015
|
+
this._stack = [{ scope: assignedScope }];
|
|
1016
|
+
this._isolationScope = assignedIsolationScope;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Fork a scope for the stack.
|
|
1020
|
+
*/
|
|
1021
|
+
withScope(callback) {
|
|
1022
|
+
const scope = this._pushScope();
|
|
1023
|
+
let maybePromiseResult;
|
|
1024
|
+
try {
|
|
1025
|
+
maybePromiseResult = callback(scope);
|
|
1026
|
+
} catch (e) {
|
|
1027
|
+
this._popScope();
|
|
1028
|
+
throw e;
|
|
1029
|
+
}
|
|
1030
|
+
if (isThenable(maybePromiseResult)) return chainAndCopyPromiseLike(maybePromiseResult, () => this._popScope(), () => this._popScope());
|
|
1031
|
+
this._popScope();
|
|
1032
|
+
return maybePromiseResult;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Get the client of the stack.
|
|
1036
|
+
*/
|
|
1037
|
+
getClient() {
|
|
1038
|
+
return this.getStackTop().client;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Returns the scope of the top stack.
|
|
1042
|
+
*/
|
|
1043
|
+
getScope() {
|
|
1044
|
+
return this.getStackTop().scope;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the isolation scope for the stack.
|
|
1048
|
+
*/
|
|
1049
|
+
getIsolationScope() {
|
|
1050
|
+
return this._isolationScope;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Returns the topmost scope layer in the order domain > local > process.
|
|
1054
|
+
*/
|
|
1055
|
+
getStackTop() {
|
|
1056
|
+
return this._stack[this._stack.length - 1];
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Push a scope to the stack.
|
|
1060
|
+
*/
|
|
1061
|
+
_pushScope() {
|
|
1062
|
+
const scope = this.getScope().clone();
|
|
1063
|
+
this._stack.push({
|
|
1064
|
+
client: this.getClient(),
|
|
1065
|
+
scope
|
|
1066
|
+
});
|
|
1067
|
+
return scope;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Pop a scope from the stack.
|
|
1071
|
+
*/
|
|
1072
|
+
_popScope() {
|
|
1073
|
+
if (this._stack.length <= 1) return false;
|
|
1074
|
+
return !!this._stack.pop();
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
function getAsyncContextStack() {
|
|
1078
|
+
const sentry = getSentryCarrier(getMainCarrier());
|
|
1079
|
+
return sentry.stack = sentry.stack || new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope());
|
|
1080
|
+
}
|
|
1081
|
+
function withScope$1(callback) {
|
|
1082
|
+
return getAsyncContextStack().withScope(callback);
|
|
1083
|
+
}
|
|
1084
|
+
function withSetScope(scope, callback) {
|
|
1085
|
+
const stack = getAsyncContextStack();
|
|
1086
|
+
return stack.withScope(() => {
|
|
1087
|
+
stack.getStackTop().scope = scope;
|
|
1088
|
+
return callback(scope);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
function withIsolationScope(callback) {
|
|
1092
|
+
return getAsyncContextStack().withScope(() => {
|
|
1093
|
+
return callback(getAsyncContextStack().getIsolationScope());
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
function getStackAsyncContextStrategy() {
|
|
1097
|
+
return {
|
|
1098
|
+
suppressTracing: suppressTracingInStack,
|
|
1099
|
+
withIsolationScope,
|
|
1100
|
+
withScope: withScope$1,
|
|
1101
|
+
withSetScope,
|
|
1102
|
+
withSetIsolationScope: (_isolationScope, callback) => {
|
|
1103
|
+
return withIsolationScope(callback);
|
|
1104
|
+
},
|
|
1105
|
+
getCurrentScope: () => getAsyncContextStack().getScope(),
|
|
1106
|
+
getIsolationScope: () => getAsyncContextStack().getIsolationScope()
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
function suppressTracingInStack(callback) {
|
|
1110
|
+
return withScope$1((scope) => {
|
|
1111
|
+
scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });
|
|
1112
|
+
const res = callback();
|
|
1113
|
+
scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: void 0 });
|
|
1114
|
+
return res;
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region node_modules/@sentry/core/build/esm/asyncContext/index.js
|
|
1119
|
+
function getAsyncContextStrategy(carrier) {
|
|
1120
|
+
const sentry = getSentryCarrier(carrier);
|
|
1121
|
+
if (sentry.acs) return sentry.acs;
|
|
1122
|
+
return getStackAsyncContextStrategy();
|
|
1123
|
+
}
|
|
1124
|
+
//#endregion
|
|
1125
|
+
//#region node_modules/@sentry/core/build/esm/attributes.js
|
|
1126
|
+
function isAttributeObject(maybeObj) {
|
|
1127
|
+
return typeof maybeObj === "object" && maybeObj != null && !Array.isArray(maybeObj) && Object.keys(maybeObj).includes("value");
|
|
1128
|
+
}
|
|
1129
|
+
function attributeValueToTypedAttributeValue(rawValue, useFallback) {
|
|
1130
|
+
const { value, unit } = isAttributeObject(rawValue) ? rawValue : {
|
|
1131
|
+
value: rawValue,
|
|
1132
|
+
unit: void 0
|
|
1133
|
+
};
|
|
1134
|
+
const attributeValue = getTypedAttributeValue(value);
|
|
1135
|
+
const checkedUnit = unit && typeof unit === "string" ? { unit } : {};
|
|
1136
|
+
if (attributeValue) return {
|
|
1137
|
+
...attributeValue,
|
|
1138
|
+
...checkedUnit
|
|
1139
|
+
};
|
|
1140
|
+
if (!useFallback || useFallback === "skip-undefined" && value === void 0) return;
|
|
1141
|
+
let stringValue = "";
|
|
1142
|
+
try {
|
|
1143
|
+
stringValue = JSON.stringify(value) ?? "";
|
|
1144
|
+
} catch {}
|
|
1145
|
+
return {
|
|
1146
|
+
value: stringValue,
|
|
1147
|
+
type: "string",
|
|
1148
|
+
...checkedUnit
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
function serializeAttributes(attributes, fallback = false) {
|
|
1152
|
+
const serializedAttributes = {};
|
|
1153
|
+
for (const [key, value] of Object.entries(attributes ?? {})) {
|
|
1154
|
+
const typedValue = attributeValueToTypedAttributeValue(value, fallback);
|
|
1155
|
+
if (typedValue) serializedAttributes[key] = typedValue;
|
|
1156
|
+
}
|
|
1157
|
+
return serializedAttributes;
|
|
1158
|
+
}
|
|
1159
|
+
function estimateTypedAttributesSizeInBytes(attributes) {
|
|
1160
|
+
if (!attributes) return 0;
|
|
1161
|
+
let weight = 0;
|
|
1162
|
+
for (const [key, attr] of Object.entries(attributes)) {
|
|
1163
|
+
weight += key.length * 2;
|
|
1164
|
+
weight += attr.type.length * 2;
|
|
1165
|
+
weight += (attr.unit?.length ?? 0) * 2;
|
|
1166
|
+
const val = attr.value;
|
|
1167
|
+
if (Array.isArray(val)) weight += estimatePrimitiveSizeInBytes$1(val[0]) * val.length;
|
|
1168
|
+
else if (isPrimitive(val)) weight += estimatePrimitiveSizeInBytes$1(val);
|
|
1169
|
+
else weight += 100;
|
|
1170
|
+
}
|
|
1171
|
+
return weight;
|
|
1172
|
+
}
|
|
1173
|
+
function estimatePrimitiveSizeInBytes$1(value) {
|
|
1174
|
+
if (typeof value === "string") return value.length * 2;
|
|
1175
|
+
else if (typeof value === "boolean") return 4;
|
|
1176
|
+
else if (typeof value === "number") return 8;
|
|
1177
|
+
return 0;
|
|
1178
|
+
}
|
|
1179
|
+
function getTypedAttributeValue(value) {
|
|
1180
|
+
if (Array.isArray(value)) return {
|
|
1181
|
+
value,
|
|
1182
|
+
type: "array"
|
|
1183
|
+
};
|
|
1184
|
+
const primitiveType = typeof value === "string" ? "string" : typeof value === "boolean" ? "boolean" : typeof value === "number" && !Number.isNaN(value) ? Number.isInteger(value) ? "integer" : "double" : null;
|
|
1185
|
+
if (primitiveType) return {
|
|
1186
|
+
value,
|
|
1187
|
+
type: primitiveType
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region node_modules/@sentry/core/build/esm/currentScopes.js
|
|
1192
|
+
function getExternalPropagationContext() {
|
|
1193
|
+
return getSentryCarrier(getMainCarrier()).externalPropagationContextProvider?.();
|
|
1194
|
+
}
|
|
1195
|
+
function getCurrentScope() {
|
|
1196
|
+
return getAsyncContextStrategy(getMainCarrier()).getCurrentScope();
|
|
1197
|
+
}
|
|
1198
|
+
function getIsolationScope() {
|
|
1199
|
+
return getAsyncContextStrategy(getMainCarrier()).getIsolationScope();
|
|
1200
|
+
}
|
|
1201
|
+
function getGlobalScope() {
|
|
1202
|
+
return getGlobalSingleton("globalScope", () => new Scope());
|
|
1203
|
+
}
|
|
1204
|
+
function withScope(...rest) {
|
|
1205
|
+
const acs = getAsyncContextStrategy(getMainCarrier());
|
|
1206
|
+
if (rest.length === 2) {
|
|
1207
|
+
const [scope, callback] = rest;
|
|
1208
|
+
if (!scope) return acs.withScope(callback);
|
|
1209
|
+
return acs.withSetScope(scope, callback);
|
|
1210
|
+
}
|
|
1211
|
+
return acs.withScope(rest[0]);
|
|
1212
|
+
}
|
|
1213
|
+
function getClient() {
|
|
1214
|
+
return getCurrentScope().getClient();
|
|
1215
|
+
}
|
|
1216
|
+
function getTraceContextFromScope(scope) {
|
|
1217
|
+
const externalContext = getExternalPropagationContext();
|
|
1218
|
+
if (externalContext) return {
|
|
1219
|
+
trace_id: externalContext.traceId,
|
|
1220
|
+
span_id: externalContext.spanId
|
|
1221
|
+
};
|
|
1222
|
+
const { traceId, parentSpanId, propagationSpanId } = scope.getPropagationContext();
|
|
1223
|
+
const traceContext = {
|
|
1224
|
+
trace_id: traceId,
|
|
1225
|
+
span_id: propagationSpanId || generateSpanId()
|
|
1226
|
+
};
|
|
1227
|
+
if (parentSpanId) traceContext.parent_span_id = parentSpanId;
|
|
1228
|
+
return traceContext;
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region node_modules/@sentry/conventions/dist/attributes.mjs
|
|
1232
|
+
const zd = "sentry.sdk.name";
|
|
1233
|
+
const Yd = "sentry.sdk.version";
|
|
1234
|
+
const Vd = "sentry.segment.id";
|
|
1235
|
+
const Fd = "sentry.segment.name";
|
|
1236
|
+
const Wd = "sentry.segment.name.source";
|
|
1237
|
+
const ag = "sentry.trace_lifecycle";
|
|
1238
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_OP = "sentry.op";
|
|
1239
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = "sentry.origin";
|
|
1240
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = "sentry.release";
|
|
1241
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = "sentry.environment";
|
|
1242
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS = "sentry.sdk.integrations";
|
|
1243
|
+
const SEMANTIC_ATTRIBUTE_USER_ID = "user.id";
|
|
1244
|
+
const SEMANTIC_ATTRIBUTE_USER_EMAIL = "user.email";
|
|
1245
|
+
const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = "user.ip_address";
|
|
1246
|
+
const SEMANTIC_ATTRIBUTE_USER_USERNAME = "user.name";
|
|
1247
|
+
const SEMANTIC_ATTRIBUTE_PROFILE_ID = "sentry.profile_id";
|
|
1248
|
+
const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = "sentry.exclusive_time";
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region node_modules/@sentry/core/build/esm/types/spanStatus.js
|
|
1251
|
+
const SPAN_STATUS_TYPES = [
|
|
1252
|
+
"ok",
|
|
1253
|
+
"deadline_exceeded",
|
|
1254
|
+
"unauthenticated",
|
|
1255
|
+
"permission_denied",
|
|
1256
|
+
"not_found",
|
|
1257
|
+
"resource_exhausted",
|
|
1258
|
+
"invalid_argument",
|
|
1259
|
+
"unimplemented",
|
|
1260
|
+
"unavailable",
|
|
1261
|
+
"internal_error",
|
|
1262
|
+
"unknown_error",
|
|
1263
|
+
"cancelled",
|
|
1264
|
+
"already_exists",
|
|
1265
|
+
"failed_precondition",
|
|
1266
|
+
"aborted",
|
|
1267
|
+
"out_of_range",
|
|
1268
|
+
"data_loss"
|
|
1269
|
+
];
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spanstatus.js
|
|
1272
|
+
function isStatusErrorMessageValid(message) {
|
|
1273
|
+
return message !== "ok" && SPAN_STATUS_TYPES.includes(message);
|
|
1274
|
+
}
|
|
1275
|
+
//#endregion
|
|
1276
|
+
//#region node_modules/@sentry/core/build/esm/utils/weakRef.js
|
|
1277
|
+
function derefWeakRef(ref) {
|
|
1278
|
+
if (!ref) return;
|
|
1279
|
+
if (typeof ref === "object" && "deref" in ref && typeof ref.deref === "function") try {
|
|
1280
|
+
return ref.deref();
|
|
1281
|
+
} catch {
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
return ref;
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region node_modules/@sentry/core/build/esm/tracing/utils.js
|
|
1288
|
+
const SCOPE_ON_START_SPAN_FIELD = "_sentryScope";
|
|
1289
|
+
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = "_sentryIsolationScope";
|
|
1290
|
+
function getCapturedScopesOnSpan(span) {
|
|
1291
|
+
const spanWithScopes = span;
|
|
1292
|
+
return {
|
|
1293
|
+
scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
|
|
1294
|
+
isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD])
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function baggageHeaderToDynamicSamplingContext(baggageHeader) {
|
|
1298
|
+
const baggageObject = parseBaggageHeader(baggageHeader);
|
|
1299
|
+
if (!baggageObject) return;
|
|
1300
|
+
const dynamicSamplingContext = Object.entries(baggageObject).reduce((acc, [key, value]) => {
|
|
1301
|
+
if (key.startsWith("sentry-")) {
|
|
1302
|
+
const nonPrefixedKey = key.slice(7);
|
|
1303
|
+
acc[nonPrefixedKey] = value;
|
|
1304
|
+
}
|
|
1305
|
+
return acc;
|
|
1306
|
+
}, {});
|
|
1307
|
+
if (Object.keys(dynamicSamplingContext).length > 0) return dynamicSamplingContext;
|
|
1308
|
+
else return;
|
|
1309
|
+
}
|
|
1310
|
+
function parseBaggageHeader(baggageHeader) {
|
|
1311
|
+
if (!baggageHeader || !isString(baggageHeader) && !Array.isArray(baggageHeader)) return;
|
|
1312
|
+
if (Array.isArray(baggageHeader)) return baggageHeader.reduce((acc, curr) => {
|
|
1313
|
+
const currBaggageObject = baggageHeaderToObject(curr);
|
|
1314
|
+
Object.entries(currBaggageObject).forEach(([key, value]) => {
|
|
1315
|
+
acc[key] = value;
|
|
1316
|
+
});
|
|
1317
|
+
return acc;
|
|
1318
|
+
}, {});
|
|
1319
|
+
return baggageHeaderToObject(baggageHeader);
|
|
1320
|
+
}
|
|
1321
|
+
function baggageHeaderToObject(baggageHeader) {
|
|
1322
|
+
return baggageHeader.split(",").map((baggageEntry) => {
|
|
1323
|
+
const eqIdx = baggageEntry.indexOf("=");
|
|
1324
|
+
if (eqIdx === -1) return [];
|
|
1325
|
+
return [baggageEntry.slice(0, eqIdx), baggageEntry.slice(eqIdx + 1)].map((keyOrValue) => {
|
|
1326
|
+
try {
|
|
1327
|
+
return decodeURIComponent(keyOrValue.trim());
|
|
1328
|
+
} catch {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
}).reduce((acc, [key, value]) => {
|
|
1333
|
+
if (key && value) acc[key] = value;
|
|
1334
|
+
return acc;
|
|
1335
|
+
}, {});
|
|
1336
|
+
}
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region node_modules/@sentry/core/build/esm/utils/dsn.js
|
|
1339
|
+
const ORG_ID_REGEX = /^o(\d+)\./;
|
|
1340
|
+
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;
|
|
1341
|
+
function isValidProtocol(protocol) {
|
|
1342
|
+
return protocol === "http" || protocol === "https";
|
|
1343
|
+
}
|
|
1344
|
+
function dsnToString(dsn, withPassword = false) {
|
|
1345
|
+
const { host, path, pass, port, projectId, protocol, publicKey } = dsn;
|
|
1346
|
+
return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path ? `${path}/` : path}${projectId}`;
|
|
1347
|
+
}
|
|
1348
|
+
function dsnFromString(str) {
|
|
1349
|
+
const match = DSN_REGEX.exec(str);
|
|
1350
|
+
if (!match) {
|
|
1351
|
+
consoleSandbox(() => {
|
|
1352
|
+
console.error(`Invalid Sentry Dsn: ${str}`);
|
|
1353
|
+
});
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
const [protocol, publicKey, pass = "", host = "", port = "", lastPath = ""] = match.slice(1);
|
|
1357
|
+
let path = "";
|
|
1358
|
+
let projectId = lastPath;
|
|
1359
|
+
const split = projectId.split("/");
|
|
1360
|
+
if (split.length > 1) {
|
|
1361
|
+
path = split.slice(0, -1).join("/");
|
|
1362
|
+
projectId = split.pop();
|
|
1363
|
+
}
|
|
1364
|
+
if (projectId) {
|
|
1365
|
+
const projectMatch = projectId.match(/^\d+/);
|
|
1366
|
+
if (projectMatch) projectId = projectMatch[0];
|
|
1367
|
+
}
|
|
1368
|
+
return dsnFromComponents({
|
|
1369
|
+
host,
|
|
1370
|
+
pass,
|
|
1371
|
+
path,
|
|
1372
|
+
projectId,
|
|
1373
|
+
port,
|
|
1374
|
+
protocol,
|
|
1375
|
+
publicKey
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
function dsnFromComponents(components) {
|
|
1379
|
+
return {
|
|
1380
|
+
protocol: components.protocol,
|
|
1381
|
+
publicKey: components.publicKey || "",
|
|
1382
|
+
pass: components.pass || "",
|
|
1383
|
+
host: components.host,
|
|
1384
|
+
port: components.port || "",
|
|
1385
|
+
path: components.path || "",
|
|
1386
|
+
projectId: components.projectId
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
function validateDsn(dsn) {
|
|
1390
|
+
if (!DEBUG_BUILD) return true;
|
|
1391
|
+
const { port, projectId, protocol } = dsn;
|
|
1392
|
+
if ([
|
|
1393
|
+
"protocol",
|
|
1394
|
+
"publicKey",
|
|
1395
|
+
"host",
|
|
1396
|
+
"projectId"
|
|
1397
|
+
].find((component) => {
|
|
1398
|
+
if (!dsn[component]) {
|
|
1399
|
+
debug.error(`Invalid Sentry Dsn: ${component} missing`);
|
|
1400
|
+
return true;
|
|
1401
|
+
}
|
|
1402
|
+
return false;
|
|
1403
|
+
})) return false;
|
|
1404
|
+
if (!projectId.match(/^\d+$/)) {
|
|
1405
|
+
debug.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
if (!isValidProtocol(protocol)) {
|
|
1409
|
+
debug.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
|
|
1410
|
+
return false;
|
|
1411
|
+
}
|
|
1412
|
+
if (port && isNaN(parseInt(port, 10))) {
|
|
1413
|
+
debug.error(`Invalid Sentry Dsn: Invalid port ${port}`);
|
|
1414
|
+
return false;
|
|
1415
|
+
}
|
|
1416
|
+
return true;
|
|
1417
|
+
}
|
|
1418
|
+
function extractOrgIdFromDsnHost(host) {
|
|
1419
|
+
return host.match(ORG_ID_REGEX)?.[1];
|
|
1420
|
+
}
|
|
1421
|
+
function extractOrgIdFromClient(client) {
|
|
1422
|
+
const options = client.getOptions();
|
|
1423
|
+
const { host } = client.getDsn() || {};
|
|
1424
|
+
let org_id;
|
|
1425
|
+
if (options.orgId) org_id = String(options.orgId);
|
|
1426
|
+
else if (host) org_id = extractOrgIdFromDsnHost(host);
|
|
1427
|
+
return org_id;
|
|
1428
|
+
}
|
|
1429
|
+
function makeDsn(from) {
|
|
1430
|
+
const components = typeof from === "string" ? dsnFromString(from) : dsnFromComponents(from);
|
|
1431
|
+
if (!components || !validateDsn(components)) return;
|
|
1432
|
+
return components;
|
|
1433
|
+
}
|
|
1434
|
+
//#endregion
|
|
1435
|
+
//#region node_modules/@sentry/core/build/esm/utils/parseSampleRate.js
|
|
1436
|
+
function parseSampleRate(sampleRate) {
|
|
1437
|
+
if (typeof sampleRate === "boolean") return Number(sampleRate);
|
|
1438
|
+
const rate = typeof sampleRate === "string" ? parseFloat(sampleRate) : sampleRate;
|
|
1439
|
+
if (typeof rate !== "number" || isNaN(rate) || rate < 0 || rate > 1) return;
|
|
1440
|
+
return rate;
|
|
1441
|
+
}
|
|
1442
|
+
//#endregion
|
|
1443
|
+
//#region node_modules/@sentry/core/build/esm/utils/spanOnScope.js
|
|
1444
|
+
const SCOPE_SPAN_FIELD = "span";
|
|
1445
|
+
function _getSpanForScope(scope) {
|
|
1446
|
+
return derefWeakRef(scope.refs[SCOPE_SPAN_FIELD]);
|
|
1447
|
+
}
|
|
1448
|
+
function spanToTraceContext(span) {
|
|
1449
|
+
const { spanId, traceId: trace_id, isRemote } = span.spanContext();
|
|
1450
|
+
const parent_span_id = isRemote ? spanId : spanToStaticSpanJSON(span).parent_span_id;
|
|
1451
|
+
const scope = getCapturedScopesOnSpan(span).scope;
|
|
1452
|
+
return {
|
|
1453
|
+
parent_span_id,
|
|
1454
|
+
span_id: isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId,
|
|
1455
|
+
trace_id
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
function convertSpanLinksForEnvelope(links) {
|
|
1459
|
+
if (links && links.length > 0) return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({
|
|
1460
|
+
span_id: spanId,
|
|
1461
|
+
trace_id: traceId,
|
|
1462
|
+
sampled: traceFlags === 1,
|
|
1463
|
+
attributes,
|
|
1464
|
+
...restContext
|
|
1465
|
+
}));
|
|
1466
|
+
else return;
|
|
1467
|
+
}
|
|
1468
|
+
function getStreamedSpanLinks(links) {
|
|
1469
|
+
if (links?.length) return links.map(({ context: { spanId, traceId, traceFlags }, attributes }) => ({
|
|
1470
|
+
span_id: spanId,
|
|
1471
|
+
trace_id: traceId,
|
|
1472
|
+
sampled: traceFlags === 1,
|
|
1473
|
+
attributes
|
|
1474
|
+
}));
|
|
1475
|
+
else return;
|
|
1476
|
+
}
|
|
1477
|
+
function spanTimeInputToSeconds(input) {
|
|
1478
|
+
if (typeof input === "number") return ensureTimestampInSeconds(input);
|
|
1479
|
+
if (Array.isArray(input)) return input[0] + input[1] / 1e9;
|
|
1480
|
+
if (input instanceof Date) return ensureTimestampInSeconds(input.getTime());
|
|
1481
|
+
return timestampInSeconds();
|
|
1482
|
+
}
|
|
1483
|
+
function ensureTimestampInSeconds(timestamp) {
|
|
1484
|
+
return timestamp > 9999999999 ? timestamp / 1e3 : timestamp;
|
|
1485
|
+
}
|
|
1486
|
+
function spanToStaticSpanJSON(span) {
|
|
1487
|
+
if (spanIsSentrySpan(span)) return span.getStaticSpanJSON();
|
|
1488
|
+
const { spanId: span_id, traceId: trace_id } = span.spanContext();
|
|
1489
|
+
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
|
|
1490
|
+
const { attributes, startTime, name, endTime, status, links } = span;
|
|
1491
|
+
return {
|
|
1492
|
+
span_id,
|
|
1493
|
+
trace_id,
|
|
1494
|
+
data: attributes,
|
|
1495
|
+
description: name,
|
|
1496
|
+
parent_span_id: getOtelParentSpanId(span),
|
|
1497
|
+
start_timestamp: spanTimeInputToSeconds(startTime),
|
|
1498
|
+
timestamp: spanTimeInputToSeconds(endTime) || void 0,
|
|
1499
|
+
status: getStatusMessage(status),
|
|
1500
|
+
op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
|
|
1501
|
+
origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN],
|
|
1502
|
+
links: convertSpanLinksForEnvelope(links)
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
return {
|
|
1506
|
+
span_id,
|
|
1507
|
+
trace_id,
|
|
1508
|
+
start_timestamp: 0,
|
|
1509
|
+
status: "ok",
|
|
1510
|
+
data: {}
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function spanToJSON(span) {
|
|
1514
|
+
if (spanIsSentrySpan(span)) return span.getSpanJSON();
|
|
1515
|
+
const { spanId: span_id, traceId: trace_id } = span.spanContext();
|
|
1516
|
+
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
|
|
1517
|
+
const { attributes, startTime, name, endTime, status, links } = span;
|
|
1518
|
+
return {
|
|
1519
|
+
name,
|
|
1520
|
+
span_id,
|
|
1521
|
+
trace_id,
|
|
1522
|
+
parent_span_id: getOtelParentSpanId(span),
|
|
1523
|
+
start_timestamp: spanTimeInputToSeconds(startTime),
|
|
1524
|
+
end_timestamp: spanTimeInputToSeconds(endTime) || void 0,
|
|
1525
|
+
is_segment: spanIsSegment(span),
|
|
1526
|
+
status: getSimpleStatus(status),
|
|
1527
|
+
attributes: addStatusMessageAttribute(attributes, status),
|
|
1528
|
+
links: getStreamedSpanLinks(links)
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
return {
|
|
1532
|
+
span_id,
|
|
1533
|
+
trace_id,
|
|
1534
|
+
start_timestamp: 0,
|
|
1535
|
+
name: "",
|
|
1536
|
+
status: "ok",
|
|
1537
|
+
is_segment: spanIsSegment(span),
|
|
1538
|
+
attributes: {}
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
function getOtelParentSpanId(span) {
|
|
1542
|
+
return "parentSpanId" in span ? span.parentSpanId : "parentSpanContext" in span ? span.parentSpanContext?.spanId : void 0;
|
|
1543
|
+
}
|
|
1544
|
+
function streamedSpanJsonToSerializedSpan(spanJson) {
|
|
1545
|
+
return {
|
|
1546
|
+
...spanJson,
|
|
1547
|
+
end_timestamp: spanJson.end_timestamp ?? spanJson.start_timestamp,
|
|
1548
|
+
attributes: serializeAttributes(spanJson.attributes),
|
|
1549
|
+
links: spanJson.links?.map((link) => ({
|
|
1550
|
+
...link,
|
|
1551
|
+
attributes: serializeAttributes(link.attributes)
|
|
1552
|
+
}))
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
function spanIsOpenTelemetrySdkTraceBaseSpan(span) {
|
|
1556
|
+
const castSpan = span;
|
|
1557
|
+
return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;
|
|
1558
|
+
}
|
|
1559
|
+
function spanIsSentrySpan(span) {
|
|
1560
|
+
return typeof span.getSpanJSON === "function";
|
|
1561
|
+
}
|
|
1562
|
+
function spanIsSampled(span) {
|
|
1563
|
+
const { traceFlags } = span.spanContext();
|
|
1564
|
+
return traceFlags === 1;
|
|
1565
|
+
}
|
|
1566
|
+
function getStatusMessage(status) {
|
|
1567
|
+
if (!status || status.code === 0) return "ok";
|
|
1568
|
+
if (status.code === 1) return "ok";
|
|
1569
|
+
return status.message && isStatusErrorMessageValid(status.message) ? status.message : "internal_error";
|
|
1570
|
+
}
|
|
1571
|
+
function getSimpleStatus(status) {
|
|
1572
|
+
return !status || status.code === 1 || status.code === 0 || status.message === "cancelled" ? "ok" : "error";
|
|
1573
|
+
}
|
|
1574
|
+
function addStatusMessageAttribute(attributes, status) {
|
|
1575
|
+
const statusMessage = getSimpleStatus(status) === "error" ? status?.message : void 0;
|
|
1576
|
+
return {
|
|
1577
|
+
...statusMessage && { ["sentry.status.message"]: statusMessage },
|
|
1578
|
+
...attributes
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
const ROOT_SPAN_FIELD = "_sentryRootSpan";
|
|
1582
|
+
const getRootSpan = INTERNAL_getSegmentSpan;
|
|
1583
|
+
function INTERNAL_getSegmentSpan(span) {
|
|
1584
|
+
return span[ROOT_SPAN_FIELD] || span;
|
|
1585
|
+
}
|
|
1586
|
+
function spanIsSegment(span) {
|
|
1587
|
+
return span === INTERNAL_getSegmentSpan(span);
|
|
1588
|
+
}
|
|
1589
|
+
function getActiveSpan(scope) {
|
|
1590
|
+
const acs = getAsyncContextStrategy(getMainCarrier());
|
|
1591
|
+
if (acs.getActiveSpan) return acs.getActiveSpan(scope);
|
|
1592
|
+
return _getSpanForScope(scope || getCurrentScope());
|
|
1593
|
+
}
|
|
1594
|
+
//#endregion
|
|
1595
|
+
//#region node_modules/@sentry/core/build/esm/utils/hasSpansEnabled.js
|
|
1596
|
+
function hasSpansEnabled(maybeOptions) {
|
|
1597
|
+
if (typeof __SENTRY_TRACING__ === "boolean" && !__SENTRY_TRACING__) return false;
|
|
1598
|
+
const options = maybeOptions || getClient()?.getOptions();
|
|
1599
|
+
return !!options && (options.tracesSampleRate != null || !!options.tracesSampler);
|
|
1600
|
+
}
|
|
1601
|
+
//#endregion
|
|
1602
|
+
//#region node_modules/@sentry/core/build/esm/utils/should-ignore-span.js
|
|
1603
|
+
function logIgnoredSpan(droppedSpan) {
|
|
1604
|
+
debug.log(`Ignoring span ${droppedSpan.op} - ${droppedSpan.description} because it matches \`ignoreSpans\`.`);
|
|
1605
|
+
}
|
|
1606
|
+
function shouldIgnoreSpan(span, ignoreSpans) {
|
|
1607
|
+
if (!ignoreSpans?.length) return false;
|
|
1608
|
+
for (const pattern of ignoreSpans) {
|
|
1609
|
+
if (isStringOrRegExp(pattern)) {
|
|
1610
|
+
if (span.description && isMatchingPattern(span.description, pattern)) {
|
|
1611
|
+
DEBUG_BUILD && logIgnoredSpan(span);
|
|
1612
|
+
return true;
|
|
1613
|
+
}
|
|
1614
|
+
continue;
|
|
1615
|
+
}
|
|
1616
|
+
const hasAttributes = !!pattern.attributes && Object.keys(pattern.attributes).length > 0;
|
|
1617
|
+
if (!pattern.name && !pattern.op && !hasAttributes) continue;
|
|
1618
|
+
const nameMatches = pattern.name ? span.description && isMatchingPattern(span.description, pattern.name) : true;
|
|
1619
|
+
const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true;
|
|
1620
|
+
const attrsMatch = pattern.attributes ? Object.entries(pattern.attributes).every(([key, valuePattern]) => _matchesAttributeValue(span.attributes?.[key], valuePattern)) : true;
|
|
1621
|
+
if (nameMatches && opMatches && attrsMatch) {
|
|
1622
|
+
DEBUG_BUILD && logIgnoredSpan(span);
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1628
|
+
function _matchesAttributeValue(actual, pat) {
|
|
1629
|
+
if (typeof actual === "string" && (typeof pat === "string" || pat instanceof RegExp)) return isMatchingPattern(actual, pat);
|
|
1630
|
+
if (Array.isArray(actual) && Array.isArray(pat)) return actual.length === pat.length && actual.every((v, i) => v === pat[i]);
|
|
1631
|
+
return actual === pat;
|
|
1632
|
+
}
|
|
1633
|
+
function reparentChildSpans(spans, dropSpan) {
|
|
1634
|
+
const droppedSpanParentId = dropSpan.parent_span_id;
|
|
1635
|
+
const droppedSpanId = dropSpan.span_id;
|
|
1636
|
+
if (!droppedSpanParentId) return;
|
|
1637
|
+
for (const span of spans) if (span.parent_span_id === droppedSpanId) span.parent_span_id = droppedSpanParentId;
|
|
1638
|
+
}
|
|
1639
|
+
function isStringOrRegExp(value) {
|
|
1640
|
+
return typeof value === "string" || value instanceof RegExp;
|
|
1641
|
+
}
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region node_modules/@sentry/core/build/esm/integration.js
|
|
1644
|
+
const installedIntegrations = [];
|
|
1645
|
+
function setupIntegrations(client, integrations) {
|
|
1646
|
+
const integrationIndex = {};
|
|
1647
|
+
integrations.forEach((integration) => {
|
|
1648
|
+
if (integration?.beforeSetup) integration.beforeSetup(client);
|
|
1649
|
+
});
|
|
1650
|
+
integrations.forEach((integration) => {
|
|
1651
|
+
if (integration) setupIntegration(client, integration, integrationIndex);
|
|
1652
|
+
});
|
|
1653
|
+
return integrationIndex;
|
|
1654
|
+
}
|
|
1655
|
+
function afterSetupIntegrations(client, integrations) {
|
|
1656
|
+
for (const integration of integrations) if (integration?.afterAllSetup) integration.afterAllSetup(client);
|
|
1657
|
+
}
|
|
1658
|
+
function setupIntegration(client, integration, integrationIndex) {
|
|
1659
|
+
if (integrationIndex[integration.name]) {
|
|
1660
|
+
DEBUG_BUILD && debug.log(`Integration skipped because it was already installed: ${integration.name}`);
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
integrationIndex[integration.name] = integration;
|
|
1664
|
+
if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === "function") {
|
|
1665
|
+
integration.setupOnce();
|
|
1666
|
+
installedIntegrations.push(integration.name);
|
|
1667
|
+
}
|
|
1668
|
+
if (integration.setup && typeof integration.setup === "function") integration.setup(client);
|
|
1669
|
+
if (typeof integration.preprocessEvent === "function") {
|
|
1670
|
+
const callback = integration.preprocessEvent.bind(integration);
|
|
1671
|
+
client.on("preprocessEvent", (event, hint) => callback(event, hint, client));
|
|
1672
|
+
}
|
|
1673
|
+
if (typeof integration.processEvent === "function") {
|
|
1674
|
+
const callback = integration.processEvent.bind(integration);
|
|
1675
|
+
const processor = Object.assign((event, hint) => callback(event, hint, client), { id: integration.name });
|
|
1676
|
+
client.addEventProcessor(processor);
|
|
1677
|
+
}
|
|
1678
|
+
["processSpan", "processSegmentSpan"].forEach((hook) => {
|
|
1679
|
+
const callback = integration[hook];
|
|
1680
|
+
if (typeof callback === "function") client.on(hook, (span) => callback.call(integration, span, client));
|
|
1681
|
+
});
|
|
1682
|
+
DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);
|
|
1683
|
+
}
|
|
1684
|
+
function defineIntegration(fn) {
|
|
1685
|
+
return fn;
|
|
1686
|
+
}
|
|
1687
|
+
//#endregion
|
|
1688
|
+
//#region node_modules/@sentry/core/build/esm/constants.js
|
|
1689
|
+
const DEFAULT_ENVIRONMENT = "production";
|
|
1690
|
+
//#endregion
|
|
1691
|
+
//#region node_modules/@sentry/core/build/esm/tracing/sentryNonRecordingSpan.js
|
|
1692
|
+
const NON_RECORDING_SPAN_FIELD = /* @__PURE__ */ Symbol.for("sentry.nonRecordingSpan");
|
|
1693
|
+
function spanIsNonRecordingSpan(span) {
|
|
1694
|
+
return !!span && span[NON_RECORDING_SPAN_FIELD] === true;
|
|
1695
|
+
}
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region node_modules/@sentry/core/build/esm/tracing/dynamicSamplingContext.js
|
|
1698
|
+
const FROZEN_DSC_FIELD = "_frozenDsc";
|
|
1699
|
+
function getDynamicSamplingContextFromClient(trace_id, client) {
|
|
1700
|
+
const options = client.getOptions();
|
|
1701
|
+
const { publicKey: public_key } = client.getDsn() || {};
|
|
1702
|
+
const dsc = {
|
|
1703
|
+
environment: options.environment || "production",
|
|
1704
|
+
release: options.release,
|
|
1705
|
+
public_key,
|
|
1706
|
+
trace_id,
|
|
1707
|
+
org_id: extractOrgIdFromClient(client)
|
|
1708
|
+
};
|
|
1709
|
+
client.emit("createDsc", dsc);
|
|
1710
|
+
return dsc;
|
|
1711
|
+
}
|
|
1712
|
+
function getDynamicSamplingContextFromScope(client, scope) {
|
|
1713
|
+
if (getExternalPropagationContext()) return;
|
|
1714
|
+
const propagationContext = scope.getPropagationContext();
|
|
1715
|
+
return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);
|
|
1716
|
+
}
|
|
1717
|
+
function getDynamicSamplingContextFromSpan(span) {
|
|
1718
|
+
const client = getClient();
|
|
1719
|
+
if (!client) return {};
|
|
1720
|
+
const rootSpan = getRootSpan(span);
|
|
1721
|
+
const rootSpanJson = spanToStaticSpanJSON(rootSpan);
|
|
1722
|
+
const rootSpanAttributes = rootSpanJson.data;
|
|
1723
|
+
const traceState = rootSpan.spanContext().traceState;
|
|
1724
|
+
const rootSpanSampleRate = traceState?.get("sentry.sample_rate") ?? rootSpanAttributes["sentry.sample_rate"] ?? rootSpanAttributes["sentry.previous_trace_sample_rate"];
|
|
1725
|
+
function applyLocalSampleRateToDsc(dsc2) {
|
|
1726
|
+
if (typeof rootSpanSampleRate === "number" || typeof rootSpanSampleRate === "string") dsc2.sample_rate = `${rootSpanSampleRate}`;
|
|
1727
|
+
return dsc2;
|
|
1728
|
+
}
|
|
1729
|
+
const frozenDsc = rootSpan[FROZEN_DSC_FIELD];
|
|
1730
|
+
if (frozenDsc) return applyLocalSampleRateToDsc(frozenDsc);
|
|
1731
|
+
const isNonRecordingRoot = spanIsNonRecordingSpan(rootSpan);
|
|
1732
|
+
const isIgnoredRoot = isNonRecordingRoot && rootSpan.dropReason === "ignored";
|
|
1733
|
+
if (isNonRecordingRoot && (!hasSpansEnabled(client.getOptions()) || isIgnoredRoot)) {
|
|
1734
|
+
const capturedScope = getCapturedScopesOnSpan(rootSpan).scope;
|
|
1735
|
+
const scopeDsc = capturedScope && getDynamicSamplingContextFromScope(client, capturedScope);
|
|
1736
|
+
if (scopeDsc) {
|
|
1737
|
+
const dsc2 = { ...scopeDsc };
|
|
1738
|
+
if (isIgnoredRoot) dsc2.sampled = "false";
|
|
1739
|
+
return applyLocalSampleRateToDsc(dsc2);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const traceStateDsc = traceState?.get("sentry.dsc");
|
|
1743
|
+
const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);
|
|
1744
|
+
if (dscOnTraceState) return applyLocalSampleRateToDsc(dscOnTraceState);
|
|
1745
|
+
const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
|
|
1746
|
+
const source = rootSpanAttributes[Wd];
|
|
1747
|
+
const name = rootSpanJson.description;
|
|
1748
|
+
if (source !== "url" && name) dsc.transaction = name;
|
|
1749
|
+
if (hasSpansEnabled()) {
|
|
1750
|
+
dsc.sampled = String(spanIsSampled(rootSpan));
|
|
1751
|
+
dsc.sample_rand = traceState?.get("sentry.sample_rand") ?? getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();
|
|
1752
|
+
}
|
|
1753
|
+
applyLocalSampleRateToDsc(dsc);
|
|
1754
|
+
client.emit("createDsc", dsc, rootSpan);
|
|
1755
|
+
return dsc;
|
|
1756
|
+
}
|
|
1757
|
+
//#endregion
|
|
1758
|
+
//#region node_modules/@sentry/core/build/esm/utils/scopeData.js
|
|
1759
|
+
function applyScopeDataToEvent(event, data) {
|
|
1760
|
+
const { fingerprint, breadcrumbs, sdkProcessingMetadata } = data;
|
|
1761
|
+
applyDataToEvent(event, data);
|
|
1762
|
+
applyFingerprintToEvent(event, fingerprint);
|
|
1763
|
+
applyBreadcrumbsToEvent(event, breadcrumbs);
|
|
1764
|
+
applySdkMetadataToEvent(event, sdkProcessingMetadata);
|
|
1765
|
+
}
|
|
1766
|
+
function mergeScopeData(data, mergeData) {
|
|
1767
|
+
const { extra, tags, attributes, user, contexts, level, sdkProcessingMetadata, breadcrumbs, fingerprint, eventProcessors, attachments, propagationContext, transactionName } = mergeData;
|
|
1768
|
+
mergeAndOverwriteScopeData(data, "extra", extra);
|
|
1769
|
+
mergeAndOverwriteScopeData(data, "tags", tags);
|
|
1770
|
+
mergeAndOverwriteScopeData(data, "attributes", attributes);
|
|
1771
|
+
mergeAndOverwriteScopeData(data, "user", user);
|
|
1772
|
+
mergeAndOverwriteScopeData(data, "contexts", contexts);
|
|
1773
|
+
data.sdkProcessingMetadata = merge(data.sdkProcessingMetadata, sdkProcessingMetadata, 2);
|
|
1774
|
+
if (level) data.level = level;
|
|
1775
|
+
if (transactionName) data.transactionName = transactionName;
|
|
1776
|
+
if (breadcrumbs.length) data.breadcrumbs = [...data.breadcrumbs, ...breadcrumbs];
|
|
1777
|
+
if (fingerprint.length) data.fingerprint = [...data.fingerprint, ...fingerprint];
|
|
1778
|
+
if (eventProcessors.length) data.eventProcessors = [...data.eventProcessors, ...eventProcessors];
|
|
1779
|
+
if (attachments.length) data.attachments = [...data.attachments, ...attachments];
|
|
1780
|
+
data.propagationContext = {
|
|
1781
|
+
...data.propagationContext,
|
|
1782
|
+
...propagationContext
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
function mergeAndOverwriteScopeData(data, prop, mergeVal) {
|
|
1786
|
+
data[prop] = merge(data[prop], mergeVal, 1);
|
|
1787
|
+
}
|
|
1788
|
+
function getCombinedScopeData(isolationScope, currentScope) {
|
|
1789
|
+
const scopeData = getGlobalScope().getScopeData();
|
|
1790
|
+
isolationScope && mergeScopeData(scopeData, isolationScope.getScopeData());
|
|
1791
|
+
currentScope && mergeScopeData(scopeData, currentScope.getScopeData());
|
|
1792
|
+
return scopeData;
|
|
1793
|
+
}
|
|
1794
|
+
function applyDataToEvent(event, data) {
|
|
1795
|
+
const { extra, tags, user, contexts, level, transactionName } = data;
|
|
1796
|
+
if (Object.keys(extra).length) event.extra = {
|
|
1797
|
+
...extra,
|
|
1798
|
+
...event.extra
|
|
1799
|
+
};
|
|
1800
|
+
if (Object.keys(tags).length) event.tags = {
|
|
1801
|
+
...tags,
|
|
1802
|
+
...event.tags
|
|
1803
|
+
};
|
|
1804
|
+
if (Object.keys(user).length) event.user = {
|
|
1805
|
+
...user,
|
|
1806
|
+
...event.user
|
|
1807
|
+
};
|
|
1808
|
+
if (Object.keys(contexts).length) event.contexts = {
|
|
1809
|
+
...contexts,
|
|
1810
|
+
...event.contexts
|
|
1811
|
+
};
|
|
1812
|
+
if (level) event.level = level;
|
|
1813
|
+
if (transactionName && event.type !== "transaction") event.transaction = transactionName;
|
|
1814
|
+
}
|
|
1815
|
+
function applyBreadcrumbsToEvent(event, breadcrumbs) {
|
|
1816
|
+
const mergedBreadcrumbs = [...event.breadcrumbs || [], ...breadcrumbs];
|
|
1817
|
+
event.breadcrumbs = mergedBreadcrumbs.length ? mergedBreadcrumbs : void 0;
|
|
1818
|
+
}
|
|
1819
|
+
function applySdkMetadataToEvent(event, sdkProcessingMetadata) {
|
|
1820
|
+
event.sdkProcessingMetadata = {
|
|
1821
|
+
...event.sdkProcessingMetadata,
|
|
1822
|
+
...sdkProcessingMetadata
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
function applySpanToEvent(event, span) {
|
|
1826
|
+
event.contexts = {
|
|
1827
|
+
trace: spanToTraceContext(span),
|
|
1828
|
+
...event.contexts
|
|
1829
|
+
};
|
|
1830
|
+
event.sdkProcessingMetadata = {
|
|
1831
|
+
dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),
|
|
1832
|
+
...event.sdkProcessingMetadata
|
|
1833
|
+
};
|
|
1834
|
+
const transactionName = spanToStaticSpanJSON(getRootSpan(span)).description;
|
|
1835
|
+
if (transactionName && !event.transaction && event.type === "transaction") event.transaction = transactionName;
|
|
1836
|
+
}
|
|
1837
|
+
function applyFingerprintToEvent(event, fingerprint) {
|
|
1838
|
+
event.fingerprint = event.fingerprint ? Array.isArray(event.fingerprint) ? event.fingerprint : [event.fingerprint] : [];
|
|
1839
|
+
if (fingerprint) event.fingerprint = event.fingerprint.concat(fingerprint);
|
|
1840
|
+
if (!event.fingerprint.length) delete event.fingerprint;
|
|
1841
|
+
}
|
|
1842
|
+
//#endregion
|
|
1843
|
+
//#region node_modules/@sentry/core/build/esm/utils/safeCallback.js
|
|
1844
|
+
function safeCallback(message, fn, fallback) {
|
|
1845
|
+
let result;
|
|
1846
|
+
try {
|
|
1847
|
+
result = fn();
|
|
1848
|
+
} catch (error) {
|
|
1849
|
+
return recover(message, error, fallback);
|
|
1850
|
+
}
|
|
1851
|
+
if (isThenable(result)) return result.then(void 0, (error) => recover(message, error, fallback));
|
|
1852
|
+
return result;
|
|
1853
|
+
}
|
|
1854
|
+
function recover(message, error, fallback) {
|
|
1855
|
+
DEBUG_BUILD && debug.error(message, error);
|
|
1856
|
+
return fallback(error);
|
|
1857
|
+
}
|
|
1858
|
+
//#endregion
|
|
1859
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/beforeSendSpan.js
|
|
1860
|
+
function isStaticBeforeSendSpanCallback(callback) {
|
|
1861
|
+
return !!callback && typeof callback === "function" && "_static" in callback && !!callback._static;
|
|
1862
|
+
}
|
|
1863
|
+
let hasShownSpanDropWarning = false;
|
|
1864
|
+
function applyBeforeSendSpanCallback(span, beforeSendSpan) {
|
|
1865
|
+
const modifiedSpan = safeCallback(DEBUG_BUILD ? "The `beforeSendSpan` callback threw an error, sending the span unmodified:" : "", () => beforeSendSpan(span), () => span);
|
|
1866
|
+
if (modifiedSpan) return modifiedSpan;
|
|
1867
|
+
if (!hasShownSpanDropWarning) {
|
|
1868
|
+
consoleSandbox(() => {
|
|
1869
|
+
console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.");
|
|
1870
|
+
});
|
|
1871
|
+
hasShownSpanDropWarning = true;
|
|
1872
|
+
}
|
|
1873
|
+
return span;
|
|
1874
|
+
}
|
|
1875
|
+
//#endregion
|
|
1876
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/spanJsonToStreamedSpan.js
|
|
1877
|
+
function spanJsonToSerializedStreamedSpan(span) {
|
|
1878
|
+
return streamedSpanJsonToSerializedSpan({
|
|
1879
|
+
trace_id: span.trace_id,
|
|
1880
|
+
span_id: span.span_id,
|
|
1881
|
+
parent_span_id: span.parent_span_id,
|
|
1882
|
+
name: span.description || "",
|
|
1883
|
+
start_timestamp: span.start_timestamp,
|
|
1884
|
+
end_timestamp: span.timestamp,
|
|
1885
|
+
status: !span.status || span.status === "ok" || span.status === "cancelled" ? "ok" : "error",
|
|
1886
|
+
is_segment: false,
|
|
1887
|
+
attributes: { ...span.data },
|
|
1888
|
+
links: span.links
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
//#endregion
|
|
1892
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/scopeContextAttributes.js
|
|
1893
|
+
function scopeContextsToSpanAttributes(contexts) {
|
|
1894
|
+
const attrs = {};
|
|
1895
|
+
const { response, profile, cloud_resource, culture, state } = contexts;
|
|
1896
|
+
if (response) {
|
|
1897
|
+
if (response.status_code != null) attrs["http.response.status_code"] = response.status_code;
|
|
1898
|
+
if (response.body_size != null) attrs["http.response.body.size"] = response.body_size;
|
|
1899
|
+
}
|
|
1900
|
+
if (profile) {
|
|
1901
|
+
if (profile.profile_id) attrs["sentry.profile_id"] = profile.profile_id;
|
|
1902
|
+
if (profile.profiler_id) attrs["sentry.profiler_id"] = profile.profiler_id;
|
|
1903
|
+
}
|
|
1904
|
+
if (cloud_resource) {
|
|
1905
|
+
for (const [key, value] of Object.entries(cloud_resource)) if (value != null) attrs[key] = value;
|
|
1906
|
+
}
|
|
1907
|
+
if (culture) {
|
|
1908
|
+
if (culture.locale) attrs["culture.locale"] = culture.locale;
|
|
1909
|
+
if (culture.timezone) attrs["culture.timezone"] = culture.timezone;
|
|
1910
|
+
}
|
|
1911
|
+
if (state?.state && typeof state.state.type === "string") attrs["state.type"] = state.state.type;
|
|
1912
|
+
const angular = contexts["angular"];
|
|
1913
|
+
if (angular) {
|
|
1914
|
+
const version = angular["version"];
|
|
1915
|
+
if (typeof version === "string" || typeof version === "number") attrs["angular.version"] = version;
|
|
1916
|
+
}
|
|
1917
|
+
const react = contexts["react"];
|
|
1918
|
+
if (react) {
|
|
1919
|
+
const version = react["version"];
|
|
1920
|
+
if (typeof version === "string" || typeof version === "number") attrs["react.version"] = version;
|
|
1921
|
+
}
|
|
1922
|
+
return attrs;
|
|
1923
|
+
}
|
|
1924
|
+
//#endregion
|
|
1925
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/captureSpan.js
|
|
1926
|
+
function captureSpan(span, client) {
|
|
1927
|
+
const spanJSON = spanToJSON(span);
|
|
1928
|
+
const segmentSpan = INTERNAL_getSegmentSpan(span);
|
|
1929
|
+
const serializedSegmentSpan = spanToJSON(segmentSpan);
|
|
1930
|
+
const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);
|
|
1931
|
+
const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);
|
|
1932
|
+
applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);
|
|
1933
|
+
client.emit("preprocessSpan", spanJSON);
|
|
1934
|
+
if (spanJSON.is_segment) {
|
|
1935
|
+
applyScopeToSegmentSpan(spanJSON, finalScopeData);
|
|
1936
|
+
applySdkMetadataToSegmentSpan(spanJSON, client);
|
|
1937
|
+
client.emit("processSegmentSpan", spanJSON);
|
|
1938
|
+
}
|
|
1939
|
+
client.emit("processSpan", spanJSON);
|
|
1940
|
+
const { beforeSendSpan, traceLifecycle } = client.getOptions();
|
|
1941
|
+
return {
|
|
1942
|
+
...streamedSpanJsonToSerializedSpan(traceLifecycle !== "static" && beforeSendSpan && !isStaticBeforeSendSpanCallback(beforeSendSpan) ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan) : spanJSON),
|
|
1943
|
+
_segmentSpan: segmentSpan
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
function applyScopeToSegmentSpan(segmentSpanJSON, scopeData) {
|
|
1947
|
+
safeSetSpanJSONAttributes(segmentSpanJSON, scopeContextsToSpanAttributes(scopeData.contexts));
|
|
1948
|
+
}
|
|
1949
|
+
function safeSetSpanJSONAttributes(spanJSON, newAttributes) {
|
|
1950
|
+
const originalAttributes = spanJSON.attributes ?? (spanJSON.attributes = {});
|
|
1951
|
+
Object.entries(newAttributes).forEach(([key, value]) => {
|
|
1952
|
+
if (value != null && !(key in originalAttributes)) originalAttributes[key] = value;
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
function applySdkMetadataToSegmentSpan(segmentSpanJSON, client) {
|
|
1956
|
+
const integrationNames = client.getIntegrationNames();
|
|
1957
|
+
if (!integrationNames.length) return;
|
|
1958
|
+
safeSetSpanJSONAttributes(segmentSpanJSON, { [SEMANTIC_ATTRIBUTE_SENTRY_SDK_INTEGRATIONS]: integrationNames });
|
|
1959
|
+
}
|
|
1960
|
+
function commonSpanAttributes(serializedSegmentSpan, client, scopeData, includeScopeAttributes = true) {
|
|
1961
|
+
const sdk = client.getSdkMetadata();
|
|
1962
|
+
const { release, environment } = client.getOptions();
|
|
1963
|
+
return {
|
|
1964
|
+
[ag]: "stream",
|
|
1965
|
+
[Fd]: serializedSegmentSpan.name,
|
|
1966
|
+
[Vd]: serializedSegmentSpan.span_id,
|
|
1967
|
+
[zd]: sdk?.sdk?.name,
|
|
1968
|
+
[Yd]: sdk?.sdk?.version,
|
|
1969
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,
|
|
1970
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment || "production",
|
|
1971
|
+
[SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,
|
|
1972
|
+
[SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,
|
|
1973
|
+
[SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,
|
|
1974
|
+
[SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,
|
|
1975
|
+
...includeScopeAttributes ? scopeData.attributes : void 0
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
function applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, scopeData) {
|
|
1979
|
+
safeSetSpanJSONAttributes(spanJSON, commonSpanAttributes(serializedSegmentSpan, client, scopeData));
|
|
1980
|
+
}
|
|
1981
|
+
//#endregion
|
|
1982
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/hasSpanStreamingEnabled.js
|
|
1983
|
+
function hasSpanStreamingEnabled(client) {
|
|
1984
|
+
return client.getOptions().traceLifecycle === "stream";
|
|
1985
|
+
}
|
|
1986
|
+
//#endregion
|
|
1987
|
+
//#region node_modules/@sentry/core/build/esm/utils/timer.js
|
|
1988
|
+
function safeUnref(timer) {
|
|
1989
|
+
if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
|
|
1990
|
+
return timer;
|
|
1991
|
+
}
|
|
1992
|
+
//#endregion
|
|
1993
|
+
//#region node_modules/@sentry/core/build/esm/utils/envelope.js
|
|
1994
|
+
function createEnvelope(headers, items = []) {
|
|
1995
|
+
return [headers, items];
|
|
1996
|
+
}
|
|
1997
|
+
function addItemToEnvelope(envelope, newItem) {
|
|
1998
|
+
const [headers, items] = envelope;
|
|
1999
|
+
return [headers, [...items, newItem]];
|
|
2000
|
+
}
|
|
2001
|
+
function forEachEnvelopeItem(envelope, callback) {
|
|
2002
|
+
const envelopeItems = envelope[1];
|
|
2003
|
+
for (const envelopeItem of envelopeItems) {
|
|
2004
|
+
const envelopeItemType = envelopeItem[0].type;
|
|
2005
|
+
if (callback(envelopeItem, envelopeItemType)) return true;
|
|
2006
|
+
}
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
function envelopeContainsItemType(envelope, types) {
|
|
2010
|
+
return forEachEnvelopeItem(envelope, (_, type) => types.includes(type));
|
|
2011
|
+
}
|
|
2012
|
+
function encodeUTF8(input) {
|
|
2013
|
+
const carrier = getSentryCarrier(GLOBAL_OBJ);
|
|
2014
|
+
return carrier.encodePolyfill ? carrier.encodePolyfill(input) : new TextEncoder().encode(input);
|
|
2015
|
+
}
|
|
2016
|
+
function serializeEnvelope(envelope) {
|
|
2017
|
+
const [envHeaders, items] = envelope;
|
|
2018
|
+
let parts = JSON.stringify(envHeaders);
|
|
2019
|
+
function append(next) {
|
|
2020
|
+
if (typeof parts === "string") parts = typeof next === "string" ? parts + next : [encodeUTF8(parts), next];
|
|
2021
|
+
else parts.push(typeof next === "string" ? encodeUTF8(next) : next);
|
|
2022
|
+
}
|
|
2023
|
+
for (const item of items) {
|
|
2024
|
+
const [itemHeaders, payload] = item;
|
|
2025
|
+
append(`
|
|
2026
|
+
${JSON.stringify(itemHeaders)}
|
|
2027
|
+
`);
|
|
2028
|
+
if (typeof payload === "string" || payload instanceof Uint8Array) append(payload);
|
|
2029
|
+
else {
|
|
2030
|
+
let stringifiedPayload;
|
|
2031
|
+
try {
|
|
2032
|
+
stringifiedPayload = JSON.stringify(payload);
|
|
2033
|
+
} catch {
|
|
2034
|
+
stringifiedPayload = JSON.stringify(normalize(payload));
|
|
2035
|
+
}
|
|
2036
|
+
append(stringifiedPayload);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
return typeof parts === "string" ? parts : concatBuffers(parts);
|
|
2040
|
+
}
|
|
2041
|
+
function concatBuffers(buffers) {
|
|
2042
|
+
const totalLength = buffers.reduce((acc, buf) => acc + buf.length, 0);
|
|
2043
|
+
const merged = new Uint8Array(totalLength);
|
|
2044
|
+
let offset = 0;
|
|
2045
|
+
for (const buffer of buffers) {
|
|
2046
|
+
merged.set(buffer, offset);
|
|
2047
|
+
offset += buffer.length;
|
|
2048
|
+
}
|
|
2049
|
+
return merged;
|
|
2050
|
+
}
|
|
2051
|
+
function createAttachmentEnvelopeItem(attachment) {
|
|
2052
|
+
const buffer = typeof attachment.data === "string" ? encodeUTF8(attachment.data) : attachment.data;
|
|
2053
|
+
return [{
|
|
2054
|
+
type: "attachment",
|
|
2055
|
+
length: buffer.length,
|
|
2056
|
+
filename: attachment.filename,
|
|
2057
|
+
content_type: attachment.contentType,
|
|
2058
|
+
attachment_type: attachment.attachmentType
|
|
2059
|
+
}, buffer];
|
|
2060
|
+
}
|
|
2061
|
+
const DATA_CATEGORY_OVERRIDES = {
|
|
2062
|
+
sessions: "session",
|
|
2063
|
+
event: "error",
|
|
2064
|
+
client_report: "internal",
|
|
2065
|
+
user_report: "default",
|
|
2066
|
+
profile_chunk: "profile",
|
|
2067
|
+
replay_event: "replay",
|
|
2068
|
+
replay_recording: "replay",
|
|
2069
|
+
check_in: "monitor",
|
|
2070
|
+
raw_security: "security",
|
|
2071
|
+
log: "log_item",
|
|
2072
|
+
trace_metric: "metric"
|
|
2073
|
+
};
|
|
2074
|
+
function _isOverriddenType(type) {
|
|
2075
|
+
return type in DATA_CATEGORY_OVERRIDES;
|
|
2076
|
+
}
|
|
2077
|
+
function envelopeItemTypeToDataCategory(type) {
|
|
2078
|
+
return _isOverriddenType(type) ? DATA_CATEGORY_OVERRIDES[type] : type;
|
|
2079
|
+
}
|
|
2080
|
+
function getSdkMetadataForEnvelopeHeader(metadataOrEvent) {
|
|
2081
|
+
if (!metadataOrEvent?.sdk) return;
|
|
2082
|
+
const { name, version } = metadataOrEvent.sdk;
|
|
2083
|
+
return {
|
|
2084
|
+
name,
|
|
2085
|
+
version
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
|
|
2089
|
+
const dynamicSamplingContext = event.sdkProcessingMetadata?.dynamicSamplingContext;
|
|
2090
|
+
return {
|
|
2091
|
+
event_id: event.event_id,
|
|
2092
|
+
sent_at: new Date(safeDateNow()).toISOString(),
|
|
2093
|
+
...sdkInfo && { sdk: sdkInfo },
|
|
2094
|
+
...!!tunnel && dsn && { dsn: dsnToString(dsn) },
|
|
2095
|
+
...dynamicSamplingContext && { trace: dynamicSamplingContext }
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
function getDataCategoryByType(type) {
|
|
2099
|
+
return type === "replay_event" ? "replay" : type || "error";
|
|
2100
|
+
}
|
|
2101
|
+
//#endregion
|
|
2102
|
+
//#region node_modules/@sentry/core/build/esm/utils/env.js
|
|
2103
|
+
function isBrowserBundle() {
|
|
2104
|
+
return typeof __SENTRY_BROWSER_BUNDLE__ !== "undefined" && !!__SENTRY_BROWSER_BUNDLE__;
|
|
2105
|
+
}
|
|
2106
|
+
/*! __SENTRY_SDK_SOURCE__ */
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region node_modules/@sentry/core/build/esm/utils/node.js
|
|
2109
|
+
function isNodeEnv() {
|
|
2110
|
+
return !isBrowserBundle() && Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
2111
|
+
}
|
|
2112
|
+
//#endregion
|
|
2113
|
+
//#region node_modules/@sentry/core/build/esm/utils/isBrowser.js
|
|
2114
|
+
function isBrowser() {
|
|
2115
|
+
return typeof window !== "undefined" && (!isNodeEnv() || isElectronNodeRenderer());
|
|
2116
|
+
}
|
|
2117
|
+
function isElectronNodeRenderer() {
|
|
2118
|
+
return GLOBAL_OBJ.process?.type === "renderer";
|
|
2119
|
+
}
|
|
2120
|
+
//#endregion
|
|
2121
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/envelope.js
|
|
2122
|
+
function createStreamedSpanEnvelope(serializedSpans, dsc, client) {
|
|
2123
|
+
const options = client.getOptions();
|
|
2124
|
+
const dsn = client.getDsn();
|
|
2125
|
+
const tunnel = options.tunnel;
|
|
2126
|
+
const sdk = getSdkMetadataForEnvelopeHeader(options._metadata);
|
|
2127
|
+
return createEnvelope({
|
|
2128
|
+
sent_at: new Date(safeDateNow()).toISOString(),
|
|
2129
|
+
...dscHasRequiredProps(dsc) && { trace: dsc },
|
|
2130
|
+
...sdk && { sdk },
|
|
2131
|
+
...!!tunnel && dsn && { dsn: dsnToString(dsn) }
|
|
2132
|
+
}, [createSpanContainerItem(serializedSpans, client)]);
|
|
2133
|
+
}
|
|
2134
|
+
function createSpanContainerItem(serializedSpans, client) {
|
|
2135
|
+
const inferSetting = client.getDataCollectionOptions().userInfo ? "auto" : "never";
|
|
2136
|
+
return [{
|
|
2137
|
+
type: "span",
|
|
2138
|
+
item_count: serializedSpans.length,
|
|
2139
|
+
content_type: "application/vnd.sentry.items.span.v2+json"
|
|
2140
|
+
}, {
|
|
2141
|
+
version: 2,
|
|
2142
|
+
ingest_settings: isBrowser() ? {
|
|
2143
|
+
infer_ip: inferSetting,
|
|
2144
|
+
infer_user_agent: inferSetting
|
|
2145
|
+
} : void 0,
|
|
2146
|
+
items: serializedSpans
|
|
2147
|
+
}];
|
|
2148
|
+
}
|
|
2149
|
+
function dscHasRequiredProps(dsc) {
|
|
2150
|
+
return !!dsc.trace_id && !!dsc.public_key;
|
|
2151
|
+
}
|
|
2152
|
+
//#endregion
|
|
2153
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/estimateSize.js
|
|
2154
|
+
function estimateSerializedSpanSizeInBytes(span) {
|
|
2155
|
+
let weight = 156;
|
|
2156
|
+
weight += span.name.length * 2;
|
|
2157
|
+
weight += estimateTypedAttributesSizeInBytes(span.attributes);
|
|
2158
|
+
if (span.links && span.links.length > 0) {
|
|
2159
|
+
const attributes = span.links[0]?.attributes;
|
|
2160
|
+
const linkWeight = 100 + (attributes ? estimateTypedAttributesSizeInBytes(attributes) : 0);
|
|
2161
|
+
weight += linkWeight * span.links.length;
|
|
2162
|
+
}
|
|
2163
|
+
return weight;
|
|
2164
|
+
}
|
|
2165
|
+
//#endregion
|
|
2166
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/spanBuffer.js
|
|
2167
|
+
const MAX_SPANS_PER_ENVELOPE = 1e3;
|
|
2168
|
+
const MAX_TRACE_WEIGHT_IN_BYTES = 5e6;
|
|
2169
|
+
var SpanBuffer = class {
|
|
2170
|
+
constructor(client, options) {
|
|
2171
|
+
this._traceBuckets = /* @__PURE__ */ new Map();
|
|
2172
|
+
this._client = client;
|
|
2173
|
+
const { maxSpanLimit, flushInterval, maxTraceWeightInBytes } = options ?? {};
|
|
2174
|
+
this._maxSpanLimit = maxSpanLimit && maxSpanLimit > 0 && maxSpanLimit <= MAX_SPANS_PER_ENVELOPE ? maxSpanLimit : MAX_SPANS_PER_ENVELOPE;
|
|
2175
|
+
this._flushInterval = flushInterval && flushInterval > 0 ? flushInterval : 5e3;
|
|
2176
|
+
this._maxTraceWeight = maxTraceWeightInBytes && maxTraceWeightInBytes > 0 ? maxTraceWeightInBytes : MAX_TRACE_WEIGHT_IN_BYTES;
|
|
2177
|
+
this._client.on("flush", () => {
|
|
2178
|
+
this.drain();
|
|
2179
|
+
});
|
|
2180
|
+
this._client.on("close", () => {
|
|
2181
|
+
this._traceBuckets.forEach((bucket) => {
|
|
2182
|
+
clearTimeout(bucket.timeout);
|
|
2183
|
+
});
|
|
2184
|
+
this._traceBuckets.clear();
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Add a span to the buffer.
|
|
2189
|
+
*/
|
|
2190
|
+
add(spanJSON) {
|
|
2191
|
+
const traceId = spanJSON.trace_id;
|
|
2192
|
+
let bucket = this._traceBuckets.get(traceId);
|
|
2193
|
+
if (!bucket) {
|
|
2194
|
+
bucket = {
|
|
2195
|
+
spans: /* @__PURE__ */ new Set(),
|
|
2196
|
+
size: 0,
|
|
2197
|
+
timeout: safeUnref(setTimeout(() => {
|
|
2198
|
+
this.flush(traceId);
|
|
2199
|
+
}, this._flushInterval))
|
|
2200
|
+
};
|
|
2201
|
+
this._traceBuckets.set(traceId, bucket);
|
|
2202
|
+
}
|
|
2203
|
+
bucket.spans.add(spanJSON);
|
|
2204
|
+
bucket.size += estimateSerializedSpanSizeInBytes(spanJSON);
|
|
2205
|
+
if (bucket.spans.size >= this._maxSpanLimit || bucket.size >= this._maxTraceWeight) this.flush(traceId);
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Drain and flush all buffered traces.
|
|
2209
|
+
*/
|
|
2210
|
+
drain() {
|
|
2211
|
+
if (!this._traceBuckets.size) return;
|
|
2212
|
+
DEBUG_BUILD && debug.log(`Flushing span tree map with ${this._traceBuckets.size} traces`);
|
|
2213
|
+
this._traceBuckets.forEach((_, traceId) => {
|
|
2214
|
+
this.flush(traceId);
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Flush spans of a specific trace.
|
|
2219
|
+
* In contrast to {@link SpanBuffer.drain}, this method does not flush all traces, but only the one with the given traceId.
|
|
2220
|
+
*/
|
|
2221
|
+
flush(traceId) {
|
|
2222
|
+
const bucket = this._traceBuckets.get(traceId);
|
|
2223
|
+
if (!bucket) return;
|
|
2224
|
+
if (!bucket.spans.size) {
|
|
2225
|
+
this._removeTrace(traceId);
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
const spans = Array.from(bucket.spans);
|
|
2229
|
+
const segmentSpan = spans[0]?._segmentSpan;
|
|
2230
|
+
if (!segmentSpan) {
|
|
2231
|
+
DEBUG_BUILD && debug.warn("No segment span reference found on span JSON, cannot compute DSC");
|
|
2232
|
+
this._removeTrace(traceId);
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
const dsc = getDynamicSamplingContextFromSpan(segmentSpan);
|
|
2236
|
+
const cleanedSpans = spans.map((spanJSON) => {
|
|
2237
|
+
const { _segmentSpan, ...cleanSpanJSON } = spanJSON;
|
|
2238
|
+
return cleanSpanJSON;
|
|
2239
|
+
});
|
|
2240
|
+
const envelope = createStreamedSpanEnvelope(cleanedSpans, dsc, this._client);
|
|
2241
|
+
DEBUG_BUILD && debug.log(`Sending span envelope for trace ${traceId} with ${cleanedSpans.length} spans`);
|
|
2242
|
+
this._client.sendEnvelope(envelope).then(null, (reason) => {
|
|
2243
|
+
DEBUG_BUILD && debug.error("Error while sending streamed span envelope:", reason);
|
|
2244
|
+
});
|
|
2245
|
+
this._removeTrace(traceId);
|
|
2246
|
+
}
|
|
2247
|
+
_removeTrace(traceId) {
|
|
2248
|
+
const bucket = this._traceBuckets.get(traceId);
|
|
2249
|
+
if (bucket) clearTimeout(bucket.timeout);
|
|
2250
|
+
this._traceBuckets.delete(traceId);
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
//#endregion
|
|
2254
|
+
//#region node_modules/@sentry/core/build/esm/integrations/spanStreaming.js
|
|
2255
|
+
const INTEGRATION_NAME$2 = "SpanStreaming";
|
|
2256
|
+
const spanStreamingIntegration = defineIntegration((options = {}) => {
|
|
2257
|
+
const flushOnSegmentEnd = options.flushOnSegmentEnd ?? true;
|
|
2258
|
+
return {
|
|
2259
|
+
name: INTEGRATION_NAME$2,
|
|
2260
|
+
setup(client) {
|
|
2261
|
+
if (!hasSpanStreamingEnabled(client)) {
|
|
2262
|
+
DEBUG_BUILD && debug.log(`[SpanStreaming] \`traceLifecycle\` is "static", skipping setup.`);
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
const buffer = new SpanBuffer(client);
|
|
2266
|
+
client.on("afterSpanEnd", (span) => {
|
|
2267
|
+
if (!spanIsSampled(span)) return;
|
|
2268
|
+
buffer.add(captureSpan(span, client));
|
|
2269
|
+
});
|
|
2270
|
+
client.on("flushTraceSpans", (traceId) => {
|
|
2271
|
+
buffer.flush(traceId);
|
|
2272
|
+
});
|
|
2273
|
+
if (flushOnSegmentEnd) client.on("afterSegmentSpanEnd", (segmentSpan) => {
|
|
2274
|
+
const traceId = segmentSpan.spanContext().traceId;
|
|
2275
|
+
safeUnref(setTimeout(() => {
|
|
2276
|
+
buffer.flush(traceId);
|
|
2277
|
+
}, 500));
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
});
|
|
2282
|
+
//#endregion
|
|
2283
|
+
//#region node_modules/@sentry/core/build/esm/utils/errorSpanAttribution.js
|
|
2284
|
+
const escapedSpanTraceContexts = /* @__PURE__ */ new WeakMap();
|
|
2285
|
+
function toWeakMapKey(error) {
|
|
2286
|
+
return isPrimitive(error) ? void 0 : error;
|
|
2287
|
+
}
|
|
2288
|
+
function applyEscapedErrorSpanToEvent(event, hint, scope) {
|
|
2289
|
+
const key = toWeakMapKey(hint.originalException);
|
|
2290
|
+
const traceContext = key && escapedSpanTraceContexts.get(key);
|
|
2291
|
+
if (!traceContext) return;
|
|
2292
|
+
const eventTraceContext = event.contexts?.trace;
|
|
2293
|
+
if ((eventTraceContext?.trace_id ?? (scope && getTraceContextFromScope(scope).trace_id)) !== traceContext.trace_id) return;
|
|
2294
|
+
event.contexts = {
|
|
2295
|
+
...event.contexts,
|
|
2296
|
+
trace: {
|
|
2297
|
+
...eventTraceContext,
|
|
2298
|
+
...traceContext
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
//#endregion
|
|
2303
|
+
//#region node_modules/@sentry/core/build/esm/envelope.js
|
|
2304
|
+
function _enhanceEventWithSdkInfo(event, newSdkInfo) {
|
|
2305
|
+
if (!newSdkInfo) return event;
|
|
2306
|
+
const eventSdkInfo = event.sdk || {};
|
|
2307
|
+
event.sdk = {
|
|
2308
|
+
...eventSdkInfo,
|
|
2309
|
+
name: eventSdkInfo.name || newSdkInfo.name,
|
|
2310
|
+
version: eventSdkInfo.version || newSdkInfo.version,
|
|
2311
|
+
integrations: [...event.sdk?.integrations || [], ...newSdkInfo.integrations || []],
|
|
2312
|
+
packages: [...event.sdk?.packages || [], ...newSdkInfo.packages || []],
|
|
2313
|
+
settings: event.sdk?.settings || newSdkInfo.settings ? {
|
|
2314
|
+
...event.sdk?.settings,
|
|
2315
|
+
...newSdkInfo.settings
|
|
2316
|
+
} : void 0
|
|
2317
|
+
};
|
|
2318
|
+
return event;
|
|
2319
|
+
}
|
|
2320
|
+
function createSessionEnvelope(session, dsn, metadata, tunnel) {
|
|
2321
|
+
const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
|
|
2322
|
+
return createEnvelope({
|
|
2323
|
+
sent_at: new Date(safeDateNow()).toISOString(),
|
|
2324
|
+
...sdkInfo && { sdk: sdkInfo },
|
|
2325
|
+
...!!tunnel && dsn && { dsn: dsnToString(dsn) }
|
|
2326
|
+
}, ["aggregates" in session ? [{ type: "sessions" }, session] : [{ type: "session" }, session.toJSON()]]);
|
|
2327
|
+
}
|
|
2328
|
+
function createEventEnvelope(event, dsn, metadata, tunnel) {
|
|
2329
|
+
const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
|
|
2330
|
+
const eventType = event.type && event.type !== "replay_event" ? event.type : "event";
|
|
2331
|
+
_enhanceEventWithSdkInfo(event, metadata?.sdk);
|
|
2332
|
+
const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);
|
|
2333
|
+
delete event.sdkProcessingMetadata;
|
|
2334
|
+
return createEnvelope(envelopeHeaders, [[{ type: eventType }, event]]);
|
|
2335
|
+
}
|
|
2336
|
+
//#endregion
|
|
2337
|
+
//#region node_modules/@sentry/core/build/esm/utils/syncpromise.js
|
|
2338
|
+
const STATE_PENDING = 0;
|
|
2339
|
+
const STATE_RESOLVED = 1;
|
|
2340
|
+
const STATE_REJECTED = 2;
|
|
2341
|
+
function resolvedSyncPromise(value) {
|
|
2342
|
+
return new SyncPromise((resolve) => {
|
|
2343
|
+
resolve(value);
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
function rejectedSyncPromise(reason) {
|
|
2347
|
+
return new SyncPromise((_, reject) => {
|
|
2348
|
+
reject(reason);
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
var SyncPromise = class SyncPromise {
|
|
2352
|
+
constructor(executor) {
|
|
2353
|
+
this._state = STATE_PENDING;
|
|
2354
|
+
this._handlers = [];
|
|
2355
|
+
this._runExecutor(executor);
|
|
2356
|
+
}
|
|
2357
|
+
/** @inheritdoc */
|
|
2358
|
+
then(onfulfilled, onrejected) {
|
|
2359
|
+
return new SyncPromise((resolve, reject) => {
|
|
2360
|
+
this._handlers.push([
|
|
2361
|
+
false,
|
|
2362
|
+
(result) => {
|
|
2363
|
+
if (!onfulfilled) resolve(result);
|
|
2364
|
+
else try {
|
|
2365
|
+
resolve(onfulfilled(result));
|
|
2366
|
+
} catch (e) {
|
|
2367
|
+
reject(e);
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
(reason) => {
|
|
2371
|
+
if (!onrejected) reject(reason);
|
|
2372
|
+
else try {
|
|
2373
|
+
resolve(onrejected(reason));
|
|
2374
|
+
} catch (e) {
|
|
2375
|
+
reject(e);
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
]);
|
|
2379
|
+
this._executeHandlers();
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
/** @inheritdoc */
|
|
2383
|
+
catch(onrejected) {
|
|
2384
|
+
return this.then((val) => val, onrejected);
|
|
2385
|
+
}
|
|
2386
|
+
/** @inheritdoc */
|
|
2387
|
+
finally(onfinally) {
|
|
2388
|
+
return new SyncPromise((resolve, reject) => {
|
|
2389
|
+
let val;
|
|
2390
|
+
let isRejected;
|
|
2391
|
+
return this.then((value) => {
|
|
2392
|
+
isRejected = false;
|
|
2393
|
+
val = value;
|
|
2394
|
+
if (onfinally) onfinally();
|
|
2395
|
+
}, (reason) => {
|
|
2396
|
+
isRejected = true;
|
|
2397
|
+
val = reason;
|
|
2398
|
+
if (onfinally) onfinally();
|
|
2399
|
+
}).then(() => {
|
|
2400
|
+
if (isRejected) {
|
|
2401
|
+
reject(val);
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
resolve(val);
|
|
2405
|
+
});
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
/** Excute the resolve/reject handlers. */
|
|
2409
|
+
_executeHandlers() {
|
|
2410
|
+
if (this._state === STATE_PENDING) return;
|
|
2411
|
+
const cachedHandlers = this._handlers.slice();
|
|
2412
|
+
this._handlers = [];
|
|
2413
|
+
cachedHandlers.forEach((handler) => {
|
|
2414
|
+
if (handler[0]) return;
|
|
2415
|
+
if (this._state === STATE_RESOLVED) handler[1](this._value);
|
|
2416
|
+
if (this._state === STATE_REJECTED) handler[2](this._value);
|
|
2417
|
+
handler[0] = true;
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2420
|
+
/** Run the executor for the SyncPromise. */
|
|
2421
|
+
_runExecutor(executor) {
|
|
2422
|
+
const setResult = (state, value) => {
|
|
2423
|
+
if (this._state !== STATE_PENDING) return;
|
|
2424
|
+
if (isThenable(value)) {
|
|
2425
|
+
value.then(resolve, reject);
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
this._state = state;
|
|
2429
|
+
this._value = value;
|
|
2430
|
+
this._executeHandlers();
|
|
2431
|
+
};
|
|
2432
|
+
const resolve = (value) => {
|
|
2433
|
+
setResult(STATE_RESOLVED, value);
|
|
2434
|
+
};
|
|
2435
|
+
const reject = (reason) => {
|
|
2436
|
+
setResult(STATE_REJECTED, reason);
|
|
2437
|
+
};
|
|
2438
|
+
try {
|
|
2439
|
+
executor(resolve, reject);
|
|
2440
|
+
} catch (e) {
|
|
2441
|
+
reject(e);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
//#endregion
|
|
2446
|
+
//#region node_modules/@sentry/core/build/esm/eventProcessors.js
|
|
2447
|
+
function notifyEventProcessors(processors, event, hint, index = 0, onDrop) {
|
|
2448
|
+
try {
|
|
2449
|
+
const result = _notifyEventProcessors(event, hint, processors, index, onDrop);
|
|
2450
|
+
return isThenable(result) ? result : resolvedSyncPromise(result);
|
|
2451
|
+
} catch (error) {
|
|
2452
|
+
return rejectedSyncPromise(error);
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
function _notifyEventProcessors(event, hint, processors, index, onDrop) {
|
|
2456
|
+
const processor = processors[index];
|
|
2457
|
+
if (!event || !processor) return event;
|
|
2458
|
+
const processorName = `Event processor "${processor.id || "?"}"`;
|
|
2459
|
+
let callbackError = false;
|
|
2460
|
+
const result = safeCallback(DEBUG_BUILD ? `${processorName} threw an error, dropping event:` : "", () => processor({ ...event }, hint), () => {
|
|
2461
|
+
callbackError = true;
|
|
2462
|
+
return null;
|
|
2463
|
+
});
|
|
2464
|
+
DEBUG_BUILD && result === null && debug.log(`${processorName} dropped event`);
|
|
2465
|
+
if (isThenable(result)) return result.then((final) => {
|
|
2466
|
+
if (!final) {
|
|
2467
|
+
onDrop?.(callbackError ? "callback_error" : "event_processor");
|
|
2468
|
+
return null;
|
|
2469
|
+
}
|
|
2470
|
+
return _notifyEventProcessors(final, hint, processors, index + 1, onDrop);
|
|
2471
|
+
});
|
|
2472
|
+
if (!result) {
|
|
2473
|
+
onDrop?.(callbackError ? "callback_error" : "event_processor");
|
|
2474
|
+
return null;
|
|
2475
|
+
}
|
|
2476
|
+
return _notifyEventProcessors(result, hint, processors, index + 1, onDrop);
|
|
2477
|
+
}
|
|
2478
|
+
//#endregion
|
|
2479
|
+
//#region node_modules/@sentry/core/build/esm/utils/debug-ids.js
|
|
2480
|
+
let parsedStackResults;
|
|
2481
|
+
let lastSentryKeysCount;
|
|
2482
|
+
let lastNativeKeysCount;
|
|
2483
|
+
let cachedFilenameDebugIds;
|
|
2484
|
+
function getFilenameToDebugIdMap(stackParser) {
|
|
2485
|
+
const sentryDebugIdMap = GLOBAL_OBJ._sentryDebugIds;
|
|
2486
|
+
const nativeDebugIdMap = GLOBAL_OBJ._debugIds;
|
|
2487
|
+
if (!sentryDebugIdMap && !nativeDebugIdMap) return {};
|
|
2488
|
+
const sentryDebugIdKeys = sentryDebugIdMap ? Object.keys(sentryDebugIdMap) : [];
|
|
2489
|
+
const nativeDebugIdKeys = nativeDebugIdMap ? Object.keys(nativeDebugIdMap) : [];
|
|
2490
|
+
if (cachedFilenameDebugIds && sentryDebugIdKeys.length === lastSentryKeysCount && nativeDebugIdKeys.length === lastNativeKeysCount) return cachedFilenameDebugIds;
|
|
2491
|
+
lastSentryKeysCount = sentryDebugIdKeys.length;
|
|
2492
|
+
lastNativeKeysCount = nativeDebugIdKeys.length;
|
|
2493
|
+
cachedFilenameDebugIds = {};
|
|
2494
|
+
if (!parsedStackResults) parsedStackResults = {};
|
|
2495
|
+
const processDebugIds = (debugIdKeys, debugIdMap) => {
|
|
2496
|
+
for (const key of debugIdKeys) {
|
|
2497
|
+
const debugId = debugIdMap[key];
|
|
2498
|
+
const result = parsedStackResults?.[key];
|
|
2499
|
+
if (result && cachedFilenameDebugIds && debugId) {
|
|
2500
|
+
cachedFilenameDebugIds[result[0]] = debugId;
|
|
2501
|
+
if (parsedStackResults) parsedStackResults[key] = [result[0], debugId];
|
|
2502
|
+
} else if (debugId) {
|
|
2503
|
+
const parsedStack = stackParser(key);
|
|
2504
|
+
for (let i = parsedStack.length - 1; i >= 0; i--) {
|
|
2505
|
+
const filename = parsedStack[i]?.filename;
|
|
2506
|
+
if (filename && cachedFilenameDebugIds && parsedStackResults) {
|
|
2507
|
+
cachedFilenameDebugIds[filename] = debugId;
|
|
2508
|
+
parsedStackResults[key] = [filename, debugId];
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
if (sentryDebugIdMap) processDebugIds(sentryDebugIdKeys, sentryDebugIdMap);
|
|
2516
|
+
if (nativeDebugIdMap) processDebugIds(nativeDebugIdKeys, nativeDebugIdMap);
|
|
2517
|
+
return cachedFilenameDebugIds;
|
|
2518
|
+
}
|
|
2519
|
+
//#endregion
|
|
2520
|
+
//#region node_modules/@sentry/core/build/esm/utils/prepareEvent.js
|
|
2521
|
+
function prepareEvent(options, event, hint, scope, client, isolationScope) {
|
|
2522
|
+
const { normalizeDepth = 3, normalizeMaxBreadth = 1e3 } = options;
|
|
2523
|
+
const prepared = {
|
|
2524
|
+
...event,
|
|
2525
|
+
event_id: event.event_id || hint.event_id || uuid4(),
|
|
2526
|
+
timestamp: event.timestamp || dateTimestampInSeconds()
|
|
2527
|
+
};
|
|
2528
|
+
const integrations = hint.integrations || options.integrations.map((i) => i.name);
|
|
2529
|
+
applyClientOptions(prepared, options);
|
|
2530
|
+
applyIntegrationsMetadata(prepared, integrations);
|
|
2531
|
+
if (client) client.emit("applyFrameMetadata", event);
|
|
2532
|
+
if (event.type === void 0) applyDebugIds(prepared, options.stackParser);
|
|
2533
|
+
const finalScope = getFinalScope(scope, hint.captureContext);
|
|
2534
|
+
if (hint.mechanism) addExceptionMechanismToCapturedException(prepared, hint.mechanism);
|
|
2535
|
+
const clientEventProcessors = client ? client.getEventProcessors() : [];
|
|
2536
|
+
const data = getCombinedScopeData(isolationScope, finalScope);
|
|
2537
|
+
const attachments = [...hint.attachments || [], ...data.attachments];
|
|
2538
|
+
if (attachments.length) hint.attachments = attachments;
|
|
2539
|
+
applyScopeDataToEvent(prepared, data);
|
|
2540
|
+
const span = getActiveSpan(finalScope);
|
|
2541
|
+
if (span) applySpanToEvent(prepared, span);
|
|
2542
|
+
applyEscapedErrorSpanToEvent(prepared, hint, finalScope);
|
|
2543
|
+
const eventProcessors = [...clientEventProcessors, ...data.eventProcessors];
|
|
2544
|
+
return (hint.data && hint.data.__sentry__ === true ? resolvedSyncPromise(prepared) : notifyEventProcessors(eventProcessors, prepared, hint, 0, (reason) => {
|
|
2545
|
+
if (!client) return;
|
|
2546
|
+
client.recordDroppedEvent(reason, getDataCategoryByType(event.type));
|
|
2547
|
+
if (event.type === "transaction") client.recordDroppedEvent(reason, "span", 1 + (event.spans || []).length);
|
|
2548
|
+
})).then((evt) => {
|
|
2549
|
+
if (!evt) return null;
|
|
2550
|
+
applyDebugMeta(evt);
|
|
2551
|
+
if (typeof normalizeDepth === "number" && normalizeDepth > 0) return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
|
|
2552
|
+
return evt;
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
function applyClientOptions(event, options) {
|
|
2556
|
+
const { environment, release, dist, maxValueLength } = options;
|
|
2557
|
+
event.environment = event.environment || environment || "production";
|
|
2558
|
+
if (!event.release && release) event.release = release;
|
|
2559
|
+
if (!event.dist && dist) event.dist = dist;
|
|
2560
|
+
const request = event.request;
|
|
2561
|
+
if (request?.url && maxValueLength) request.url = truncate(request.url, maxValueLength);
|
|
2562
|
+
if (maxValueLength) event.exception?.values?.forEach((exception) => {
|
|
2563
|
+
if (exception.value) exception.value = truncate(exception.value, maxValueLength);
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
function applyDebugIds(event, stackParser) {
|
|
2567
|
+
const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
|
|
2568
|
+
event.exception?.values?.forEach((exception) => {
|
|
2569
|
+
exception.stacktrace?.frames?.forEach((frame) => {
|
|
2570
|
+
if (frame.filename) frame.debug_id = filenameDebugIdMap[frame.filename];
|
|
2571
|
+
});
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
function applyDebugMeta(event) {
|
|
2575
|
+
const filenameDebugIdMap = {};
|
|
2576
|
+
event.exception?.values?.forEach((exception) => {
|
|
2577
|
+
exception.stacktrace?.frames?.forEach((frame) => {
|
|
2578
|
+
if (frame.debug_id) {
|
|
2579
|
+
if (frame.abs_path) filenameDebugIdMap[frame.abs_path] = frame.debug_id;
|
|
2580
|
+
else if (frame.filename) filenameDebugIdMap[frame.filename] = frame.debug_id;
|
|
2581
|
+
delete frame.debug_id;
|
|
2582
|
+
}
|
|
2583
|
+
});
|
|
2584
|
+
});
|
|
2585
|
+
if (Object.keys(filenameDebugIdMap).length === 0) return;
|
|
2586
|
+
event.debug_meta = event.debug_meta || {};
|
|
2587
|
+
event.debug_meta.images = event.debug_meta.images || [];
|
|
2588
|
+
const images = event.debug_meta.images;
|
|
2589
|
+
Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => {
|
|
2590
|
+
images.push({
|
|
2591
|
+
type: "sourcemap",
|
|
2592
|
+
code_file: filename,
|
|
2593
|
+
debug_id
|
|
2594
|
+
});
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
function applyIntegrationsMetadata(event, integrationNames) {
|
|
2598
|
+
if (integrationNames.length > 0) {
|
|
2599
|
+
event.sdk = event.sdk || {};
|
|
2600
|
+
event.sdk.integrations = [...event.sdk.integrations || [], ...integrationNames];
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
function normalizeEvent(event, depth, maxBreadth) {
|
|
2604
|
+
if (!event) return null;
|
|
2605
|
+
const normalized = {
|
|
2606
|
+
...event,
|
|
2607
|
+
...event.breadcrumbs && { breadcrumbs: event.breadcrumbs.map((b) => ({
|
|
2608
|
+
...b,
|
|
2609
|
+
...b.data && { data: normalize(b.data, depth, maxBreadth) }
|
|
2610
|
+
})) },
|
|
2611
|
+
...event.user && { user: normalize(event.user, depth, maxBreadth) },
|
|
2612
|
+
...event.contexts && { contexts: normalize(event.contexts, depth, maxBreadth) },
|
|
2613
|
+
...event.extra && { extra: normalize(event.extra, depth, maxBreadth) }
|
|
2614
|
+
};
|
|
2615
|
+
if (event.contexts?.trace && normalized.contexts) {
|
|
2616
|
+
normalized.contexts.trace = event.contexts.trace;
|
|
2617
|
+
if (event.contexts.trace.data) normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);
|
|
2618
|
+
}
|
|
2619
|
+
if (event.spans) normalized.spans = event.spans.map((span) => {
|
|
2620
|
+
return {
|
|
2621
|
+
...span,
|
|
2622
|
+
...span.data && { data: normalize(span.data, depth, maxBreadth) }
|
|
2623
|
+
};
|
|
2624
|
+
});
|
|
2625
|
+
if (event.contexts?.flags && normalized.contexts) normalized.contexts.flags = normalize(event.contexts.flags, 3, maxBreadth);
|
|
2626
|
+
return normalized;
|
|
2627
|
+
}
|
|
2628
|
+
function getFinalScope(scope, captureContext) {
|
|
2629
|
+
if (!captureContext) return scope;
|
|
2630
|
+
const finalScope = scope ? scope.clone() : new Scope();
|
|
2631
|
+
finalScope.update(captureContext);
|
|
2632
|
+
return finalScope;
|
|
2633
|
+
}
|
|
2634
|
+
function getBaseApiEndpoint(dsn) {
|
|
2635
|
+
const protocol = dsn.protocol ? `${dsn.protocol}:` : "";
|
|
2636
|
+
const port = dsn.port ? `:${dsn.port}` : "";
|
|
2637
|
+
return `${protocol}//${dsn.host}${port}${dsn.path ? `/${dsn.path}` : ""}/api/`;
|
|
2638
|
+
}
|
|
2639
|
+
function _getIngestEndpoint(dsn) {
|
|
2640
|
+
return `${getBaseApiEndpoint(dsn)}${dsn.projectId}/envelope/`;
|
|
2641
|
+
}
|
|
2642
|
+
function _encodedAuth(dsn, sdkInfo) {
|
|
2643
|
+
const params = { sentry_version: "7" };
|
|
2644
|
+
if (dsn.publicKey) params.sentry_key = dsn.publicKey;
|
|
2645
|
+
if (sdkInfo) params.sentry_client = `${sdkInfo.name}/${sdkInfo.version}`;
|
|
2646
|
+
return new URLSearchParams(params).toString();
|
|
2647
|
+
}
|
|
2648
|
+
function getEnvelopeEndpointWithUrlEncodedAuth(dsn, tunnel, sdkInfo) {
|
|
2649
|
+
return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, sdkInfo)}`;
|
|
2650
|
+
}
|
|
2651
|
+
//#endregion
|
|
2652
|
+
//#region node_modules/@sentry/core/build/esm/utils/trace-info.js
|
|
2653
|
+
function _getTraceInfoFromScope(client, scope) {
|
|
2654
|
+
if (!scope) return [void 0, void 0];
|
|
2655
|
+
return withScope(scope, () => {
|
|
2656
|
+
const span = getActiveSpan();
|
|
2657
|
+
const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
|
|
2658
|
+
return [span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope), traceContext];
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
//#endregion
|
|
2662
|
+
//#region node_modules/@sentry/core/build/esm/logs/envelope.js
|
|
2663
|
+
function createLogContainerEnvelopeItem(items, inferUserData) {
|
|
2664
|
+
const inferSetting = inferUserData ? "auto" : "never";
|
|
2665
|
+
return [{
|
|
2666
|
+
type: "log",
|
|
2667
|
+
item_count: items.length,
|
|
2668
|
+
content_type: "application/vnd.sentry.items.log+json"
|
|
2669
|
+
}, {
|
|
2670
|
+
version: 2,
|
|
2671
|
+
...isBrowser() && { ingest_settings: {
|
|
2672
|
+
infer_ip: inferSetting,
|
|
2673
|
+
infer_user_agent: inferSetting
|
|
2674
|
+
} },
|
|
2675
|
+
items
|
|
2676
|
+
}];
|
|
2677
|
+
}
|
|
2678
|
+
function createLogEnvelope(logs, metadata, tunnel, dsn, inferUserData) {
|
|
2679
|
+
const headers = {};
|
|
2680
|
+
if (metadata?.sdk) headers.sdk = {
|
|
2681
|
+
name: metadata.sdk.name,
|
|
2682
|
+
version: metadata.sdk.version
|
|
2683
|
+
};
|
|
2684
|
+
if (!!tunnel && !!dsn) headers.dsn = dsnToString(dsn);
|
|
2685
|
+
return createEnvelope(headers, [createLogContainerEnvelopeItem(logs, inferUserData)]);
|
|
2686
|
+
}
|
|
2687
|
+
//#endregion
|
|
2688
|
+
//#region node_modules/@sentry/core/build/esm/logs/internal.js
|
|
2689
|
+
function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
|
|
2690
|
+
const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
|
|
2691
|
+
if (logBuffer.length === 0) return;
|
|
2692
|
+
const clientOptions = client.getOptions();
|
|
2693
|
+
const envelope = createLogEnvelope(logBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn(), client.getDataCollectionOptions().userInfo);
|
|
2694
|
+
_getBufferMap$1().set(client, []);
|
|
2695
|
+
client.emit("flushLogs");
|
|
2696
|
+
client.sendEnvelope(envelope);
|
|
2697
|
+
}
|
|
2698
|
+
function _INTERNAL_getLogBuffer(client) {
|
|
2699
|
+
return _getBufferMap$1().get(client);
|
|
2700
|
+
}
|
|
2701
|
+
function _getBufferMap$1() {
|
|
2702
|
+
return getGlobalSingleton("clientToLogBufferMap", () => /* @__PURE__ */ new WeakMap());
|
|
2703
|
+
}
|
|
2704
|
+
//#endregion
|
|
2705
|
+
//#region node_modules/@sentry/core/build/esm/metrics/envelope.js
|
|
2706
|
+
function createMetricContainerEnvelopeItem(items, inferUserData) {
|
|
2707
|
+
const inferSetting = inferUserData ? "auto" : "never";
|
|
2708
|
+
return [{
|
|
2709
|
+
type: "trace_metric",
|
|
2710
|
+
item_count: items.length,
|
|
2711
|
+
content_type: "application/vnd.sentry.items.trace-metric+json"
|
|
2712
|
+
}, {
|
|
2713
|
+
version: 2,
|
|
2714
|
+
...isBrowser() && { ingest_settings: {
|
|
2715
|
+
infer_ip: inferSetting,
|
|
2716
|
+
infer_user_agent: inferSetting
|
|
2717
|
+
} },
|
|
2718
|
+
items
|
|
2719
|
+
}];
|
|
2720
|
+
}
|
|
2721
|
+
function createMetricEnvelope(metrics, metadata, tunnel, dsn, inferUserData) {
|
|
2722
|
+
const headers = {};
|
|
2723
|
+
if (metadata?.sdk) headers.sdk = {
|
|
2724
|
+
name: metadata.sdk.name,
|
|
2725
|
+
version: metadata.sdk.version
|
|
2726
|
+
};
|
|
2727
|
+
if (!!tunnel && !!dsn) headers.dsn = dsnToString(dsn);
|
|
2728
|
+
return createEnvelope(headers, [createMetricContainerEnvelopeItem(metrics, inferUserData)]);
|
|
2729
|
+
}
|
|
2730
|
+
//#endregion
|
|
2731
|
+
//#region node_modules/@sentry/core/build/esm/metrics/internal.js
|
|
2732
|
+
function _INTERNAL_flushMetricsBuffer(client, maybeMetricBuffer) {
|
|
2733
|
+
const metricBuffer = maybeMetricBuffer ?? _INTERNAL_getMetricBuffer(client) ?? [];
|
|
2734
|
+
if (metricBuffer.length === 0) return;
|
|
2735
|
+
const clientOptions = client.getOptions();
|
|
2736
|
+
const envelope = createMetricEnvelope(metricBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn(), client.getDataCollectionOptions().userInfo);
|
|
2737
|
+
_getBufferMap().set(client, []);
|
|
2738
|
+
client.emit("flushMetrics");
|
|
2739
|
+
client.sendEnvelope(envelope);
|
|
2740
|
+
}
|
|
2741
|
+
function _INTERNAL_getMetricBuffer(client) {
|
|
2742
|
+
return _getBufferMap().get(client);
|
|
2743
|
+
}
|
|
2744
|
+
function _getBufferMap() {
|
|
2745
|
+
return getGlobalSingleton("clientToMetricBufferMap", () => /* @__PURE__ */ new WeakMap());
|
|
2746
|
+
}
|
|
2747
|
+
//#endregion
|
|
2748
|
+
//#region node_modules/@sentry/core/build/esm/tracing/spans/extractGenAiSpans.js
|
|
2749
|
+
function extractGenAiSpansFromEvent(event, client) {
|
|
2750
|
+
if (event.type !== "transaction" || !event.spans?.length || !event.sdkProcessingMetadata?.hasGenAiSpans || hasSpanStreamingEnabled(client)) return;
|
|
2751
|
+
const genAiSpans = [];
|
|
2752
|
+
const remainingSpans = [];
|
|
2753
|
+
for (const span of event.spans) if (span.op?.startsWith("gen_ai.")) genAiSpans.push(spanJsonToSerializedStreamedSpan(span));
|
|
2754
|
+
else remainingSpans.push(span);
|
|
2755
|
+
if (genAiSpans.length === 0) return;
|
|
2756
|
+
event.spans = remainingSpans;
|
|
2757
|
+
return createSpanContainerItem(genAiSpans, client);
|
|
2758
|
+
}
|
|
2759
|
+
//#endregion
|
|
2760
|
+
//#region node_modules/@sentry/core/build/esm/utils/promisebuffer.js
|
|
2761
|
+
const SENTRY_BUFFER_FULL_ERROR = /* @__PURE__ */ Symbol.for("SentryBufferFullError");
|
|
2762
|
+
function makePromiseBuffer(limit = 100) {
|
|
2763
|
+
const buffer = /* @__PURE__ */ new Set();
|
|
2764
|
+
function isReady() {
|
|
2765
|
+
return buffer.size < limit;
|
|
2766
|
+
}
|
|
2767
|
+
function remove(task) {
|
|
2768
|
+
buffer.delete(task);
|
|
2769
|
+
}
|
|
2770
|
+
function add(taskProducer) {
|
|
2771
|
+
if (!isReady()) return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR);
|
|
2772
|
+
const task = taskProducer();
|
|
2773
|
+
buffer.add(task);
|
|
2774
|
+
task.then(() => remove(task), () => remove(task));
|
|
2775
|
+
return task;
|
|
2776
|
+
}
|
|
2777
|
+
function drain(timeout) {
|
|
2778
|
+
if (!buffer.size) return resolvedSyncPromise(true);
|
|
2779
|
+
const drainPromise = Promise.allSettled(Array.from(buffer)).then(() => true);
|
|
2780
|
+
if (!timeout) return drainPromise;
|
|
2781
|
+
const promises = [drainPromise, new Promise((resolve) => safeUnref(setTimeout(() => resolve(false), timeout)))];
|
|
2782
|
+
return Promise.race(promises);
|
|
2783
|
+
}
|
|
2784
|
+
return {
|
|
2785
|
+
get $() {
|
|
2786
|
+
return Array.from(buffer);
|
|
2787
|
+
},
|
|
2788
|
+
add,
|
|
2789
|
+
drain
|
|
2790
|
+
};
|
|
2791
|
+
}
|
|
2792
|
+
//#endregion
|
|
2793
|
+
//#region node_modules/@sentry/core/build/esm/utils/ratelimit.js
|
|
2794
|
+
const DEFAULT_RETRY_AFTER = 6e4;
|
|
2795
|
+
function parseRetryAfterHeader(header, now = safeDateNow()) {
|
|
2796
|
+
const headerDelay = parseInt(`${header}`, 10);
|
|
2797
|
+
if (!isNaN(headerDelay)) return headerDelay * 1e3;
|
|
2798
|
+
const headerDate = Date.parse(`${header}`);
|
|
2799
|
+
if (!isNaN(headerDate)) return headerDate - now;
|
|
2800
|
+
return DEFAULT_RETRY_AFTER;
|
|
2801
|
+
}
|
|
2802
|
+
function disabledUntil(limits, dataCategory) {
|
|
2803
|
+
return limits[dataCategory] || limits.all || 0;
|
|
2804
|
+
}
|
|
2805
|
+
function isRateLimited(limits, dataCategory, now = safeDateNow()) {
|
|
2806
|
+
return disabledUntil(limits, dataCategory) > now;
|
|
2807
|
+
}
|
|
2808
|
+
function updateRateLimits(limits, { statusCode, headers }, now = safeDateNow()) {
|
|
2809
|
+
const updatedRateLimits = { ...limits };
|
|
2810
|
+
const rateLimitHeader = headers?.["x-sentry-rate-limits"];
|
|
2811
|
+
const retryAfterHeader = headers?.["retry-after"];
|
|
2812
|
+
if (rateLimitHeader) for (const limit of rateLimitHeader.trim().split(",")) {
|
|
2813
|
+
const [retryAfter, categories, , , namespaces] = limit.split(":", 5);
|
|
2814
|
+
const headerDelay = parseInt(retryAfter, 10);
|
|
2815
|
+
const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1e3;
|
|
2816
|
+
if (!categories) updatedRateLimits.all = now + delay;
|
|
2817
|
+
else for (const category of categories.split(";")) if (category === "metric_bucket") {
|
|
2818
|
+
if (!namespaces || namespaces.split(";").includes("custom")) updatedRateLimits[category] = now + delay;
|
|
2819
|
+
} else updatedRateLimits[category] = now + delay;
|
|
2820
|
+
}
|
|
2821
|
+
else if (retryAfterHeader) updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);
|
|
2822
|
+
else if (statusCode === 429) updatedRateLimits.all = now + 6e4;
|
|
2823
|
+
return updatedRateLimits;
|
|
2824
|
+
}
|
|
2825
|
+
function createTransport(options, makeRequest, buffer = makePromiseBuffer(options.bufferSize || 64)) {
|
|
2826
|
+
let rateLimits = {};
|
|
2827
|
+
const flush = (timeout) => buffer.drain(timeout);
|
|
2828
|
+
function send(envelope) {
|
|
2829
|
+
const filteredEnvelopeItems = [];
|
|
2830
|
+
forEachEnvelopeItem(envelope, (item, type) => {
|
|
2831
|
+
const dataCategory = envelopeItemTypeToDataCategory(type);
|
|
2832
|
+
if (isRateLimited(rateLimits, dataCategory)) options.recordDroppedEvent("ratelimit_backoff", dataCategory);
|
|
2833
|
+
else filteredEnvelopeItems.push(item);
|
|
2834
|
+
});
|
|
2835
|
+
if (filteredEnvelopeItems.length === 0) return Promise.resolve({});
|
|
2836
|
+
const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems);
|
|
2837
|
+
const recordEnvelopeLoss = (reason) => {
|
|
2838
|
+
if (envelopeContainsItemType(filteredEnvelope, ["client_report"])) {
|
|
2839
|
+
DEBUG_BUILD && debug.warn(`Dropping client report. Will not send outcomes (reason: ${reason}).`);
|
|
2840
|
+
return;
|
|
2841
|
+
}
|
|
2842
|
+
forEachEnvelopeItem(filteredEnvelope, (item, type) => {
|
|
2843
|
+
options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type));
|
|
2844
|
+
});
|
|
2845
|
+
};
|
|
2846
|
+
const requestTask = () => makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then((response) => {
|
|
2847
|
+
if (response.statusCode === 413) {
|
|
2848
|
+
DEBUG_BUILD && debug.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.");
|
|
2849
|
+
recordEnvelopeLoss("send_error");
|
|
2850
|
+
return response;
|
|
2851
|
+
}
|
|
2852
|
+
if (DEBUG_BUILD && response.statusCode !== void 0 && (response.statusCode < 200 || response.statusCode >= 300)) debug.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);
|
|
2853
|
+
rateLimits = updateRateLimits(rateLimits, response);
|
|
2854
|
+
return response;
|
|
2855
|
+
}, (error) => {
|
|
2856
|
+
recordEnvelopeLoss("network_error");
|
|
2857
|
+
DEBUG_BUILD && debug.error("Encountered error running transport request:", error);
|
|
2858
|
+
throw error;
|
|
2859
|
+
});
|
|
2860
|
+
return buffer.add(requestTask).then((result) => result, (error) => {
|
|
2861
|
+
if (error === SENTRY_BUFFER_FULL_ERROR) {
|
|
2862
|
+
DEBUG_BUILD && debug.error("Skipped sending event because buffer is full.");
|
|
2863
|
+
recordEnvelopeLoss("queue_overflow");
|
|
2864
|
+
return Promise.resolve({});
|
|
2865
|
+
} else throw error;
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
return {
|
|
2869
|
+
send,
|
|
2870
|
+
flush
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
//#endregion
|
|
2874
|
+
//#region node_modules/@sentry/core/build/esm/utils/clientreport.js
|
|
2875
|
+
function createClientReportEnvelope(discarded_events, dsn, timestamp) {
|
|
2876
|
+
const clientReportItem = [{ type: "client_report" }, {
|
|
2877
|
+
timestamp: timestamp || dateTimestampInSeconds(),
|
|
2878
|
+
discarded_events
|
|
2879
|
+
}];
|
|
2880
|
+
return createEnvelope(dsn ? { dsn } : {}, [clientReportItem]);
|
|
2881
|
+
}
|
|
2882
|
+
//#endregion
|
|
2883
|
+
//#region node_modules/@sentry/core/build/esm/utils/eventUtils.js
|
|
2884
|
+
function getPossibleEventMessages(event) {
|
|
2885
|
+
const possibleMessages = [];
|
|
2886
|
+
if (event.message) possibleMessages.push(event.message);
|
|
2887
|
+
try {
|
|
2888
|
+
const lastException = event.exception.values[event.exception.values.length - 1];
|
|
2889
|
+
if (lastException?.value) {
|
|
2890
|
+
possibleMessages.push(lastException.value);
|
|
2891
|
+
if (lastException.type) possibleMessages.push(`${lastException.type}: ${lastException.value}`);
|
|
2892
|
+
}
|
|
2893
|
+
} catch {}
|
|
2894
|
+
return possibleMessages;
|
|
2895
|
+
}
|
|
2896
|
+
//#endregion
|
|
2897
|
+
//#region node_modules/@sentry/core/build/esm/utils/transactionEvent.js
|
|
2898
|
+
function convertTransactionEventToSpanJson(event) {
|
|
2899
|
+
const { trace_id, parent_span_id, span_id, status, origin, data, op } = event.contexts?.trace ?? {};
|
|
2900
|
+
return {
|
|
2901
|
+
data: data ?? {},
|
|
2902
|
+
description: event.transaction,
|
|
2903
|
+
op,
|
|
2904
|
+
parent_span_id,
|
|
2905
|
+
span_id: span_id ?? "",
|
|
2906
|
+
start_timestamp: event.start_timestamp ?? 0,
|
|
2907
|
+
status: status ?? "ok",
|
|
2908
|
+
timestamp: event.timestamp,
|
|
2909
|
+
trace_id: trace_id ?? "",
|
|
2910
|
+
origin,
|
|
2911
|
+
profile_id: data?.[SEMANTIC_ATTRIBUTE_PROFILE_ID],
|
|
2912
|
+
exclusive_time: data?.[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME],
|
|
2913
|
+
measurements: event.measurements,
|
|
2914
|
+
is_segment: true
|
|
2915
|
+
};
|
|
2916
|
+
}
|
|
2917
|
+
function convertSpanJsonToTransactionEvent(span) {
|
|
2918
|
+
return {
|
|
2919
|
+
type: "transaction",
|
|
2920
|
+
timestamp: span.timestamp,
|
|
2921
|
+
start_timestamp: span.start_timestamp,
|
|
2922
|
+
transaction: span.description,
|
|
2923
|
+
contexts: { trace: {
|
|
2924
|
+
trace_id: span.trace_id,
|
|
2925
|
+
span_id: span.span_id,
|
|
2926
|
+
parent_span_id: span.parent_span_id,
|
|
2927
|
+
op: span.op,
|
|
2928
|
+
status: span.status,
|
|
2929
|
+
origin: span.origin,
|
|
2930
|
+
data: {
|
|
2931
|
+
...span.data,
|
|
2932
|
+
...span.profile_id && { ["sentry.profile_id"]: span.profile_id },
|
|
2933
|
+
...span.exclusive_time && { ["sentry.exclusive_time"]: span.exclusive_time }
|
|
2934
|
+
}
|
|
2935
|
+
} },
|
|
2936
|
+
measurements: span.measurements
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
//#endregion
|
|
2940
|
+
//#region node_modules/@sentry/core/build/esm/utils/warnAboutIgnoredTransactionOptions.js
|
|
2941
|
+
function maybeWarnAboutIgnoredTransactionOptions(options) {
|
|
2942
|
+
if (options.traceLifecycle !== "stream" || !(options.beforeSendTransaction || options.ignoreTransactions?.length)) return;
|
|
2943
|
+
consoleSandbox(() => {
|
|
2944
|
+
console.warn("[Sentry] `beforeSendTransaction` and `ignoreTransactions` are ignored with `traceLifecycle: 'stream'` (enabled by default). Use `beforeSendSpan` and `ignoreSpans` instead, or set `traceLifecycle: 'static'`.");
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
//#endregion
|
|
2948
|
+
//#region node_modules/@sentry/core/build/esm/utils/data-collection/resolveDataCollectionOptions.js
|
|
2949
|
+
const DEFAULTS = {
|
|
2950
|
+
userInfo: true,
|
|
2951
|
+
cookies: true,
|
|
2952
|
+
httpHeaders: {
|
|
2953
|
+
request: true,
|
|
2954
|
+
response: true
|
|
2955
|
+
},
|
|
2956
|
+
httpBodies: [
|
|
2957
|
+
"incomingRequest",
|
|
2958
|
+
"outgoingRequest",
|
|
2959
|
+
"incomingResponse",
|
|
2960
|
+
"outgoingResponse"
|
|
2961
|
+
],
|
|
2962
|
+
urlQueryParams: true,
|
|
2963
|
+
graphQL: {
|
|
2964
|
+
document: true,
|
|
2965
|
+
variables: true
|
|
2966
|
+
},
|
|
2967
|
+
genAI: {
|
|
2968
|
+
inputs: true,
|
|
2969
|
+
outputs: true
|
|
2970
|
+
},
|
|
2971
|
+
databaseQueryData: true,
|
|
2972
|
+
queues: true,
|
|
2973
|
+
stackFrameVariables: true,
|
|
2974
|
+
frameContextLines: 5
|
|
2975
|
+
};
|
|
2976
|
+
function isCollectBehavior(value) {
|
|
2977
|
+
return typeof value === "boolean" || "allow" in value || "deny" in value;
|
|
2978
|
+
}
|
|
2979
|
+
function resolveHttpHeaders(httpHeaders) {
|
|
2980
|
+
if (httpHeaders === void 0) return { ...DEFAULTS.httpHeaders };
|
|
2981
|
+
if (isCollectBehavior(httpHeaders)) return {
|
|
2982
|
+
request: httpHeaders,
|
|
2983
|
+
response: httpHeaders
|
|
2984
|
+
};
|
|
2985
|
+
return {
|
|
2986
|
+
request: httpHeaders.request ?? DEFAULTS.httpHeaders.request,
|
|
2987
|
+
response: httpHeaders.response ?? DEFAULTS.httpHeaders.response
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
function resolveDataCollectionOptions(options) {
|
|
2991
|
+
const dc = options.dataCollection ?? {};
|
|
2992
|
+
return {
|
|
2993
|
+
userInfo: dc.userInfo ?? DEFAULTS.userInfo,
|
|
2994
|
+
cookies: dc.cookies ?? DEFAULTS.cookies,
|
|
2995
|
+
httpHeaders: resolveHttpHeaders(dc.httpHeaders),
|
|
2996
|
+
httpBodies: dc.httpBodies ?? DEFAULTS.httpBodies,
|
|
2997
|
+
urlQueryParams: dc.urlQueryParams ?? DEFAULTS.urlQueryParams,
|
|
2998
|
+
graphQL: {
|
|
2999
|
+
document: dc.graphQL?.document ?? DEFAULTS.graphQL.document,
|
|
3000
|
+
variables: dc.graphQL?.variables ?? DEFAULTS.graphQL.variables
|
|
3001
|
+
},
|
|
3002
|
+
genAI: {
|
|
3003
|
+
inputs: dc.genAI?.inputs ?? DEFAULTS.genAI.inputs,
|
|
3004
|
+
outputs: dc.genAI?.outputs ?? DEFAULTS.genAI.outputs
|
|
3005
|
+
},
|
|
3006
|
+
databaseQueryData: dc.databaseQueryData ?? DEFAULTS.databaseQueryData,
|
|
3007
|
+
queues: dc.queues ?? DEFAULTS.queues,
|
|
3008
|
+
stackFrameVariables: dc.stackFrameVariables ?? DEFAULTS.stackFrameVariables,
|
|
3009
|
+
frameContextLines: dc.frameContextLines ?? DEFAULTS.frameContextLines
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
//#endregion
|
|
3013
|
+
//#region node_modules/@sentry/core/build/esm/client.js
|
|
3014
|
+
const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
|
|
3015
|
+
const MISSING_RELEASE_FOR_SESSION_ERROR = "Discarded session because of missing or non-string release";
|
|
3016
|
+
const INTERNAL_ERROR_SYMBOL = /* @__PURE__ */ Symbol.for("SentryInternalError");
|
|
3017
|
+
const DO_NOT_SEND_EVENT_SYMBOL = /* @__PURE__ */ Symbol.for("SentryDoNotSendEventError");
|
|
3018
|
+
const DEFAULT_FLUSH_INTERVAL = 5e3;
|
|
3019
|
+
function _makeInternalError(message) {
|
|
3020
|
+
return {
|
|
3021
|
+
message,
|
|
3022
|
+
[INTERNAL_ERROR_SYMBOL]: true
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
function _makeDoNotSendEventError(message) {
|
|
3026
|
+
return {
|
|
3027
|
+
message,
|
|
3028
|
+
[DO_NOT_SEND_EVENT_SYMBOL]: true
|
|
3029
|
+
};
|
|
3030
|
+
}
|
|
3031
|
+
function _isInternalError(error) {
|
|
3032
|
+
return isObjectLike(error) && INTERNAL_ERROR_SYMBOL in error;
|
|
3033
|
+
}
|
|
3034
|
+
function _isDoNotSendEventError(error) {
|
|
3035
|
+
return isObjectLike(error) && DO_NOT_SEND_EVENT_SYMBOL in error;
|
|
3036
|
+
}
|
|
3037
|
+
function setupWeightBasedFlushing(client, afterCaptureHook, flushHook, estimateSizeFn, flushFn) {
|
|
3038
|
+
let weight = 0;
|
|
3039
|
+
let flushTimeout;
|
|
3040
|
+
let isTimerActive = false;
|
|
3041
|
+
client.on(flushHook, () => {
|
|
3042
|
+
weight = 0;
|
|
3043
|
+
clearTimeout(flushTimeout);
|
|
3044
|
+
isTimerActive = false;
|
|
3045
|
+
});
|
|
3046
|
+
client.on(afterCaptureHook, (item) => {
|
|
3047
|
+
weight += estimateSizeFn(item);
|
|
3048
|
+
if (weight >= 8e5) flushFn(client);
|
|
3049
|
+
else if (!isTimerActive) {
|
|
3050
|
+
const flushInterval = client.getOptions()._flushInterval ?? DEFAULT_FLUSH_INTERVAL;
|
|
3051
|
+
if (flushInterval > 0) {
|
|
3052
|
+
isTimerActive = true;
|
|
3053
|
+
flushTimeout = safeUnref(setTimeout(() => {
|
|
3054
|
+
flushFn(client);
|
|
3055
|
+
}, flushInterval));
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
});
|
|
3059
|
+
client.on("flush", () => {
|
|
3060
|
+
flushFn(client);
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
var Client = class {
|
|
3064
|
+
/**
|
|
3065
|
+
* Initializes this client instance.
|
|
3066
|
+
*
|
|
3067
|
+
* @param options Options for the client.
|
|
3068
|
+
*/
|
|
3069
|
+
constructor(options) {
|
|
3070
|
+
this._options = {
|
|
3071
|
+
attachStacktrace: true,
|
|
3072
|
+
...options,
|
|
3073
|
+
traceLifecycle: options.traceLifecycle === "static" ? "static" : "stream"
|
|
3074
|
+
};
|
|
3075
|
+
this._integrations = {};
|
|
3076
|
+
this._numProcessing = 0;
|
|
3077
|
+
this._outcomes = {};
|
|
3078
|
+
this._hooks = {};
|
|
3079
|
+
this._eventProcessors = [];
|
|
3080
|
+
this._promiseBuffer = makePromiseBuffer(options.transportOptions?.bufferSize ?? 64);
|
|
3081
|
+
this._dataCollection = resolveDataCollectionOptions(options);
|
|
3082
|
+
this._unhandledSessionStatus = "crashed";
|
|
3083
|
+
if (options.dsn) this._dsn = makeDsn(options.dsn);
|
|
3084
|
+
else DEBUG_BUILD && debug.warn("No DSN provided, client will not send events.");
|
|
3085
|
+
const { beforeSendSpan, traceLifecycle } = this._options;
|
|
3086
|
+
if (DEBUG_BUILD && beforeSendSpan && isStaticBeforeSendSpanCallback(beforeSendSpan) !== (traceLifecycle === "static")) consoleSandbox(() => {
|
|
3087
|
+
console.warn(`Ignoring \`beforeSendSpan\`: ${traceLifecycle === "static" ? "wrap it with" : "remove"} \`Sentry.withStaticSpan\` to use it with \`traceLifecycle: "${traceLifecycle}"\`.`);
|
|
3088
|
+
});
|
|
3089
|
+
if (this._dsn) {
|
|
3090
|
+
const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options.tunnel, options._metadata ? options._metadata.sdk : void 0);
|
|
3091
|
+
this._transport = options.transport({
|
|
3092
|
+
tunnel: this._options.tunnel,
|
|
3093
|
+
recordDroppedEvent: this.recordDroppedEvent.bind(this),
|
|
3094
|
+
...options.transportOptions,
|
|
3095
|
+
url
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
setupWeightBasedFlushing(this, "afterCaptureLog", "flushLogs", estimateLogSizeInBytes, _INTERNAL_flushLogsBuffer);
|
|
3099
|
+
setupWeightBasedFlushing(this, "afterCaptureMetric", "flushMetrics", estimateMetricSizeInBytes, _INTERNAL_flushMetricsBuffer);
|
|
3100
|
+
}
|
|
3101
|
+
/**
|
|
3102
|
+
* Captures an exception event and sends it to Sentry.
|
|
3103
|
+
*
|
|
3104
|
+
* Unlike `captureException` exported from every SDK, this method requires that you pass it the current scope.
|
|
3105
|
+
*/
|
|
3106
|
+
captureException(exception, hint, scope) {
|
|
3107
|
+
const eventId = uuid4();
|
|
3108
|
+
if (checkOrSetAlreadyCaught(exception)) {
|
|
3109
|
+
DEBUG_BUILD && debug.log(ALREADY_SEEN_ERROR);
|
|
3110
|
+
return eventId;
|
|
3111
|
+
}
|
|
3112
|
+
const hintWithEventId = {
|
|
3113
|
+
event_id: eventId,
|
|
3114
|
+
...hint
|
|
3115
|
+
};
|
|
3116
|
+
this._process(() => this.eventFromException(exception, hintWithEventId).then((event) => this._captureEvent(event, hintWithEventId, scope)).then((res) => res), "error");
|
|
3117
|
+
return hintWithEventId.event_id;
|
|
3118
|
+
}
|
|
3119
|
+
/**
|
|
3120
|
+
* Captures a message event and sends it to Sentry.
|
|
3121
|
+
*
|
|
3122
|
+
* Unlike `captureMessage` exported from every SDK, this method requires that you pass it the current scope.
|
|
3123
|
+
*/
|
|
3124
|
+
captureMessage(message, level, hint, currentScope) {
|
|
3125
|
+
const hintWithEventId = {
|
|
3126
|
+
event_id: uuid4(),
|
|
3127
|
+
...hint
|
|
3128
|
+
};
|
|
3129
|
+
const eventMessage = isParameterizedString(message) ? message : String(message);
|
|
3130
|
+
const isMessage = isPrimitive(message);
|
|
3131
|
+
const promisedEvent = isMessage ? this.eventFromMessage(eventMessage, level, hintWithEventId) : this.eventFromException(message, hintWithEventId);
|
|
3132
|
+
this._process(() => promisedEvent.then((event) => this._captureEvent(event, hintWithEventId, currentScope)), isMessage ? "unknown" : "error");
|
|
3133
|
+
return hintWithEventId.event_id;
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Captures a manually created event and sends it to Sentry.
|
|
3137
|
+
*
|
|
3138
|
+
* Unlike `captureEvent` exported from every SDK, this method requires that you pass it the current scope.
|
|
3139
|
+
*/
|
|
3140
|
+
captureEvent(event, hint, currentScope) {
|
|
3141
|
+
const eventId = uuid4();
|
|
3142
|
+
if (hint?.originalException && checkOrSetAlreadyCaught(hint.originalException)) {
|
|
3143
|
+
DEBUG_BUILD && debug.log(ALREADY_SEEN_ERROR);
|
|
3144
|
+
return eventId;
|
|
3145
|
+
}
|
|
3146
|
+
const hintWithEventId = {
|
|
3147
|
+
event_id: eventId,
|
|
3148
|
+
...hint
|
|
3149
|
+
};
|
|
3150
|
+
const sdkProcessingMetadata = event.sdkProcessingMetadata || {};
|
|
3151
|
+
const capturedSpanScope = sdkProcessingMetadata.capturedSpanScope;
|
|
3152
|
+
const capturedSpanIsolationScope = sdkProcessingMetadata.capturedSpanIsolationScope;
|
|
3153
|
+
const dataCategory = getDataCategoryByType(event.type);
|
|
3154
|
+
this._process(() => this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope, capturedSpanIsolationScope), dataCategory);
|
|
3155
|
+
return hintWithEventId.event_id;
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Captures a session.
|
|
3159
|
+
*/
|
|
3160
|
+
captureSession(session) {
|
|
3161
|
+
this.sendSession(session);
|
|
3162
|
+
updateSession(session, { init: false });
|
|
3163
|
+
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Get the current Dsn.
|
|
3166
|
+
*/
|
|
3167
|
+
getDsn() {
|
|
3168
|
+
return this._dsn;
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Get the current options.
|
|
3172
|
+
*/
|
|
3173
|
+
getOptions() {
|
|
3174
|
+
return this._options;
|
|
3175
|
+
}
|
|
3176
|
+
/**
|
|
3177
|
+
* Get the resolved data collection configuration.
|
|
3178
|
+
*/
|
|
3179
|
+
getDataCollectionOptions() {
|
|
3180
|
+
return this._dataCollection;
|
|
3181
|
+
}
|
|
3182
|
+
/**
|
|
3183
|
+
* Get the SDK metadata.
|
|
3184
|
+
* @see SdkMetadata
|
|
3185
|
+
*/
|
|
3186
|
+
getSdkMetadata() {
|
|
3187
|
+
return this._options._metadata;
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Returns the transport that is used by the client.
|
|
3191
|
+
* Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
|
|
3192
|
+
*/
|
|
3193
|
+
getTransport() {
|
|
3194
|
+
return this._transport;
|
|
3195
|
+
}
|
|
3196
|
+
/**
|
|
3197
|
+
* Wait for all events to be sent or the timeout to expire, whichever comes first.
|
|
3198
|
+
*
|
|
3199
|
+
* @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
|
|
3200
|
+
* cause the client to wait until all events are sent before resolving the promise.
|
|
3201
|
+
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
|
|
3202
|
+
* still events in the queue when the timeout is reached.
|
|
3203
|
+
*/
|
|
3204
|
+
async flush(timeout) {
|
|
3205
|
+
const transport = this._transport;
|
|
3206
|
+
this.emit("flush");
|
|
3207
|
+
if (!transport) return true;
|
|
3208
|
+
const clientFinished = await this._isClientDoneProcessing(timeout);
|
|
3209
|
+
const transportFlushed = await transport.flush(timeout);
|
|
3210
|
+
return clientFinished && transportFlushed;
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
|
|
3214
|
+
*
|
|
3215
|
+
* @param {number} timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
|
|
3216
|
+
* the client to wait until all events are sent before disabling itself.
|
|
3217
|
+
* @returns {Promise<boolean>} A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
|
|
3218
|
+
* it doesn't.
|
|
3219
|
+
*/
|
|
3220
|
+
async close(timeout) {
|
|
3221
|
+
const result = await this.flush(timeout);
|
|
3222
|
+
this.getOptions().enabled = false;
|
|
3223
|
+
this.emit("close");
|
|
3224
|
+
return result;
|
|
3225
|
+
}
|
|
3226
|
+
/**
|
|
3227
|
+
* Get all installed event processors.
|
|
3228
|
+
*/
|
|
3229
|
+
getEventProcessors() {
|
|
3230
|
+
return this._eventProcessors;
|
|
3231
|
+
}
|
|
3232
|
+
/**
|
|
3233
|
+
* Adds an event processor that applies to any event processed by this client.
|
|
3234
|
+
*/
|
|
3235
|
+
addEventProcessor(eventProcessor) {
|
|
3236
|
+
this._eventProcessors.push(eventProcessor);
|
|
3237
|
+
}
|
|
3238
|
+
/**
|
|
3239
|
+
* Initialize this client.
|
|
3240
|
+
* Call this after the client was set on a scope.
|
|
3241
|
+
*/
|
|
3242
|
+
init() {
|
|
3243
|
+
if (this._isEnabled() || this._options.integrations.some(({ name }) => name.startsWith("Spotlight"))) {
|
|
3244
|
+
this._setupIntegrations();
|
|
3245
|
+
maybeWarnAboutIgnoredTransactionOptions(this._options);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Gets an installed integration by its name.
|
|
3250
|
+
*
|
|
3251
|
+
* @returns {Integration|undefined} The installed integration or `undefined` if no integration with that `name` was installed.
|
|
3252
|
+
*/
|
|
3253
|
+
getIntegrationByName(integrationName) {
|
|
3254
|
+
return this._integrations[integrationName];
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Returns the names of all installed integrations.
|
|
3258
|
+
*/
|
|
3259
|
+
getIntegrationNames() {
|
|
3260
|
+
return Object.keys(this._integrations);
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* Add an integration to the client.
|
|
3264
|
+
* This can be used to e.g. lazy load integrations.
|
|
3265
|
+
* In most cases, this should not be necessary,
|
|
3266
|
+
* and you're better off just passing the integrations via `integrations: []` at initialization time.
|
|
3267
|
+
* However, if you find the need to conditionally load & add an integration, you can use `addIntegration` to do so.
|
|
3268
|
+
*/
|
|
3269
|
+
addIntegration(integration) {
|
|
3270
|
+
const isAlreadyInstalled = this._integrations[integration.name];
|
|
3271
|
+
if (!isAlreadyInstalled && integration.beforeSetup) integration.beforeSetup(this);
|
|
3272
|
+
setupIntegration(this, integration, this._integrations);
|
|
3273
|
+
if (!isAlreadyInstalled) afterSetupIntegrations(this, [integration]);
|
|
3274
|
+
}
|
|
3275
|
+
/**
|
|
3276
|
+
* Send a fully prepared event to Sentry.
|
|
3277
|
+
*/
|
|
3278
|
+
sendEvent(event, hint = {}) {
|
|
3279
|
+
this.emit("beforeSendEvent", event, hint);
|
|
3280
|
+
const genAiSpanItem = extractGenAiSpansFromEvent(event, this);
|
|
3281
|
+
let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel);
|
|
3282
|
+
for (const attachment of hint.attachments || []) env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment));
|
|
3283
|
+
if (genAiSpanItem) env = addItemToEnvelope(env, genAiSpanItem);
|
|
3284
|
+
this.sendEnvelope(env).then((sendResponse) => this.emit("afterSendEvent", event, sendResponse));
|
|
3285
|
+
}
|
|
3286
|
+
/**
|
|
3287
|
+
* Send a session or session aggregrates to Sentry.
|
|
3288
|
+
*/
|
|
3289
|
+
sendSession(session) {
|
|
3290
|
+
const { release: clientReleaseOption, environment: clientEnvironmentOption = DEFAULT_ENVIRONMENT } = this._options;
|
|
3291
|
+
if ("aggregates" in session) {
|
|
3292
|
+
const sessionAttrs = session.attrs || {};
|
|
3293
|
+
if (!sessionAttrs.release && !clientReleaseOption) {
|
|
3294
|
+
DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
|
|
3295
|
+
return;
|
|
3296
|
+
}
|
|
3297
|
+
sessionAttrs.release = sessionAttrs.release || clientReleaseOption;
|
|
3298
|
+
sessionAttrs.environment = sessionAttrs.environment || clientEnvironmentOption;
|
|
3299
|
+
session.attrs = sessionAttrs;
|
|
3300
|
+
} else {
|
|
3301
|
+
if (!session.release && !clientReleaseOption) {
|
|
3302
|
+
DEBUG_BUILD && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
session.release = session.release || clientReleaseOption;
|
|
3306
|
+
session.environment = session.environment || clientEnvironmentOption;
|
|
3307
|
+
}
|
|
3308
|
+
this.emit("beforeSendSession", session);
|
|
3309
|
+
const env = createSessionEnvelope(session, this._dsn, this._options._metadata, this._options.tunnel);
|
|
3310
|
+
this.sendEnvelope(env);
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Record on the client that an event got dropped (ie, an event that will not be sent to Sentry).
|
|
3314
|
+
*/
|
|
3315
|
+
recordDroppedEvent(reason, category, count = 1) {
|
|
3316
|
+
if (this._options.sendClientReports) {
|
|
3317
|
+
const key = `${reason}:${category}`;
|
|
3318
|
+
DEBUG_BUILD && debug.log(`Recording outcome: "${key}"${count > 1 ? ` (${count} times)` : ""}`);
|
|
3319
|
+
this._outcomes[key] = (this._outcomes[key] || 0) + count;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
/**
|
|
3323
|
+
* Register a hook on this client.
|
|
3324
|
+
*/
|
|
3325
|
+
on(hook, callback) {
|
|
3326
|
+
const hookCallbacks = this._hooks[hook] = this._hooks[hook] || /* @__PURE__ */ new Set();
|
|
3327
|
+
const uniqueCallback = (...args) => callback(...args);
|
|
3328
|
+
hookCallbacks.add(uniqueCallback);
|
|
3329
|
+
return () => {
|
|
3330
|
+
hookCallbacks.delete(uniqueCallback);
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Emit a hook that was previously registered via `on()`.
|
|
3335
|
+
*/
|
|
3336
|
+
emit(hook, ...rest) {
|
|
3337
|
+
const callbacks = this._hooks[hook];
|
|
3338
|
+
if (callbacks) callbacks.forEach((callback) => callback(...rest));
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Send an envelope to Sentry.
|
|
3342
|
+
*/
|
|
3343
|
+
async sendEnvelope(envelope) {
|
|
3344
|
+
this.emit("beforeEnvelope", envelope);
|
|
3345
|
+
if (this._isEnabled() && this._transport) try {
|
|
3346
|
+
const result = await this._transport.send(envelope);
|
|
3347
|
+
this.emit("afterEnvelope", envelope);
|
|
3348
|
+
return result;
|
|
3349
|
+
} catch (reason) {
|
|
3350
|
+
DEBUG_BUILD && debug.error("Error while sending envelope:", reason);
|
|
3351
|
+
return {};
|
|
3352
|
+
}
|
|
3353
|
+
DEBUG_BUILD && debug.error("Transport disabled");
|
|
3354
|
+
return {};
|
|
3355
|
+
}
|
|
3356
|
+
/**
|
|
3357
|
+
* Register a cleanup function to be called when the client is disposed.
|
|
3358
|
+
* This is useful for integrations that need to clean up global state.
|
|
3359
|
+
*
|
|
3360
|
+
* NOTE: This is a no-op in the base `Client` class. Subclasses like `ServerRuntimeClient`
|
|
3361
|
+
* override this method to actually register and execute cleanup callbacks.
|
|
3362
|
+
*/
|
|
3363
|
+
registerCleanup(callback) {}
|
|
3364
|
+
/**
|
|
3365
|
+
* Disposes of the client and releases all resources.
|
|
3366
|
+
*
|
|
3367
|
+
* Subclasses should override this method to clean up their own resources, including invoking
|
|
3368
|
+
* any callbacks registered via {@link Client.registerCleanup}. The base implementation is a
|
|
3369
|
+
* no-op and does NOT execute registered cleanup callbacks.
|
|
3370
|
+
*
|
|
3371
|
+
* After calling dispose(), the client should not be used anymore.
|
|
3372
|
+
*/
|
|
3373
|
+
dispose() {}
|
|
3374
|
+
/** Setup integrations for this client. */
|
|
3375
|
+
_setupIntegrations() {
|
|
3376
|
+
const { integrations } = this._options;
|
|
3377
|
+
this._integrations = setupIntegrations(this, integrations);
|
|
3378
|
+
afterSetupIntegrations(this, integrations);
|
|
3379
|
+
}
|
|
3380
|
+
/** Updates existing session based on the provided event */
|
|
3381
|
+
_updateSessionFromEvent(session, event) {
|
|
3382
|
+
let unhandled = event.level === "fatal";
|
|
3383
|
+
let errored = false;
|
|
3384
|
+
const exceptions = event.exception?.values;
|
|
3385
|
+
if (exceptions) {
|
|
3386
|
+
errored = true;
|
|
3387
|
+
unhandled = false;
|
|
3388
|
+
for (const ex of exceptions) if (ex.mechanism?.handled === false) {
|
|
3389
|
+
unhandled = true;
|
|
3390
|
+
break;
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
const sessionNonTerminal = session.status === "ok";
|
|
3394
|
+
if (sessionNonTerminal && session.errors === 0 || sessionNonTerminal && unhandled) {
|
|
3395
|
+
updateSession(session, {
|
|
3396
|
+
...unhandled && { status: this._unhandledSessionStatus },
|
|
3397
|
+
errors: session.errors || Number(errored || unhandled)
|
|
3398
|
+
});
|
|
3399
|
+
this.captureSession(session);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
/**
|
|
3403
|
+
* Determine if the client is finished processing. Returns a promise because it will wait `timeout` ms before saying
|
|
3404
|
+
* "no" (resolving to `false`) in order to give the client a chance to potentially finish first.
|
|
3405
|
+
*
|
|
3406
|
+
* @param timeout The time, in ms, after which to resolve to `false` if the client is still busy. Passing `0` (or not
|
|
3407
|
+
* passing anything) will make the promise wait as long as it takes for processing to finish before resolving to
|
|
3408
|
+
* `true`.
|
|
3409
|
+
* @returns A promise which will resolve to `true` if processing is already done or finishes before the timeout, and
|
|
3410
|
+
* `false` otherwise
|
|
3411
|
+
*/
|
|
3412
|
+
async _isClientDoneProcessing(timeout) {
|
|
3413
|
+
let ticked = 0;
|
|
3414
|
+
while (!timeout || ticked < timeout) {
|
|
3415
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
3416
|
+
if (!this._numProcessing) return true;
|
|
3417
|
+
ticked++;
|
|
3418
|
+
}
|
|
3419
|
+
return false;
|
|
3420
|
+
}
|
|
3421
|
+
/** Determines whether this SDK is enabled and a transport is present. */
|
|
3422
|
+
_isEnabled() {
|
|
3423
|
+
return this.getOptions().enabled !== false && this._transport !== void 0;
|
|
3424
|
+
}
|
|
3425
|
+
/**
|
|
3426
|
+
* Adds common information to events.
|
|
3427
|
+
*
|
|
3428
|
+
* The information includes release and environment from `options`,
|
|
3429
|
+
* breadcrumbs and context (extra, tags and user) from the scope.
|
|
3430
|
+
*
|
|
3431
|
+
* Information that is already present in the event is never overwritten. For
|
|
3432
|
+
* nested objects, such as the context, keys are merged.
|
|
3433
|
+
*
|
|
3434
|
+
* @param event The original event.
|
|
3435
|
+
* @param hint May contain additional information about the original exception.
|
|
3436
|
+
* @param currentScope A scope containing event metadata.
|
|
3437
|
+
* @returns A new event with more information.
|
|
3438
|
+
*/
|
|
3439
|
+
_prepareEvent(event, hint, currentScope, isolationScope) {
|
|
3440
|
+
const options = this.getOptions();
|
|
3441
|
+
const integrations = this.getIntegrationNames();
|
|
3442
|
+
if (!hint.integrations && integrations.length) hint.integrations = integrations;
|
|
3443
|
+
this.emit("preprocessEvent", event, hint);
|
|
3444
|
+
if (!event.type) isolationScope.setLastEventId(event.event_id || hint.event_id);
|
|
3445
|
+
return prepareEvent(options, event, hint, currentScope, this, isolationScope).then((evt) => {
|
|
3446
|
+
if (evt === null) return evt;
|
|
3447
|
+
this.emit("postprocessEvent", evt, hint);
|
|
3448
|
+
evt.contexts = {
|
|
3449
|
+
trace: {
|
|
3450
|
+
...evt.contexts?.trace,
|
|
3451
|
+
...getTraceContextFromScope(currentScope)
|
|
3452
|
+
},
|
|
3453
|
+
...evt.contexts
|
|
3454
|
+
};
|
|
3455
|
+
evt.sdkProcessingMetadata = {
|
|
3456
|
+
dynamicSamplingContext: getDynamicSamplingContextFromScope(this, currentScope),
|
|
3457
|
+
...evt.sdkProcessingMetadata
|
|
3458
|
+
};
|
|
3459
|
+
return evt;
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* Processes the event and logs an error in case of rejection
|
|
3464
|
+
* @param event
|
|
3465
|
+
* @param hint
|
|
3466
|
+
* @param scope
|
|
3467
|
+
*/
|
|
3468
|
+
_captureEvent(event, hint = {}, currentScope = getCurrentScope(), isolationScope = getIsolationScope()) {
|
|
3469
|
+
if (DEBUG_BUILD && isErrorEvent(event)) debug.log(`Captured error event \`${getPossibleEventMessages(event)[0] || "<unknown>"}\``);
|
|
3470
|
+
return this._processEvent(event, hint, currentScope, isolationScope).then((finalEvent) => {
|
|
3471
|
+
return finalEvent.event_id;
|
|
3472
|
+
}, (reason) => {
|
|
3473
|
+
if (DEBUG_BUILD) {
|
|
3474
|
+
if (_isDoNotSendEventError(reason)) debug.log(reason.message);
|
|
3475
|
+
else if (_isInternalError(reason)) debug.warn(reason.message);
|
|
3476
|
+
else debug.warn(reason);
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
/**
|
|
3481
|
+
* Processes an event (either error or message) and sends it to Sentry.
|
|
3482
|
+
*
|
|
3483
|
+
* This also adds breadcrumbs and context information to the event. However,
|
|
3484
|
+
* platform specific meta data (such as the User's IP address) must be added
|
|
3485
|
+
* by the SDK implementor.
|
|
3486
|
+
*
|
|
3487
|
+
*
|
|
3488
|
+
* @param event The event to send to Sentry.
|
|
3489
|
+
* @param hint May contain additional information about the original exception.
|
|
3490
|
+
* @param currentScope A scope containing event metadata.
|
|
3491
|
+
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
|
|
3492
|
+
*/
|
|
3493
|
+
_processEvent(event, hint, currentScope, isolationScope) {
|
|
3494
|
+
const options = this.getOptions();
|
|
3495
|
+
const { sampleRate } = options;
|
|
3496
|
+
const isTransaction = isTransactionEvent(event);
|
|
3497
|
+
const isError = isErrorEvent(event);
|
|
3498
|
+
const beforeSendLabel = `before send for type \`${event.type || "error"}\``;
|
|
3499
|
+
let beforeSendDropReason = "before_send";
|
|
3500
|
+
const parsedSampleRate = typeof sampleRate === "undefined" ? void 0 : parseSampleRate(sampleRate);
|
|
3501
|
+
const dataCategory = getDataCategoryByType(event.type);
|
|
3502
|
+
return this._prepareEvent(event, hint, currentScope, isolationScope).then((prepared) => {
|
|
3503
|
+
if (prepared === null) throw _makeDoNotSendEventError("An event processor returned `null`, will not send event.");
|
|
3504
|
+
if (hint.data?.__sentry__ === true) return prepared;
|
|
3505
|
+
return _validateBeforeSendResult(processBeforeSend(this, options, prepared, hint, () => {
|
|
3506
|
+
beforeSendDropReason = "callback_error";
|
|
3507
|
+
}), beforeSendLabel);
|
|
3508
|
+
}).then((processedEvent) => {
|
|
3509
|
+
if (processedEvent === null) {
|
|
3510
|
+
this.recordDroppedEvent(beforeSendDropReason, dataCategory);
|
|
3511
|
+
if (isTransaction) {
|
|
3512
|
+
const spans = event.spans || [];
|
|
3513
|
+
this.recordDroppedEvent(beforeSendDropReason, "span", 1 + spans.length);
|
|
3514
|
+
}
|
|
3515
|
+
throw _makeDoNotSendEventError(`${beforeSendLabel} ${beforeSendDropReason === "callback_error" ? "threw an error" : "returned `null`"}, will not send event.`);
|
|
3516
|
+
}
|
|
3517
|
+
const session = currentScope.getSession() || isolationScope.getSession();
|
|
3518
|
+
if (isError && session) this._updateSessionFromEvent(session, processedEvent);
|
|
3519
|
+
if (isError && typeof parsedSampleRate === "number" && safeMathRandom() > parsedSampleRate) {
|
|
3520
|
+
this.recordDroppedEvent("sample_rate", "error");
|
|
3521
|
+
throw _makeDoNotSendEventError(`Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`);
|
|
3522
|
+
}
|
|
3523
|
+
if (isTransaction) {
|
|
3524
|
+
const droppedSpanCount = (processedEvent.sdkProcessingMetadata?.spanCountBeforeProcessing || 0) - (processedEvent.spans ? processedEvent.spans.length : 0);
|
|
3525
|
+
if (droppedSpanCount > 0) this.recordDroppedEvent("before_send", "span", droppedSpanCount);
|
|
3526
|
+
}
|
|
3527
|
+
const transactionInfo = processedEvent.transaction_info;
|
|
3528
|
+
if (isTransaction && transactionInfo && processedEvent.transaction !== event.transaction) {
|
|
3529
|
+
const source = "custom";
|
|
3530
|
+
processedEvent.transaction_info = {
|
|
3531
|
+
...transactionInfo,
|
|
3532
|
+
source
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
this.sendEvent(processedEvent, hint);
|
|
3536
|
+
return processedEvent;
|
|
3537
|
+
}).then(null, (reason) => {
|
|
3538
|
+
if (_isDoNotSendEventError(reason) || _isInternalError(reason)) throw reason;
|
|
3539
|
+
this.captureException(reason, {
|
|
3540
|
+
mechanism: {
|
|
3541
|
+
handled: false,
|
|
3542
|
+
type: "internal"
|
|
3543
|
+
},
|
|
3544
|
+
data: { __sentry__: true },
|
|
3545
|
+
originalException: reason
|
|
3546
|
+
});
|
|
3547
|
+
throw _makeInternalError(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
|
|
3548
|
+
Reason: ${reason}`);
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* Occupies the client with processing and event
|
|
3553
|
+
*/
|
|
3554
|
+
_process(taskProducer, dataCategory) {
|
|
3555
|
+
this._numProcessing++;
|
|
3556
|
+
this._promiseBuffer.add(taskProducer).then((value) => {
|
|
3557
|
+
this._numProcessing--;
|
|
3558
|
+
return value;
|
|
3559
|
+
}, (reason) => {
|
|
3560
|
+
this._numProcessing--;
|
|
3561
|
+
if (reason === SENTRY_BUFFER_FULL_ERROR) this.recordDroppedEvent("queue_overflow", dataCategory);
|
|
3562
|
+
return reason;
|
|
3563
|
+
});
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Clears outcomes on this client and returns them.
|
|
3567
|
+
*/
|
|
3568
|
+
_clearOutcomes() {
|
|
3569
|
+
const outcomes = this._outcomes;
|
|
3570
|
+
this._outcomes = {};
|
|
3571
|
+
return Object.entries(outcomes).map(([key, quantity]) => {
|
|
3572
|
+
const [reason, category] = key.split(":");
|
|
3573
|
+
return {
|
|
3574
|
+
reason,
|
|
3575
|
+
category,
|
|
3576
|
+
quantity
|
|
3577
|
+
};
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
/**
|
|
3581
|
+
* Sends client reports as an envelope.
|
|
3582
|
+
*/
|
|
3583
|
+
_flushOutcomes() {
|
|
3584
|
+
DEBUG_BUILD && debug.log("Flushing outcomes...");
|
|
3585
|
+
const outcomes = this._clearOutcomes();
|
|
3586
|
+
if (outcomes.length === 0) {
|
|
3587
|
+
DEBUG_BUILD && debug.log("No outcomes to send");
|
|
3588
|
+
return;
|
|
3589
|
+
}
|
|
3590
|
+
if (!this._dsn) {
|
|
3591
|
+
DEBUG_BUILD && debug.log("No dsn provided, will not send outcomes");
|
|
3592
|
+
return;
|
|
3593
|
+
}
|
|
3594
|
+
DEBUG_BUILD && debug.log("Sending outcomes:", outcomes);
|
|
3595
|
+
const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
|
|
3596
|
+
this.sendEnvelope(envelope);
|
|
3597
|
+
}
|
|
3598
|
+
};
|
|
3599
|
+
function _validateBeforeSendResult(beforeSendResult, beforeSendLabel) {
|
|
3600
|
+
const invalidValueError = `${beforeSendLabel} must return \`null\` or a valid event.`;
|
|
3601
|
+
if (isThenable(beforeSendResult)) return beforeSendResult.then((event) => {
|
|
3602
|
+
if (!isPlainObject(event) && event !== null) throw _makeInternalError(invalidValueError);
|
|
3603
|
+
return event;
|
|
3604
|
+
}, (e) => {
|
|
3605
|
+
throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`);
|
|
3606
|
+
});
|
|
3607
|
+
else if (!isPlainObject(beforeSendResult) && beforeSendResult !== null) throw _makeInternalError(invalidValueError);
|
|
3608
|
+
return beforeSendResult;
|
|
3609
|
+
}
|
|
3610
|
+
function processBeforeSend(client, options, event, hint, onCallbackError) {
|
|
3611
|
+
const { beforeSend, ignoreSpans, beforeSendTransaction } = options;
|
|
3612
|
+
const beforeSendSpan = isStaticBeforeSendSpanCallback(options.beforeSendSpan) && options.beforeSendSpan;
|
|
3613
|
+
let processedEvent = event;
|
|
3614
|
+
if (isErrorEvent(processedEvent) && beforeSend) {
|
|
3615
|
+
const errorEvent = processedEvent;
|
|
3616
|
+
return safeCallback(DEBUG_BUILD ? "The `beforeSend` callback threw an error, dropping the event:" : "", () => beforeSend(errorEvent, hint), () => {
|
|
3617
|
+
onCallbackError();
|
|
3618
|
+
return null;
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
if (isTransactionEvent(processedEvent)) {
|
|
3622
|
+
if (beforeSendSpan || ignoreSpans) {
|
|
3623
|
+
const rootSpanJson = convertTransactionEventToSpanJson(processedEvent);
|
|
3624
|
+
if (ignoreSpans?.length && shouldIgnoreSpan({
|
|
3625
|
+
description: rootSpanJson.description,
|
|
3626
|
+
op: rootSpanJson.op,
|
|
3627
|
+
attributes: rootSpanJson.data
|
|
3628
|
+
}, ignoreSpans)) return null;
|
|
3629
|
+
if (beforeSendSpan) processedEvent = merge(event, convertSpanJsonToTransactionEvent(applyBeforeSendSpanCallback(rootSpanJson, beforeSendSpan)));
|
|
3630
|
+
if (processedEvent.spans) {
|
|
3631
|
+
const processedSpans = [];
|
|
3632
|
+
const initialSpans = processedEvent.spans;
|
|
3633
|
+
for (const span of initialSpans) {
|
|
3634
|
+
if (ignoreSpans?.length && shouldIgnoreSpan({
|
|
3635
|
+
description: span.description,
|
|
3636
|
+
op: span.op,
|
|
3637
|
+
attributes: span.data
|
|
3638
|
+
}, ignoreSpans)) {
|
|
3639
|
+
reparentChildSpans(initialSpans, span);
|
|
3640
|
+
continue;
|
|
3641
|
+
}
|
|
3642
|
+
if (beforeSendSpan) processedSpans.push(applyBeforeSendSpanCallback(span, beforeSendSpan));
|
|
3643
|
+
else processedSpans.push(span);
|
|
3644
|
+
}
|
|
3645
|
+
const droppedSpans = processedEvent.spans.length - processedSpans.length;
|
|
3646
|
+
if (droppedSpans) client.recordDroppedEvent("before_send", "span", droppedSpans);
|
|
3647
|
+
processedEvent.spans = processedSpans;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
if (beforeSendTransaction) {
|
|
3651
|
+
if (processedEvent.spans) {
|
|
3652
|
+
const spanCountBefore = processedEvent.spans.length;
|
|
3653
|
+
processedEvent.sdkProcessingMetadata = {
|
|
3654
|
+
...event.sdkProcessingMetadata,
|
|
3655
|
+
spanCountBeforeProcessing: spanCountBefore
|
|
3656
|
+
};
|
|
3657
|
+
}
|
|
3658
|
+
return safeCallback(DEBUG_BUILD ? "The `beforeSendTransaction` callback threw an error, dropping the event:" : "", () => beforeSendTransaction(processedEvent, hint), () => {
|
|
3659
|
+
onCallbackError();
|
|
3660
|
+
return null;
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
return processedEvent;
|
|
3665
|
+
}
|
|
3666
|
+
function isErrorEvent(event) {
|
|
3667
|
+
return event.type === void 0;
|
|
3668
|
+
}
|
|
3669
|
+
function isTransactionEvent(event) {
|
|
3670
|
+
return event.type === "transaction";
|
|
3671
|
+
}
|
|
3672
|
+
function estimateMetricSizeInBytes(metric) {
|
|
3673
|
+
let weight = 0;
|
|
3674
|
+
if (metric.name) weight += metric.name.length * 2;
|
|
3675
|
+
weight += 8;
|
|
3676
|
+
return weight + estimateAttributesSizeInBytes(metric.attributes);
|
|
3677
|
+
}
|
|
3678
|
+
function estimateLogSizeInBytes(log) {
|
|
3679
|
+
let weight = 0;
|
|
3680
|
+
if (log.message) weight += log.message.length * 2;
|
|
3681
|
+
return weight + estimateAttributesSizeInBytes(log.attributes);
|
|
3682
|
+
}
|
|
3683
|
+
function estimateAttributesSizeInBytes(attributes) {
|
|
3684
|
+
if (!attributes) return 0;
|
|
3685
|
+
let weight = 0;
|
|
3686
|
+
Object.values(attributes).forEach((value) => {
|
|
3687
|
+
if (Array.isArray(value)) weight += value.length * estimatePrimitiveSizeInBytes(value[0]);
|
|
3688
|
+
else if (isPrimitive(value)) weight += estimatePrimitiveSizeInBytes(value);
|
|
3689
|
+
else weight += 100;
|
|
3690
|
+
});
|
|
3691
|
+
return weight;
|
|
3692
|
+
}
|
|
3693
|
+
function estimatePrimitiveSizeInBytes(value) {
|
|
3694
|
+
if (typeof value === "string") return value.length * 2;
|
|
3695
|
+
else if (typeof value === "number") return 8;
|
|
3696
|
+
else if (typeof value === "boolean") return 4;
|
|
3697
|
+
return 0;
|
|
3698
|
+
}
|
|
3699
|
+
//#endregion
|
|
3700
|
+
//#region node_modules/@sentry/core/build/esm/checkin.js
|
|
3701
|
+
function createCheckInEnvelope(checkIn, dynamicSamplingContext, metadata, tunnel, dsn) {
|
|
3702
|
+
const headers = { sent_at: new Date(safeDateNow()).toISOString() };
|
|
3703
|
+
if (metadata?.sdk) headers.sdk = {
|
|
3704
|
+
name: metadata.sdk.name,
|
|
3705
|
+
version: metadata.sdk.version
|
|
3706
|
+
};
|
|
3707
|
+
if (!!tunnel && !!dsn) headers.dsn = dsnToString(dsn);
|
|
3708
|
+
if (dynamicSamplingContext) headers.trace = dynamicSamplingContext;
|
|
3709
|
+
return createEnvelope(headers, [createCheckInEnvelopeItem(checkIn)]);
|
|
3710
|
+
}
|
|
3711
|
+
function createCheckInEnvelopeItem(checkIn) {
|
|
3712
|
+
return [{ type: "check_in" }, checkIn];
|
|
3713
|
+
}
|
|
3714
|
+
//#endregion
|
|
3715
|
+
//#region node_modules/@sentry/core/build/esm/utils/aggregate-errors.js
|
|
3716
|
+
function applyAggregateErrorsToEvent(exceptionFromErrorImplementation, parser, key, limit, event, hint) {
|
|
3717
|
+
if (!event.exception?.values || !hint || !isError(hint.originalException)) return;
|
|
3718
|
+
const originalException = event.exception.values.length > 0 ? event.exception.values[event.exception.values.length - 1] : void 0;
|
|
3719
|
+
if (originalException) event.exception.values = aggregateExceptionsFromError(exceptionFromErrorImplementation, parser, limit, hint.originalException, key, event.exception.values, originalException, 0);
|
|
3720
|
+
}
|
|
3721
|
+
function aggregateExceptionsFromError(exceptionFromErrorImplementation, parser, limit, error, key, prevExceptions, exception, exceptionId) {
|
|
3722
|
+
if (prevExceptions.length >= limit + 1) return prevExceptions;
|
|
3723
|
+
let newExceptions = [...prevExceptions];
|
|
3724
|
+
if (isError(error[key])) {
|
|
3725
|
+
applyExceptionGroupFieldsForParentException(exception, exceptionId, error);
|
|
3726
|
+
const newException = exceptionFromErrorImplementation(parser, error[key]);
|
|
3727
|
+
const newExceptionId = newExceptions.length;
|
|
3728
|
+
applyExceptionGroupFieldsForChildException(newException, key, newExceptionId, exceptionId);
|
|
3729
|
+
newExceptions = aggregateExceptionsFromError(exceptionFromErrorImplementation, parser, limit, error[key], key, [newException, ...newExceptions], newException, newExceptionId);
|
|
3730
|
+
}
|
|
3731
|
+
if (isExceptionGroup(error)) error.errors.forEach((childError, i) => {
|
|
3732
|
+
if (isError(childError)) {
|
|
3733
|
+
applyExceptionGroupFieldsForParentException(exception, exceptionId, error);
|
|
3734
|
+
const newException = exceptionFromErrorImplementation(parser, childError);
|
|
3735
|
+
const newExceptionId = newExceptions.length;
|
|
3736
|
+
applyExceptionGroupFieldsForChildException(newException, `errors[${i}]`, newExceptionId, exceptionId);
|
|
3737
|
+
newExceptions = aggregateExceptionsFromError(exceptionFromErrorImplementation, parser, limit, childError, key, [newException, ...newExceptions], newException, newExceptionId);
|
|
3738
|
+
}
|
|
3739
|
+
});
|
|
3740
|
+
return newExceptions;
|
|
3741
|
+
}
|
|
3742
|
+
function isExceptionGroup(error) {
|
|
3743
|
+
return Array.isArray(error.errors);
|
|
3744
|
+
}
|
|
3745
|
+
function applyExceptionGroupFieldsForParentException(exception, exceptionId, error) {
|
|
3746
|
+
exception.mechanism = {
|
|
3747
|
+
handled: true,
|
|
3748
|
+
type: "auto.core.linked_errors",
|
|
3749
|
+
...isExceptionGroup(error) && { is_exception_group: true },
|
|
3750
|
+
...exception.mechanism,
|
|
3751
|
+
exception_id: exceptionId
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
function applyExceptionGroupFieldsForChildException(exception, source, exceptionId, parentId) {
|
|
3755
|
+
exception.mechanism = {
|
|
3756
|
+
handled: true,
|
|
3757
|
+
...exception.mechanism,
|
|
3758
|
+
type: "chained",
|
|
3759
|
+
source,
|
|
3760
|
+
exception_id: exceptionId,
|
|
3761
|
+
parent_id: parentId
|
|
3762
|
+
};
|
|
3763
|
+
}
|
|
3764
|
+
//#endregion
|
|
3765
|
+
//#region node_modules/@sentry/core/build/esm/utils/eventbuilder.js
|
|
3766
|
+
function parseStackFrames(stackParser, error) {
|
|
3767
|
+
return stackParser(error.stack || "", 1);
|
|
3768
|
+
}
|
|
3769
|
+
function hasSentryFetchUrlHost(error) {
|
|
3770
|
+
return isError(error) && "__sentry_fetch_url_host__" in error && typeof error.__sentry_fetch_url_host__ === "string";
|
|
3771
|
+
}
|
|
3772
|
+
function _enhanceErrorWithSentryInfo(error) {
|
|
3773
|
+
if (hasSentryFetchUrlHost(error)) return `${error.message} (${error.__sentry_fetch_url_host__})`;
|
|
3774
|
+
return error.message;
|
|
3775
|
+
}
|
|
3776
|
+
function exceptionFromError(stackParser, error) {
|
|
3777
|
+
const exception = {
|
|
3778
|
+
type: error.name || error.constructor.name,
|
|
3779
|
+
value: _enhanceErrorWithSentryInfo(error)
|
|
3780
|
+
};
|
|
3781
|
+
const frames = parseStackFrames(stackParser, error);
|
|
3782
|
+
if (frames.length) exception.stacktrace = { frames };
|
|
3783
|
+
return exception;
|
|
3784
|
+
}
|
|
3785
|
+
function getErrorPropertyFromObject(obj) {
|
|
3786
|
+
for (const prop in obj) if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
3787
|
+
const value = obj[prop];
|
|
3788
|
+
if (isError(value)) return value;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
function getMessageForObject(exception) {
|
|
3792
|
+
if ("name" in exception && typeof exception.name === "string") {
|
|
3793
|
+
let message = `'${exception.name}' captured as exception`;
|
|
3794
|
+
if ("message" in exception && typeof exception.message === "string") message += ` with message '${exception.message}'`;
|
|
3795
|
+
return message;
|
|
3796
|
+
} else if ("message" in exception && typeof exception.message === "string") return exception.message;
|
|
3797
|
+
const keys = extractExceptionKeysForMessage(exception);
|
|
3798
|
+
if (isErrorEvent$1(exception)) return `Event \`ErrorEvent\` captured as exception with message \`${exception.message}\``;
|
|
3799
|
+
const className = getObjectClassName(exception);
|
|
3800
|
+
return `${className && className !== "Object" ? `'${className}'` : "Object"} captured as exception with keys: ${keys}`;
|
|
3801
|
+
}
|
|
3802
|
+
function getObjectClassName(obj) {
|
|
3803
|
+
try {
|
|
3804
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
3805
|
+
return prototype ? prototype.constructor.name : void 0;
|
|
3806
|
+
} catch {}
|
|
3807
|
+
}
|
|
3808
|
+
function getException(client, mechanism, exception, hint) {
|
|
3809
|
+
if (isError(exception)) return [exception, void 0];
|
|
3810
|
+
mechanism.synthetic = true;
|
|
3811
|
+
if (isPlainObject(exception)) {
|
|
3812
|
+
const normalizeDepth = client?.getOptions().normalizeDepth;
|
|
3813
|
+
const extras = { ["__serialized__"]: normalizeToSize(exception, normalizeDepth) };
|
|
3814
|
+
const errorFromProp = getErrorPropertyFromObject(exception);
|
|
3815
|
+
if (errorFromProp) return [errorFromProp, extras];
|
|
3816
|
+
const message = getMessageForObject(exception);
|
|
3817
|
+
const ex2 = hint?.syntheticException || new Error(message);
|
|
3818
|
+
ex2.message = message;
|
|
3819
|
+
return [ex2, extras];
|
|
3820
|
+
}
|
|
3821
|
+
const ex = hint?.syntheticException || new Error(exception);
|
|
3822
|
+
ex.message = `${exception}`;
|
|
3823
|
+
return [ex, void 0];
|
|
3824
|
+
}
|
|
3825
|
+
function eventFromUnknownInput(client, stackParser, exception, hint) {
|
|
3826
|
+
const mechanism = hint?.data && hint.data.mechanism || {
|
|
3827
|
+
handled: true,
|
|
3828
|
+
type: "generic"
|
|
3829
|
+
};
|
|
3830
|
+
const [ex, extras] = getException(client, mechanism, exception, hint);
|
|
3831
|
+
const event = { exception: { values: [exceptionFromError(stackParser, ex)] } };
|
|
3832
|
+
if (extras) event.extra = extras;
|
|
3833
|
+
addExceptionTypeValue(event, void 0, void 0);
|
|
3834
|
+
addExceptionMechanism(event, mechanism);
|
|
3835
|
+
return {
|
|
3836
|
+
...event,
|
|
3837
|
+
event_id: hint?.event_id
|
|
3838
|
+
};
|
|
3839
|
+
}
|
|
3840
|
+
function eventFromMessage(stackParser, message, level = "info", hint, attachStacktrace) {
|
|
3841
|
+
const event = {
|
|
3842
|
+
event_id: hint?.event_id,
|
|
3843
|
+
level
|
|
3844
|
+
};
|
|
3845
|
+
if (attachStacktrace && hint?.syntheticException) {
|
|
3846
|
+
const frames = parseStackFrames(stackParser, hint.syntheticException);
|
|
3847
|
+
if (frames.length) {
|
|
3848
|
+
event.exception = { values: [{
|
|
3849
|
+
value: message,
|
|
3850
|
+
stacktrace: { frames }
|
|
3851
|
+
}] };
|
|
3852
|
+
addExceptionMechanism(event, { synthetic: true });
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
if (isParameterizedString(message)) {
|
|
3856
|
+
const { __sentry_template_string__, __sentry_template_values__ } = message;
|
|
3857
|
+
event.logentry = {
|
|
3858
|
+
message: __sentry_template_string__,
|
|
3859
|
+
params: __sentry_template_values__
|
|
3860
|
+
};
|
|
3861
|
+
return event;
|
|
3862
|
+
}
|
|
3863
|
+
event.message = message;
|
|
3864
|
+
return event;
|
|
3865
|
+
}
|
|
3866
|
+
//#endregion
|
|
3867
|
+
//#region node_modules/@sentry/core/build/esm/integrations/linkederrors.js
|
|
3868
|
+
const DEFAULT_KEY = "cause";
|
|
3869
|
+
const DEFAULT_LIMIT = 5;
|
|
3870
|
+
const INTEGRATION_NAME$1 = "LinkedErrors";
|
|
3871
|
+
const _linkedErrorsIntegration = ((options = {}) => {
|
|
3872
|
+
const limit = options.limit || DEFAULT_LIMIT;
|
|
3873
|
+
const key = options.key || DEFAULT_KEY;
|
|
3874
|
+
return {
|
|
3875
|
+
name: INTEGRATION_NAME$1,
|
|
3876
|
+
preprocessEvent(event, hint, client) {
|
|
3877
|
+
applyAggregateErrorsToEvent(exceptionFromError, client.getOptions().stackParser, key, limit, event, hint);
|
|
3878
|
+
}
|
|
3879
|
+
};
|
|
3880
|
+
});
|
|
3881
|
+
const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);
|
|
3882
|
+
//#endregion
|
|
3883
|
+
//#region node_modules/@sentry/core/build/esm/utils/path.js
|
|
3884
|
+
function normalizeArray(parts, allowAboveRoot) {
|
|
3885
|
+
let up = 0;
|
|
3886
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
3887
|
+
const last = parts[i];
|
|
3888
|
+
if (last === ".") parts.splice(i, 1);
|
|
3889
|
+
else if (last === "..") {
|
|
3890
|
+
parts.splice(i, 1);
|
|
3891
|
+
up++;
|
|
3892
|
+
} else if (up) {
|
|
3893
|
+
parts.splice(i, 1);
|
|
3894
|
+
up--;
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
if (allowAboveRoot) for (; up--;) parts.unshift("..");
|
|
3898
|
+
return parts;
|
|
3899
|
+
}
|
|
3900
|
+
const splitPathRe = /^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;
|
|
3901
|
+
function splitPath(filename) {
|
|
3902
|
+
const truncated = filename.length > 1024 ? `<truncated>${filename.slice(-1024)}` : filename;
|
|
3903
|
+
const parts = splitPathRe.exec(truncated);
|
|
3904
|
+
return parts ? parts.slice(1) : [];
|
|
3905
|
+
}
|
|
3906
|
+
function resolve$1(...args) {
|
|
3907
|
+
let resolvedPath = "";
|
|
3908
|
+
let resolvedAbsolute = false;
|
|
3909
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
3910
|
+
const path = i >= 0 ? args[i] : "/";
|
|
3911
|
+
if (!path) continue;
|
|
3912
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
3913
|
+
resolvedAbsolute = path.charAt(0) === "/";
|
|
3914
|
+
}
|
|
3915
|
+
resolvedPath = normalizeArray(resolvedPath.split("/").filter((p) => !!p), !resolvedAbsolute).join("/");
|
|
3916
|
+
return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
|
|
3917
|
+
}
|
|
3918
|
+
function trim(arr) {
|
|
3919
|
+
let start = 0;
|
|
3920
|
+
for (; start < arr.length; start++) if (arr[start] !== "") break;
|
|
3921
|
+
let end = arr.length - 1;
|
|
3922
|
+
for (; end >= 0; end--) if (arr[end] !== "") break;
|
|
3923
|
+
if (start > end) return [];
|
|
3924
|
+
return arr.slice(start, end - start + 1);
|
|
3925
|
+
}
|
|
3926
|
+
function relative(from, to) {
|
|
3927
|
+
from = resolve$1(from).slice(1);
|
|
3928
|
+
to = resolve$1(to).slice(1);
|
|
3929
|
+
const fromParts = trim(from.split("/"));
|
|
3930
|
+
const toParts = trim(to.split("/"));
|
|
3931
|
+
const length = Math.min(fromParts.length, toParts.length);
|
|
3932
|
+
let samePartsLength = length;
|
|
3933
|
+
for (let i = 0; i < length; i++) if (fromParts[i] !== toParts[i]) {
|
|
3934
|
+
samePartsLength = i;
|
|
3935
|
+
break;
|
|
3936
|
+
}
|
|
3937
|
+
let outputParts = [];
|
|
3938
|
+
for (let i = samePartsLength; i < fromParts.length; i++) outputParts.push("..");
|
|
3939
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
3940
|
+
return outputParts.join("/");
|
|
3941
|
+
}
|
|
3942
|
+
function basename$1(path, ext) {
|
|
3943
|
+
let f = splitPath(path)[2] || "";
|
|
3944
|
+
if (ext && f.slice(ext.length * -1) === ext) f = f.slice(0, f.length - ext.length);
|
|
3945
|
+
return f;
|
|
3946
|
+
}
|
|
3947
|
+
//#endregion
|
|
3948
|
+
//#region node_modules/@sentry/core/build/esm/integrations/rewriteframes.js
|
|
3949
|
+
const INTEGRATION_NAME = "RewriteFrames";
|
|
3950
|
+
const rewriteFramesIntegration = defineIntegration((options = {}) => {
|
|
3951
|
+
const root = options.root;
|
|
3952
|
+
const prefix = options.prefix || "app:///";
|
|
3953
|
+
const isBrowser = "window" in GLOBAL_OBJ && !!GLOBAL_OBJ.window;
|
|
3954
|
+
const iteratee = options.iteratee || generateIteratee({
|
|
3955
|
+
isBrowser,
|
|
3956
|
+
root,
|
|
3957
|
+
prefix
|
|
3958
|
+
});
|
|
3959
|
+
function _processExceptionsEvent(event) {
|
|
3960
|
+
try {
|
|
3961
|
+
return {
|
|
3962
|
+
...event,
|
|
3963
|
+
exception: {
|
|
3964
|
+
...event.exception,
|
|
3965
|
+
values: event.exception.values.map((value) => ({
|
|
3966
|
+
...value,
|
|
3967
|
+
...value.stacktrace && { stacktrace: _processStacktrace(value.stacktrace) }
|
|
3968
|
+
}))
|
|
3969
|
+
}
|
|
3970
|
+
};
|
|
3971
|
+
} catch {
|
|
3972
|
+
return event;
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
function _processStacktrace(stacktrace) {
|
|
3976
|
+
return {
|
|
3977
|
+
...stacktrace,
|
|
3978
|
+
frames: stacktrace?.frames?.map((f) => iteratee(f))
|
|
3979
|
+
};
|
|
3980
|
+
}
|
|
3981
|
+
return {
|
|
3982
|
+
name: INTEGRATION_NAME,
|
|
3983
|
+
processEvent(originalEvent) {
|
|
3984
|
+
let processedEvent = originalEvent;
|
|
3985
|
+
if (originalEvent.exception && Array.isArray(originalEvent.exception.values)) processedEvent = _processExceptionsEvent(processedEvent);
|
|
3986
|
+
return processedEvent;
|
|
3987
|
+
}
|
|
3988
|
+
};
|
|
3989
|
+
});
|
|
3990
|
+
function generateIteratee({ isBrowser, root, prefix }) {
|
|
3991
|
+
return (frame) => {
|
|
3992
|
+
if (!frame.filename) return frame;
|
|
3993
|
+
const isWindowsFrame = /^[a-zA-Z]:\\/.test(frame.filename) || frame.filename.includes("\\") && !frame.filename.includes("/");
|
|
3994
|
+
const startsWithSlash = /^\//.test(frame.filename);
|
|
3995
|
+
if (isBrowser) {
|
|
3996
|
+
if (root) {
|
|
3997
|
+
const oldFilename = frame.filename;
|
|
3998
|
+
if (oldFilename.indexOf(root) === 0) frame.filename = oldFilename.replace(root, prefix);
|
|
3999
|
+
}
|
|
4000
|
+
} else if (isWindowsFrame || startsWithSlash) {
|
|
4001
|
+
const filename = isWindowsFrame ? frame.filename.replace(/^[a-zA-Z]:/, "").replace(/\\/g, "/") : frame.filename;
|
|
4002
|
+
frame.filename = `${prefix}${root ? relative(root, filename) : basename$1(filename)}`;
|
|
4003
|
+
}
|
|
4004
|
+
return frame;
|
|
4005
|
+
};
|
|
4006
|
+
}
|
|
4007
|
+
//#endregion
|
|
4008
|
+
//#region node_modules/@sentry/core/build/esm/transports/userAgent.js
|
|
4009
|
+
function addUserAgentToTransportHeaders(options) {
|
|
4010
|
+
const sdkMetadata = options._metadata?.sdk;
|
|
4011
|
+
const sdkUserAgent = sdkMetadata?.name && sdkMetadata?.version ? `${sdkMetadata?.name}/${sdkMetadata?.version}` : void 0;
|
|
4012
|
+
options.transportOptions = {
|
|
4013
|
+
...options.transportOptions,
|
|
4014
|
+
headers: {
|
|
4015
|
+
...sdkUserAgent && { "user-agent": sdkUserAgent },
|
|
4016
|
+
...options.transportOptions?.headers
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
//#endregion
|
|
4021
|
+
//#region node_modules/@sentry/core/build/esm/server-runtime-client.js
|
|
4022
|
+
var ServerRuntimeClient = class extends Client {
|
|
4023
|
+
/**
|
|
4024
|
+
* Creates a new Edge SDK instance.
|
|
4025
|
+
* @param options Configuration options for this SDK.
|
|
4026
|
+
*/
|
|
4027
|
+
constructor(options) {
|
|
4028
|
+
addUserAgentToTransportHeaders(options);
|
|
4029
|
+
if ((typeof __SENTRY_TRACING__ === "undefined" || __SENTRY_TRACING__) && options.traceLifecycle !== "static" && !options.integrations.some((i) => i.name === "SpanStreaming")) options.integrations.push(spanStreamingIntegration());
|
|
4030
|
+
super(options);
|
|
4031
|
+
this._disposeCallbacks = [];
|
|
4032
|
+
this._setUpMetricsProcessing();
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* @inheritDoc
|
|
4036
|
+
*/
|
|
4037
|
+
eventFromException(exception, hint) {
|
|
4038
|
+
const event = eventFromUnknownInput(this, this._options.stackParser, exception, hint);
|
|
4039
|
+
event.level = "error";
|
|
4040
|
+
return resolvedSyncPromise(event);
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* @inheritDoc
|
|
4044
|
+
*/
|
|
4045
|
+
eventFromMessage(message, level = "info", hint) {
|
|
4046
|
+
return resolvedSyncPromise(eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace));
|
|
4047
|
+
}
|
|
4048
|
+
/**
|
|
4049
|
+
* @inheritDoc
|
|
4050
|
+
*/
|
|
4051
|
+
captureException(exception, hint, scope) {
|
|
4052
|
+
setCurrentRequestSessionErroredOrCrashed(hint);
|
|
4053
|
+
return super.captureException(exception, hint, scope);
|
|
4054
|
+
}
|
|
4055
|
+
/**
|
|
4056
|
+
* @inheritDoc
|
|
4057
|
+
*/
|
|
4058
|
+
captureEvent(event, hint, scope) {
|
|
4059
|
+
if (!event.type && event.exception?.values && event.exception.values.length > 0) setCurrentRequestSessionErroredOrCrashed(hint);
|
|
4060
|
+
return super.captureEvent(event, hint, scope);
|
|
4061
|
+
}
|
|
4062
|
+
/**
|
|
4063
|
+
* Create a cron monitor check in and send it to Sentry.
|
|
4064
|
+
*
|
|
4065
|
+
* @param checkIn An object that describes a check in.
|
|
4066
|
+
* @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
|
|
4067
|
+
* to create a monitor automatically when sending a check in.
|
|
4068
|
+
*/
|
|
4069
|
+
captureCheckIn(checkIn, monitorConfig, scope) {
|
|
4070
|
+
const id = "checkInId" in checkIn && checkIn.checkInId ? checkIn.checkInId : uuid4();
|
|
4071
|
+
if (!this._isEnabled()) {
|
|
4072
|
+
DEBUG_BUILD && debug.warn("SDK not enabled, will not capture check-in.");
|
|
4073
|
+
return id;
|
|
4074
|
+
}
|
|
4075
|
+
const { release, environment, tunnel } = this.getOptions();
|
|
4076
|
+
const serializedCheckIn = {
|
|
4077
|
+
check_in_id: id,
|
|
4078
|
+
monitor_slug: checkIn.monitorSlug,
|
|
4079
|
+
status: checkIn.status,
|
|
4080
|
+
release,
|
|
4081
|
+
environment
|
|
4082
|
+
};
|
|
4083
|
+
if ("duration" in checkIn) serializedCheckIn.duration = checkIn.duration;
|
|
4084
|
+
if (monitorConfig) serializedCheckIn.monitor_config = {
|
|
4085
|
+
schedule: monitorConfig.schedule,
|
|
4086
|
+
checkin_margin: monitorConfig.checkinMargin,
|
|
4087
|
+
max_runtime: monitorConfig.maxRuntime,
|
|
4088
|
+
timezone: monitorConfig.timezone,
|
|
4089
|
+
failure_issue_threshold: monitorConfig.failureIssueThreshold,
|
|
4090
|
+
recovery_threshold: monitorConfig.recoveryThreshold
|
|
4091
|
+
};
|
|
4092
|
+
const [dynamicSamplingContext, traceContext] = _getTraceInfoFromScope(this, scope);
|
|
4093
|
+
if (traceContext) serializedCheckIn.contexts = { trace: traceContext };
|
|
4094
|
+
const envelope = createCheckInEnvelope(serializedCheckIn, dynamicSamplingContext, this.getSdkMetadata(), tunnel, this.getDsn());
|
|
4095
|
+
DEBUG_BUILD && debug.log("Sending checkin:", checkIn.monitorSlug, checkIn.status);
|
|
4096
|
+
this.sendEnvelope(envelope);
|
|
4097
|
+
return id;
|
|
4098
|
+
}
|
|
4099
|
+
/**
|
|
4100
|
+
* @inheritDoc
|
|
4101
|
+
*/
|
|
4102
|
+
registerCleanup(callback) {
|
|
4103
|
+
this._disposeCallbacks.push(callback);
|
|
4104
|
+
}
|
|
4105
|
+
/**
|
|
4106
|
+
* Disposes of the client and releases all resources.
|
|
4107
|
+
*
|
|
4108
|
+
* This method clears all internal state to allow the client to be garbage collected.
|
|
4109
|
+
* It clears hooks, event processors, integrations, transport, and other internal references.
|
|
4110
|
+
*
|
|
4111
|
+
* Call this method after flushing to allow the client to be garbage collected.
|
|
4112
|
+
* After calling dispose(), the client should not be used anymore.
|
|
4113
|
+
*
|
|
4114
|
+
* Subclasses should override this method to clean up their own resources and call `super.dispose()`.
|
|
4115
|
+
*/
|
|
4116
|
+
dispose() {
|
|
4117
|
+
DEBUG_BUILD && debug.log("Disposing client...");
|
|
4118
|
+
for (const callback of this._disposeCallbacks) try {
|
|
4119
|
+
callback();
|
|
4120
|
+
} catch {}
|
|
4121
|
+
this._disposeCallbacks.length = 0;
|
|
4122
|
+
for (const hookName of Object.keys(this._hooks)) this._hooks[hookName]?.clear();
|
|
4123
|
+
this._hooks = {};
|
|
4124
|
+
this._eventProcessors.length = 0;
|
|
4125
|
+
this._integrations = {};
|
|
4126
|
+
this._outcomes = {};
|
|
4127
|
+
this._transport = void 0;
|
|
4128
|
+
this._promiseBuffer = makePromiseBuffer(64);
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* @inheritDoc
|
|
4132
|
+
*/
|
|
4133
|
+
_prepareEvent(event, hint, currentScope, isolationScope) {
|
|
4134
|
+
if (this._options.platform) event.platform = event.platform || this._options.platform;
|
|
4135
|
+
if (this._options.runtime) event.contexts = {
|
|
4136
|
+
...event.contexts,
|
|
4137
|
+
runtime: event.contexts?.runtime || this._options.runtime
|
|
4138
|
+
};
|
|
4139
|
+
if (this._options.serverName) event.server_name = event.server_name || this._options.serverName;
|
|
4140
|
+
return super._prepareEvent(event, hint, currentScope, isolationScope);
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Process a server-side metric before it is captured.
|
|
4144
|
+
*/
|
|
4145
|
+
_setUpMetricsProcessing() {
|
|
4146
|
+
this.on("processMetric", (metric) => {
|
|
4147
|
+
if (this._options.serverName) metric.attributes = {
|
|
4148
|
+
"server.address": this._options.serverName,
|
|
4149
|
+
...metric.attributes
|
|
4150
|
+
};
|
|
4151
|
+
});
|
|
4152
|
+
}
|
|
4153
|
+
};
|
|
4154
|
+
function setCurrentRequestSessionErroredOrCrashed(eventHint) {
|
|
4155
|
+
const requestSession = getIsolationScope().getScopeData().sdkProcessingMetadata.requestSession;
|
|
4156
|
+
if (requestSession) {
|
|
4157
|
+
const isHandledException = eventHint?.mechanism?.handled ?? true;
|
|
4158
|
+
if (isHandledException && requestSession.status !== "crashed") requestSession.status = "errored";
|
|
4159
|
+
else if (!isHandledException) requestSession.status = "crashed";
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
//#endregion
|
|
4163
|
+
//#region node_modules/@sentry/core/build/esm/utils/node-stack-trace.js
|
|
4164
|
+
function filenameIsInApp(filename, isNative = false) {
|
|
4165
|
+
return !(isNative || filename && !filename.startsWith("/") && !filename.match(/^[A-Z]:/) && !filename.startsWith(".") && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//)) && filename !== void 0 && !filename.includes("node_modules/");
|
|
4166
|
+
}
|
|
4167
|
+
function node(getModule) {
|
|
4168
|
+
const FILENAME_MATCH = /^\s*[-]{4,}$/;
|
|
4169
|
+
const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
|
|
4170
|
+
const DATA_URI_MATCH = /at (?:async )?(.+?) \(data:(.*?),/;
|
|
4171
|
+
return (line) => {
|
|
4172
|
+
const dataUriMatch = line.match(DATA_URI_MATCH);
|
|
4173
|
+
if (dataUriMatch) return {
|
|
4174
|
+
filename: `<data:${dataUriMatch[2]}>`,
|
|
4175
|
+
function: dataUriMatch[1]
|
|
4176
|
+
};
|
|
4177
|
+
const lineMatch = line.match(FULL_MATCH);
|
|
4178
|
+
if (lineMatch) {
|
|
4179
|
+
let object;
|
|
4180
|
+
let method;
|
|
4181
|
+
let functionName;
|
|
4182
|
+
let typeName;
|
|
4183
|
+
let methodName;
|
|
4184
|
+
if (lineMatch[1]) {
|
|
4185
|
+
functionName = lineMatch[1];
|
|
4186
|
+
let methodStart = functionName.lastIndexOf(".");
|
|
4187
|
+
if (functionName[methodStart - 1] === ".") methodStart--;
|
|
4188
|
+
if (methodStart > 0) {
|
|
4189
|
+
object = functionName.slice(0, methodStart);
|
|
4190
|
+
method = functionName.slice(methodStart + 1);
|
|
4191
|
+
const objectEnd = object.indexOf(".Module");
|
|
4192
|
+
if (objectEnd > 0) {
|
|
4193
|
+
functionName = functionName.slice(objectEnd + 1);
|
|
4194
|
+
object = object.slice(0, objectEnd);
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
typeName = void 0;
|
|
4198
|
+
}
|
|
4199
|
+
if (method) {
|
|
4200
|
+
typeName = object;
|
|
4201
|
+
methodName = method;
|
|
4202
|
+
}
|
|
4203
|
+
if (method === "<anonymous>") {
|
|
4204
|
+
methodName = void 0;
|
|
4205
|
+
functionName = void 0;
|
|
4206
|
+
}
|
|
4207
|
+
if (functionName === void 0) {
|
|
4208
|
+
methodName = methodName || "?";
|
|
4209
|
+
functionName = typeName ? `${typeName}.${methodName}` : methodName;
|
|
4210
|
+
}
|
|
4211
|
+
let filename = normalizeStackTracePath(lineMatch[2]);
|
|
4212
|
+
const isNative = lineMatch[5] === "native";
|
|
4213
|
+
if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
|
|
4214
|
+
const maybeDecodedFilename = filename ? _safeDecodeURI(filename) : void 0;
|
|
4215
|
+
return {
|
|
4216
|
+
filename: maybeDecodedFilename ?? filename,
|
|
4217
|
+
module: maybeDecodedFilename && getModule?.(maybeDecodedFilename),
|
|
4218
|
+
function: functionName,
|
|
4219
|
+
lineno: _parseIntOrUndefined(lineMatch[3]),
|
|
4220
|
+
colno: _parseIntOrUndefined(lineMatch[4]),
|
|
4221
|
+
in_app: filenameIsInApp(filename || "", isNative)
|
|
4222
|
+
};
|
|
4223
|
+
}
|
|
4224
|
+
if (line.match(FILENAME_MATCH)) return { filename: line };
|
|
4225
|
+
};
|
|
4226
|
+
}
|
|
4227
|
+
function nodeStackLineParser(getModule) {
|
|
4228
|
+
return [90, node(getModule)];
|
|
4229
|
+
}
|
|
4230
|
+
function _parseIntOrUndefined(input) {
|
|
4231
|
+
return parseInt(input || "", 10) || void 0;
|
|
4232
|
+
}
|
|
4233
|
+
function _safeDecodeURI(filename) {
|
|
4234
|
+
try {
|
|
4235
|
+
return decodeURI(filename);
|
|
4236
|
+
} catch {
|
|
4237
|
+
return;
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
//#endregion
|
|
4241
|
+
//#region src/report/sentry.ts
|
|
4242
|
+
/** How long a report may hold the terminal before the CLI exits without it. */
|
|
4243
|
+
const FLUSH_MS = 2e3;
|
|
4244
|
+
/**
|
|
4245
|
+
* send delivers one report, and answers its event id only once Sentry has accepted it, so a
|
|
4246
|
+
* person is never given a reference for a report that never arrived.
|
|
4247
|
+
*/
|
|
4248
|
+
async function send(delivery) {
|
|
4249
|
+
const { telemetry, occasion, status } = delivery;
|
|
4250
|
+
const outcome = { isAccepted: false };
|
|
4251
|
+
const client = new ServerRuntimeClient({
|
|
4252
|
+
dsn: telemetry.dsn,
|
|
4253
|
+
release: telemetry.release,
|
|
4254
|
+
environment: telemetry.environment,
|
|
4255
|
+
platform: "node",
|
|
4256
|
+
runtime: {
|
|
4257
|
+
name: "node",
|
|
4258
|
+
version: process.version
|
|
4259
|
+
},
|
|
4260
|
+
sampleRate: 1,
|
|
4261
|
+
maxBreadcrumbs: 0,
|
|
4262
|
+
sendClientReports: false,
|
|
4263
|
+
normalizeDepth: 6,
|
|
4264
|
+
stackParser: createStackParser(nodeStackLineParser()),
|
|
4265
|
+
integrations: [linkedErrorsIntegration(), rewriteFramesIntegration({ root: dirname(fileURLToPath(import.meta.url)) })],
|
|
4266
|
+
transport: (options) => createTransport(options, async (request) => {
|
|
4267
|
+
const body = typeof request.body === "string" ? request.body : new TextDecoder().decode(request.body);
|
|
4268
|
+
const statusCode = await toPosted(options.url, toScrubbedEnvelope(body, delivery.secrets));
|
|
4269
|
+
outcome.isAccepted = statusCode >= 200 && statusCode < 300;
|
|
4270
|
+
return { statusCode };
|
|
4271
|
+
})
|
|
4272
|
+
});
|
|
4273
|
+
client.init();
|
|
4274
|
+
const scope = new Scope();
|
|
4275
|
+
scope.setClient(client);
|
|
4276
|
+
scope.setLevel(occasion.level);
|
|
4277
|
+
scope.setTags(toTags(delivery));
|
|
4278
|
+
scope.setContext("invocation", {
|
|
4279
|
+
command: occasion.invocation.command,
|
|
4280
|
+
flags: occasion.invocation.flags
|
|
4281
|
+
});
|
|
4282
|
+
for (const [name, section] of Object.entries(toPrivate(status ?? {}))) if (section !== null && typeof section === "object" && !Array.isArray(section)) scope.setContext(`status.${name}`, section);
|
|
4283
|
+
const person = toIdentity(status)?.person?.key;
|
|
4284
|
+
if (person) scope.setUser({ id: person });
|
|
4285
|
+
const id = scope.captureException(delivery.error, { mechanism: {
|
|
4286
|
+
type: occasion.mechanism,
|
|
4287
|
+
handled: occasion.level !== "fatal"
|
|
4288
|
+
} });
|
|
4289
|
+
return await client.flush(FLUSH_MS) && outcome.isAccepted ? id : void 0;
|
|
4290
|
+
}
|
|
4291
|
+
/**
|
|
4292
|
+
* toPosted sends an envelope and answers the status Sentry gave. Flushing only stops waiting,
|
|
4293
|
+
* and an aborted fetch still leaves its connection attempt holding the process open, so the
|
|
4294
|
+
* request is destroyed when its own deadline passes, even while it is still connecting.
|
|
4295
|
+
*/
|
|
4296
|
+
function toPosted(url, body) {
|
|
4297
|
+
return new Promise((resolve, reject) => {
|
|
4298
|
+
const target = new URL(url);
|
|
4299
|
+
const request$2 = (target.protocol === "http:" ? request : request$1)(target, {
|
|
4300
|
+
method: "POST",
|
|
4301
|
+
headers: {
|
|
4302
|
+
"Content-Type": "application/x-sentry-envelope",
|
|
4303
|
+
"Content-Length": Buffer.byteLength(body)
|
|
4304
|
+
}
|
|
4305
|
+
}, (response) => {
|
|
4306
|
+
clearTimeout(deadline);
|
|
4307
|
+
response.resume();
|
|
4308
|
+
resolve(response.statusCode ?? 0);
|
|
4309
|
+
});
|
|
4310
|
+
const deadline = setTimeout(() => request$2.destroy(/* @__PURE__ */ new Error("Sentry did not answer in time")), FLUSH_MS);
|
|
4311
|
+
request$2.on("error", (error) => {
|
|
4312
|
+
clearTimeout(deadline);
|
|
4313
|
+
reject(error);
|
|
4314
|
+
});
|
|
4315
|
+
request$2.end(body);
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
/**
|
|
4319
|
+
* toScrubbedEnvelope scrubs the whole envelope as text, which reaches every message, frame
|
|
4320
|
+
* and context at once. A Windows home directory appears escaped inside JSON, so both
|
|
4321
|
+
* spellings are replaced.
|
|
4322
|
+
*/
|
|
4323
|
+
function toScrubbedEnvelope(body, secrets) {
|
|
4324
|
+
const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
|
|
4325
|
+
const escaped = JSON.stringify(home).slice(1, -1);
|
|
4326
|
+
return toScrubbed(escaped === home || home.length <= 1 ? body : body.split(escaped).join("~"), secrets, home);
|
|
4327
|
+
}
|
|
4328
|
+
function toIdentity(status) {
|
|
4329
|
+
return (status?.["api"])?.identity;
|
|
4330
|
+
}
|
|
4331
|
+
/**
|
|
4332
|
+
* toPrivate removes people's and organizations' names from the status report. The keys that
|
|
4333
|
+
* identify them stay, which is enough to find them without sending who they are.
|
|
4334
|
+
*/
|
|
4335
|
+
function toPrivate(status) {
|
|
4336
|
+
const identity = toIdentity(status);
|
|
4337
|
+
if (!identity) return status;
|
|
4338
|
+
const api = status["api"];
|
|
4339
|
+
const { organization, person } = identity;
|
|
4340
|
+
return {
|
|
4341
|
+
...status,
|
|
4342
|
+
api: {
|
|
4343
|
+
...api,
|
|
4344
|
+
identity: {
|
|
4345
|
+
...api["identity"],
|
|
4346
|
+
organization: organization ? {
|
|
4347
|
+
...organization,
|
|
4348
|
+
name: void 0
|
|
4349
|
+
} : void 0,
|
|
4350
|
+
person: person ? {
|
|
4351
|
+
...person,
|
|
4352
|
+
firstName: void 0,
|
|
4353
|
+
lastName: void 0
|
|
4354
|
+
} : void 0
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
}
|
|
4359
|
+
/** toTags picks the few values worth searching by, each with few distinct values. */
|
|
4360
|
+
function toTags(delivery) {
|
|
4361
|
+
const { occasion, status } = delivery;
|
|
4362
|
+
const cli = status?.["cli"];
|
|
4363
|
+
const host = status?.["host"];
|
|
4364
|
+
const credential = status?.["credential"];
|
|
4365
|
+
const api = status?.["api"];
|
|
4366
|
+
const tags = {
|
|
4367
|
+
command: occasion.invocation.command,
|
|
4368
|
+
mode: occasion.mode,
|
|
4369
|
+
"os.platform": process.platform,
|
|
4370
|
+
"os.arch": host?.arch ?? process.arch,
|
|
4371
|
+
"node.version": process.version,
|
|
4372
|
+
wsl: String(host?.wsl !== void 0 && host.wsl !== null && host.wsl !== false),
|
|
4373
|
+
interactive: String(cli?.interactive === true),
|
|
4374
|
+
ci: String(Boolean(process.env["CI"])),
|
|
4375
|
+
"auth.kind": credential?.kind ?? "unknown",
|
|
4376
|
+
"api.reachable": String(api?.reachable ?? "unknown")
|
|
4377
|
+
};
|
|
4378
|
+
if (api?.url) tags["api.host"] = new URL(api.url).host;
|
|
4379
|
+
const organization = toIdentity(status)?.organization?.key;
|
|
4380
|
+
if (organization) tags["organization"] = organization;
|
|
4381
|
+
return tags;
|
|
4382
|
+
}
|
|
4383
|
+
//#endregion
|
|
4384
|
+
export { send };
|