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