@capxul/cli 4.20.0-beta.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.
@@ -0,0 +1,4092 @@
1
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/debug-build.js
2
+ /**
3
+ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
4
+ *
5
+ * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
6
+ */
7
+ const DEBUG_BUILD$1 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
8
+ //#endregion
9
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/worldwide.js
10
+ /** Internal global with common properties and Sentry extensions */
11
+ /** Get's the global object for the current JavaScript runtime */
12
+ const GLOBAL_OBJ = globalThis;
13
+ //#endregion
14
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/version.js
15
+ const SDK_VERSION = "9.47.1";
16
+ //#endregion
17
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/carrier.js
18
+ /**
19
+ * An object that contains globally accessible properties and maintains a scope stack.
20
+ * @hidden
21
+ */
22
+ /**
23
+ * Returns the global shim registry.
24
+ *
25
+ * FIXME: This function is problematic, because despite always returning a valid Carrier,
26
+ * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
27
+ * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
28
+ **/
29
+ function getMainCarrier() {
30
+ getSentryCarrier(GLOBAL_OBJ);
31
+ return GLOBAL_OBJ;
32
+ }
33
+ /** Will either get the existing sentry carrier, or create a new one. */
34
+ function getSentryCarrier(carrier) {
35
+ const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {};
36
+ __SENTRY__.version = __SENTRY__.version || "9.47.1";
37
+ return __SENTRY__[SDK_VERSION] = __SENTRY__["9.47.1"] || {};
38
+ }
39
+ /**
40
+ * Returns a global singleton contained in the global `__SENTRY__[]` object.
41
+ *
42
+ * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
43
+ * function and added to the `__SENTRY__` object.
44
+ *
45
+ * @param name name of the global singleton on __SENTRY__
46
+ * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
47
+ * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
48
+ * @returns the singleton
49
+ */
50
+ function getGlobalSingleton(name, creator, obj = GLOBAL_OBJ) {
51
+ const __SENTRY__ = obj.__SENTRY__ = obj.__SENTRY__ || {};
52
+ const carrier = __SENTRY__[SDK_VERSION] = __SENTRY__["9.47.1"] || {};
53
+ return carrier[name] || (carrier[name] = creator());
54
+ }
55
+ //#endregion
56
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/debug-logger.js
57
+ /** Prefix for logging strings */
58
+ const PREFIX = "Sentry Logger ";
59
+ /** This may be mutated by the console instrumentation. */
60
+ const originalConsoleMethods = {};
61
+ /**
62
+ * Temporarily disable sentry console instrumentations.
63
+ *
64
+ * @param callback The function to run against the original `console` messages
65
+ * @returns The results of the callback
66
+ */
67
+ function consoleSandbox(callback) {
68
+ if (!("console" in GLOBAL_OBJ)) return callback();
69
+ const console = GLOBAL_OBJ.console;
70
+ const wrappedFuncs = {};
71
+ const wrappedLevels = Object.keys(originalConsoleMethods);
72
+ wrappedLevels.forEach((level) => {
73
+ const originalConsoleMethod = originalConsoleMethods[level];
74
+ wrappedFuncs[level] = console[level];
75
+ console[level] = originalConsoleMethod;
76
+ });
77
+ try {
78
+ return callback();
79
+ } finally {
80
+ wrappedLevels.forEach((level) => {
81
+ console[level] = wrappedFuncs[level];
82
+ });
83
+ }
84
+ }
85
+ function enable() {
86
+ _getLoggerSettings().enabled = true;
87
+ }
88
+ function disable() {
89
+ _getLoggerSettings().enabled = false;
90
+ }
91
+ function isEnabled() {
92
+ return _getLoggerSettings().enabled;
93
+ }
94
+ function log(...args) {
95
+ _maybeLog("log", ...args);
96
+ }
97
+ function warn(...args) {
98
+ _maybeLog("warn", ...args);
99
+ }
100
+ function error(...args) {
101
+ _maybeLog("error", ...args);
102
+ }
103
+ function _maybeLog(level, ...args) {
104
+ if (!DEBUG_BUILD$1) return;
105
+ if (isEnabled()) consoleSandbox(() => {
106
+ GLOBAL_OBJ.console[level](`${PREFIX}[${level}]:`, ...args);
107
+ });
108
+ }
109
+ function _getLoggerSettings() {
110
+ if (!DEBUG_BUILD$1) return { enabled: false };
111
+ return getGlobalSingleton("loggerSettings", () => ({ enabled: false }));
112
+ }
113
+ /**
114
+ * This is a logger singleton which either logs things or no-ops if logging is not enabled.
115
+ */
116
+ const debug = {
117
+ /** Enable logging. */
118
+ enable,
119
+ /** Disable logging. */
120
+ disable,
121
+ /** Check if logging is enabled. */
122
+ isEnabled,
123
+ /** Log a message. */
124
+ log,
125
+ /** Log a warning. */
126
+ warn,
127
+ /** Log an error. */
128
+ error
129
+ };
130
+ //#endregion
131
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/stacktrace.js
132
+ const STACKTRACE_FRAME_LIMIT = 50;
133
+ const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
134
+ const STRIP_FRAME_REGEXP = /captureMessage|captureException/;
135
+ /**
136
+ * Creates a stack parser with the supplied line parsers
137
+ *
138
+ * StackFrames are returned in the correct order for Sentry Exception
139
+ * frames and with Sentry SDK internal frames removed from the top and bottom
140
+ *
141
+ */
142
+ function createStackParser(...parsers) {
143
+ const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map((p) => p[1]);
144
+ return (stack, skipFirstLines = 0, framesToPop = 0) => {
145
+ const frames = [];
146
+ const lines = stack.split("\n");
147
+ for (let i = skipFirstLines; i < lines.length; i++) {
148
+ const line = lines[i];
149
+ if (line.length > 1024) continue;
150
+ const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
151
+ if (cleanedLine.match(/\S*Error: /)) continue;
152
+ for (const parser of sortedParsers) {
153
+ const frame = parser(cleanedLine);
154
+ if (frame) {
155
+ frames.push(frame);
156
+ break;
157
+ }
158
+ }
159
+ if (frames.length >= STACKTRACE_FRAME_LIMIT + framesToPop) break;
160
+ }
161
+ return stripSentryFramesAndReverse(frames.slice(framesToPop));
162
+ };
163
+ }
164
+ /**
165
+ * Removes Sentry frames from the top and bottom of the stack if present and enforces a limit of max number of frames.
166
+ * Assumes stack input is ordered from top to bottom and returns the reverse representation so call site of the
167
+ * function that caused the crash is the last frame in the array.
168
+ * @hidden
169
+ */
170
+ function stripSentryFramesAndReverse(stack) {
171
+ if (!stack.length) return [];
172
+ const localStack = Array.from(stack);
173
+ if (/sentryWrapped/.test(getLastStackFrame(localStack).function || "")) localStack.pop();
174
+ localStack.reverse();
175
+ if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || "")) {
176
+ localStack.pop();
177
+ if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || "")) localStack.pop();
178
+ }
179
+ return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame) => ({
180
+ ...frame,
181
+ filename: frame.filename || getLastStackFrame(localStack).filename,
182
+ function: frame.function || "?"
183
+ }));
184
+ }
185
+ function getLastStackFrame(arr) {
186
+ return arr[arr.length - 1] || {};
187
+ }
188
+ const defaultFunctionName = "<anonymous>";
189
+ /**
190
+ * Safely extract function name from itself
191
+ */
192
+ function getFunctionName(fn) {
193
+ try {
194
+ if (!fn || typeof fn !== "function") return defaultFunctionName;
195
+ return fn.name || defaultFunctionName;
196
+ } catch {
197
+ return defaultFunctionName;
198
+ }
199
+ }
200
+ //#endregion
201
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/is.js
202
+ const objectToString = Object.prototype.toString;
203
+ /**
204
+ * Checks whether given value's type is one of a few Error or Error-like
205
+ * {@link isError}.
206
+ *
207
+ * @param wat A value to be checked.
208
+ * @returns A boolean representing the result.
209
+ */
210
+ function isError(wat) {
211
+ switch (objectToString.call(wat)) {
212
+ case "[object Error]":
213
+ case "[object Exception]":
214
+ case "[object DOMException]":
215
+ case "[object WebAssembly.Exception]": return true;
216
+ default: return isInstanceOf(wat, Error);
217
+ }
218
+ }
219
+ /**
220
+ * Checks whether given value is an instance of the given built-in class.
221
+ *
222
+ * @param wat The value to be checked
223
+ * @param className
224
+ * @returns A boolean representing the result.
225
+ */
226
+ function isBuiltin(wat, className) {
227
+ return objectToString.call(wat) === `[object ${className}]`;
228
+ }
229
+ /**
230
+ * Checks whether given value's type is ErrorEvent
231
+ * {@link isErrorEvent}.
232
+ *
233
+ * @param wat A value to be checked.
234
+ * @returns A boolean representing the result.
235
+ */
236
+ function isErrorEvent$1(wat) {
237
+ return isBuiltin(wat, "ErrorEvent");
238
+ }
239
+ /**
240
+ * Checks whether given value's type is DOMError
241
+ * {@link isDOMError}.
242
+ *
243
+ * @param wat A value to be checked.
244
+ * @returns A boolean representing the result.
245
+ */
246
+ function isDOMError(wat) {
247
+ return isBuiltin(wat, "DOMError");
248
+ }
249
+ /**
250
+ * Checks whether given value's type is DOMException
251
+ * {@link isDOMException}.
252
+ *
253
+ * @param wat A value to be checked.
254
+ * @returns A boolean representing the result.
255
+ */
256
+ function isDOMException(wat) {
257
+ return isBuiltin(wat, "DOMException");
258
+ }
259
+ /**
260
+ * Checks whether given value's type is a string
261
+ * {@link isString}.
262
+ *
263
+ * @param wat A value to be checked.
264
+ * @returns A boolean representing the result.
265
+ */
266
+ function isString(wat) {
267
+ return isBuiltin(wat, "String");
268
+ }
269
+ /**
270
+ * Checks whether given string is parameterized
271
+ * {@link isParameterizedString}.
272
+ *
273
+ * @param wat A value to be checked.
274
+ * @returns A boolean representing the result.
275
+ */
276
+ function isParameterizedString(wat) {
277
+ return typeof wat === "object" && wat !== null && "__sentry_template_string__" in wat && "__sentry_template_values__" in wat;
278
+ }
279
+ /**
280
+ * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
281
+ * {@link isPrimitive}.
282
+ *
283
+ * @param wat A value to be checked.
284
+ * @returns A boolean representing the result.
285
+ */
286
+ function isPrimitive(wat) {
287
+ return wat === null || isParameterizedString(wat) || typeof wat !== "object" && typeof wat !== "function";
288
+ }
289
+ /**
290
+ * Checks whether given value's type is an object literal, or a class instance.
291
+ * {@link isPlainObject}.
292
+ *
293
+ * @param wat A value to be checked.
294
+ * @returns A boolean representing the result.
295
+ */
296
+ function isPlainObject(wat) {
297
+ return isBuiltin(wat, "Object");
298
+ }
299
+ /**
300
+ * Checks whether given value's type is an Event instance
301
+ * {@link isEvent}.
302
+ *
303
+ * @param wat A value to be checked.
304
+ * @returns A boolean representing the result.
305
+ */
306
+ function isEvent(wat) {
307
+ return typeof Event !== "undefined" && isInstanceOf(wat, Event);
308
+ }
309
+ /**
310
+ * Checks whether given value's type is an Element instance
311
+ * {@link isElement}.
312
+ *
313
+ * @param wat A value to be checked.
314
+ * @returns A boolean representing the result.
315
+ */
316
+ function isElement(wat) {
317
+ return typeof Element !== "undefined" && isInstanceOf(wat, Element);
318
+ }
319
+ /**
320
+ * Checks whether given value has a then function.
321
+ * @param wat A value to be checked.
322
+ */
323
+ function isThenable(wat) {
324
+ return Boolean(wat?.then && typeof wat.then === "function");
325
+ }
326
+ /**
327
+ * Checks whether given value's type is a SyntheticEvent
328
+ * {@link isSyntheticEvent}.
329
+ *
330
+ * @param wat A value to be checked.
331
+ * @returns A boolean representing the result.
332
+ */
333
+ function isSyntheticEvent(wat) {
334
+ return isPlainObject(wat) && "nativeEvent" in wat && "preventDefault" in wat && "stopPropagation" in wat;
335
+ }
336
+ /**
337
+ * Checks whether given value's type is an instance of provided constructor.
338
+ * {@link isInstanceOf}.
339
+ *
340
+ * @param wat A value to be checked.
341
+ * @param base A constructor to be used in a check.
342
+ * @returns A boolean representing the result.
343
+ */
344
+ function isInstanceOf(wat, base) {
345
+ try {
346
+ return wat instanceof base;
347
+ } catch {
348
+ return false;
349
+ }
350
+ }
351
+ /**
352
+ * Checks whether given value's type is a Vue ViewModel.
353
+ *
354
+ * @param wat A value to be checked.
355
+ * @returns A boolean representing the result.
356
+ */
357
+ function isVueViewModel(wat) {
358
+ return !!(typeof wat === "object" && wat !== null && (wat.__isVue || wat._isVue));
359
+ }
360
+ //#endregion
361
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/browser.js
362
+ const WINDOW$2 = GLOBAL_OBJ;
363
+ const DEFAULT_MAX_STRING_LENGTH = 80;
364
+ /**
365
+ * Given a child DOM element, returns a query-selector statement describing that
366
+ * and its ancestors
367
+ * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz]
368
+ * @returns generated DOM path
369
+ */
370
+ function htmlTreeAsString(elem, options = {}) {
371
+ if (!elem) return "<unknown>";
372
+ try {
373
+ let currentElem = elem;
374
+ const MAX_TRAVERSE_HEIGHT = 5;
375
+ const out = [];
376
+ let height = 0;
377
+ let len = 0;
378
+ const separator = " > ";
379
+ const sepLength = 3;
380
+ let nextStr;
381
+ const keyAttrs = Array.isArray(options) ? options : options.keyAttrs;
382
+ const maxStringLength = !Array.isArray(options) && options.maxStringLength || DEFAULT_MAX_STRING_LENGTH;
383
+ while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) {
384
+ nextStr = _htmlElementAsString(currentElem, keyAttrs);
385
+ if (nextStr === "html" || height > 1 && len + out.length * sepLength + nextStr.length >= maxStringLength) break;
386
+ out.push(nextStr);
387
+ len += nextStr.length;
388
+ currentElem = currentElem.parentNode;
389
+ }
390
+ return out.reverse().join(separator);
391
+ } catch {
392
+ return "<unknown>";
393
+ }
394
+ }
395
+ /**
396
+ * Returns a simple, query-selector representation of a DOM element
397
+ * e.g. [HTMLElement] => input#foo.btn[name=baz]
398
+ * @returns generated DOM path
399
+ */
400
+ function _htmlElementAsString(el, keyAttrs) {
401
+ const elem = el;
402
+ const out = [];
403
+ if (!elem?.tagName) return "";
404
+ if (WINDOW$2.HTMLElement) {
405
+ if (elem instanceof HTMLElement && elem.dataset) {
406
+ if (elem.dataset["sentryComponent"]) return elem.dataset["sentryComponent"];
407
+ if (elem.dataset["sentryElement"]) return elem.dataset["sentryElement"];
408
+ }
409
+ }
410
+ out.push(elem.tagName.toLowerCase());
411
+ const keyAttrPairs = keyAttrs?.length ? keyAttrs.filter((keyAttr) => elem.getAttribute(keyAttr)).map((keyAttr) => [keyAttr, elem.getAttribute(keyAttr)]) : null;
412
+ if (keyAttrPairs?.length) keyAttrPairs.forEach((keyAttrPair) => {
413
+ out.push(`[${keyAttrPair[0]}="${keyAttrPair[1]}"]`);
414
+ });
415
+ else {
416
+ if (elem.id) out.push(`#${elem.id}`);
417
+ const className = elem.className;
418
+ if (className && isString(className)) {
419
+ const classes = className.split(/\s+/);
420
+ for (const c of classes) out.push(`.${c}`);
421
+ }
422
+ }
423
+ for (const k of [
424
+ "aria-label",
425
+ "type",
426
+ "name",
427
+ "title",
428
+ "alt"
429
+ ]) {
430
+ const attr = elem.getAttribute(k);
431
+ if (attr) out.push(`[${k}="${attr}"]`);
432
+ }
433
+ return out.join("");
434
+ }
435
+ //#endregion
436
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/string.js
437
+ /**
438
+ * Truncates given string to the maximum characters count
439
+ *
440
+ * @param str An object that contains serializable values
441
+ * @param max Maximum number of characters in truncated string (0 = unlimited)
442
+ * @returns string Encoded
443
+ */
444
+ function truncate(str, max = 0) {
445
+ if (typeof str !== "string" || max === 0) return str;
446
+ return str.length <= max ? str : `${str.slice(0, max)}...`;
447
+ }
448
+ //#endregion
449
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/object.js
450
+ /**
451
+ * Defines a non-enumerable property on the given object.
452
+ *
453
+ * @param obj The object on which to set the property
454
+ * @param name The name of the property to be set
455
+ * @param value The value to which to set the property
456
+ */
457
+ function addNonEnumerableProperty(obj, name, value) {
458
+ try {
459
+ Object.defineProperty(obj, name, {
460
+ value,
461
+ writable: true,
462
+ configurable: true
463
+ });
464
+ } catch {
465
+ DEBUG_BUILD$1 && debug.log(`Failed to add non-enumerable property "${name}" to object`, obj);
466
+ }
467
+ }
468
+ /**
469
+ * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their
470
+ * non-enumerable properties attached.
471
+ *
472
+ * @param value Initial source that we have to transform in order for it to be usable by the serializer
473
+ * @returns An Event or Error turned into an object - or the value argument itself, when value is neither an Event nor
474
+ * an Error.
475
+ */
476
+ function convertToPlainObject(value) {
477
+ if (isError(value)) return {
478
+ message: value.message,
479
+ name: value.name,
480
+ stack: value.stack,
481
+ ...getOwnProperties(value)
482
+ };
483
+ else if (isEvent(value)) {
484
+ const newObj = {
485
+ type: value.type,
486
+ target: serializeEventTarget(value.target),
487
+ currentTarget: serializeEventTarget(value.currentTarget),
488
+ ...getOwnProperties(value)
489
+ };
490
+ if (typeof CustomEvent !== "undefined" && isInstanceOf(value, CustomEvent)) newObj.detail = value.detail;
491
+ return newObj;
492
+ } else return value;
493
+ }
494
+ /** Creates a string representation of the target of an `Event` object */
495
+ function serializeEventTarget(target) {
496
+ try {
497
+ return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);
498
+ } catch {
499
+ return "<unknown>";
500
+ }
501
+ }
502
+ /** Filters out all but an object's own properties */
503
+ function getOwnProperties(obj) {
504
+ if (typeof obj === "object" && obj !== null) {
505
+ const extractedProps = {};
506
+ for (const property in obj) if (Object.prototype.hasOwnProperty.call(obj, property)) extractedProps[property] = obj[property];
507
+ return extractedProps;
508
+ } else return {};
509
+ }
510
+ /**
511
+ * Given any captured exception, extract its keys and create a sorted
512
+ * and truncated list that will be used inside the event message.
513
+ * eg. `Non-error exception captured with keys: foo, bar, baz`
514
+ */
515
+ function extractExceptionKeysForMessage(exception, maxLength = 40) {
516
+ const keys = Object.keys(convertToPlainObject(exception));
517
+ keys.sort();
518
+ const firstKey = keys[0];
519
+ if (!firstKey) return "[object has no keys]";
520
+ if (firstKey.length >= maxLength) return truncate(firstKey, maxLength);
521
+ for (let includedKeys = keys.length; includedKeys > 0; includedKeys--) {
522
+ const serialized = keys.slice(0, includedKeys).join(", ");
523
+ if (serialized.length > maxLength) continue;
524
+ if (includedKeys === keys.length) return serialized;
525
+ return truncate(serialized, maxLength);
526
+ }
527
+ return "";
528
+ }
529
+ //#endregion
530
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/misc.js
531
+ function getCrypto() {
532
+ const gbl = GLOBAL_OBJ;
533
+ return gbl.crypto || gbl.msCrypto;
534
+ }
535
+ /**
536
+ * UUID4 generator
537
+ * @param crypto Object that provides the crypto API.
538
+ * @returns string Generated UUID4.
539
+ */
540
+ function uuid4(crypto = getCrypto()) {
541
+ let getRandomByte = () => Math.random() * 16;
542
+ try {
543
+ if (crypto?.randomUUID) return crypto.randomUUID().replace(/-/g, "");
544
+ if (crypto?.getRandomValues) getRandomByte = () => {
545
+ const typedArray = /* @__PURE__ */ new Uint8Array(1);
546
+ crypto.getRandomValues(typedArray);
547
+ return typedArray[0];
548
+ };
549
+ } catch {}
550
+ return "10000000100040008000100000000000".replace(/[018]/g, (c) => (c ^ (getRandomByte() & 15) >> c / 4).toString(16));
551
+ }
552
+ function getFirstException(event) {
553
+ return event.exception?.values?.[0];
554
+ }
555
+ /**
556
+ * Adds exception values, type and value to an synthetic Exception.
557
+ * @param event The event to modify.
558
+ * @param value Value of the exception.
559
+ * @param type Type of the exception.
560
+ * @hidden
561
+ */
562
+ function addExceptionTypeValue(event, value, type) {
563
+ const exception = event.exception = event.exception || {};
564
+ const values = exception.values = exception.values || [];
565
+ const firstException = values[0] = values[0] || {};
566
+ if (!firstException.value) firstException.value = value || "";
567
+ if (!firstException.type) firstException.type = type || "Error";
568
+ }
569
+ /**
570
+ * Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
571
+ *
572
+ * @param event The event to modify.
573
+ * @param newMechanism Mechanism data to add to the event.
574
+ * @hidden
575
+ */
576
+ function addExceptionMechanism(event, newMechanism) {
577
+ const firstException = getFirstException(event);
578
+ if (!firstException) return;
579
+ const defaultMechanism = {
580
+ type: "generic",
581
+ handled: true
582
+ };
583
+ const currentMechanism = firstException.mechanism;
584
+ firstException.mechanism = {
585
+ ...defaultMechanism,
586
+ ...currentMechanism,
587
+ ...newMechanism
588
+ };
589
+ if (newMechanism && "data" in newMechanism) {
590
+ const mergedData = {
591
+ ...currentMechanism?.data,
592
+ ...newMechanism.data
593
+ };
594
+ firstException.mechanism.data = mergedData;
595
+ }
596
+ }
597
+ /**
598
+ * Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
599
+ * in question), and marks it captured if not.
600
+ *
601
+ * This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
602
+ * record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
603
+ * that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
604
+ * the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
605
+ * caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
606
+ * function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
607
+ * see it.
608
+ *
609
+ * Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
610
+ * them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
611
+ * object wrapper forms so that this check will always work. However, because we need to flag the exact object which
612
+ * will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
613
+ * must be done before the exception captured.
614
+ *
615
+ * @param A thrown exception to check or flag as having been seen
616
+ * @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
617
+ */
618
+ function checkOrSetAlreadyCaught(exception) {
619
+ if (isAlreadyCaptured(exception)) return true;
620
+ try {
621
+ addNonEnumerableProperty(exception, "__sentry_captured__", true);
622
+ } catch {}
623
+ return false;
624
+ }
625
+ function isAlreadyCaptured(exception) {
626
+ try {
627
+ return exception.__sentry_captured__;
628
+ } catch {}
629
+ }
630
+ //#endregion
631
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/time.js
632
+ const ONE_SECOND_IN_MS = 1e3;
633
+ /**
634
+ * A partial definition of the [Performance Web API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance}
635
+ * for accessing a high-resolution monotonic clock.
636
+ */
637
+ /**
638
+ * Returns a timestamp in seconds since the UNIX epoch using the Date API.
639
+ */
640
+ function dateTimestampInSeconds() {
641
+ return Date.now() / ONE_SECOND_IN_MS;
642
+ }
643
+ /**
644
+ * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not
645
+ * support the API.
646
+ *
647
+ * Wrapping the native API works around differences in behavior from different browsers.
648
+ */
649
+ function createUnixTimestampInSecondsFunc() {
650
+ const { performance } = GLOBAL_OBJ;
651
+ if (!performance?.now || !performance.timeOrigin) return dateTimestampInSeconds;
652
+ const timeOrigin = performance.timeOrigin;
653
+ return () => {
654
+ return (timeOrigin + performance.now()) / ONE_SECOND_IN_MS;
655
+ };
656
+ }
657
+ let _cachedTimestampInSeconds;
658
+ /**
659
+ * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the
660
+ * availability of the Performance API.
661
+ *
662
+ * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is
663
+ * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The
664
+ * skew can grow to arbitrary amounts like days, weeks or months.
665
+ * See https://github.com/getsentry/sentry-javascript/issues/2590.
666
+ */
667
+ function timestampInSeconds() {
668
+ return (_cachedTimestampInSeconds ?? (_cachedTimestampInSeconds = createUnixTimestampInSecondsFunc()))();
669
+ }
670
+ //#endregion
671
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/session.js
672
+ /**
673
+ * Updates a session object with the properties passed in the context.
674
+ *
675
+ * Note that this function mutates the passed object and returns void.
676
+ * (Had to do this instead of returning a new and updated session because closing and sending a session
677
+ * makes an update to the session after it was passed to the sending logic.
678
+ * @see Client.captureSession )
679
+ *
680
+ * @param session the `Session` to update
681
+ * @param context the `SessionContext` holding the properties that should be updated in @param session
682
+ */
683
+ function updateSession(session, context = {}) {
684
+ if (context.user) {
685
+ if (!session.ipAddress && context.user.ip_address) session.ipAddress = context.user.ip_address;
686
+ if (!session.did && !context.did) session.did = context.user.id || context.user.email || context.user.username;
687
+ }
688
+ session.timestamp = context.timestamp || timestampInSeconds();
689
+ if (context.abnormal_mechanism) session.abnormal_mechanism = context.abnormal_mechanism;
690
+ if (context.ignoreDuration) session.ignoreDuration = context.ignoreDuration;
691
+ if (context.sid) session.sid = context.sid.length === 32 ? context.sid : uuid4();
692
+ if (context.init !== void 0) session.init = context.init;
693
+ if (!session.did && context.did) session.did = `${context.did}`;
694
+ if (typeof context.started === "number") session.started = context.started;
695
+ if (session.ignoreDuration) session.duration = void 0;
696
+ else if (typeof context.duration === "number") session.duration = context.duration;
697
+ else {
698
+ const duration = session.timestamp - session.started;
699
+ session.duration = duration >= 0 ? duration : 0;
700
+ }
701
+ if (context.release) session.release = context.release;
702
+ if (context.environment) session.environment = context.environment;
703
+ if (!session.ipAddress && context.ipAddress) session.ipAddress = context.ipAddress;
704
+ if (!session.userAgent && context.userAgent) session.userAgent = context.userAgent;
705
+ if (typeof context.errors === "number") session.errors = context.errors;
706
+ if (context.status) session.status = context.status;
707
+ }
708
+ //#endregion
709
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/merge.js
710
+ /**
711
+ * Shallow merge two objects.
712
+ * Does not mutate the passed in objects.
713
+ * Undefined/empty values in the merge object will overwrite existing values.
714
+ *
715
+ * By default, this merges 2 levels deep.
716
+ */
717
+ function merge(initialObj, mergeObj, levels = 2) {
718
+ if (!mergeObj || typeof mergeObj !== "object" || levels <= 0) return mergeObj;
719
+ if (initialObj && Object.keys(mergeObj).length === 0) return initialObj;
720
+ const output = { ...initialObj };
721
+ for (const key in mergeObj) if (Object.prototype.hasOwnProperty.call(mergeObj, key)) output[key] = merge(output[key], mergeObj[key], levels - 1);
722
+ return output;
723
+ }
724
+ //#endregion
725
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/propagationContext.js
726
+ /**
727
+ * Generate a random, valid trace ID.
728
+ */
729
+ function generateTraceId() {
730
+ return uuid4();
731
+ }
732
+ /**
733
+ * Generate a random, valid span ID.
734
+ */
735
+ function generateSpanId() {
736
+ return uuid4().substring(16);
737
+ }
738
+ //#endregion
739
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/spanOnScope.js
740
+ const SCOPE_SPAN_FIELD = "_sentrySpan";
741
+ /**
742
+ * Set the active span for a given scope.
743
+ * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
744
+ */
745
+ function _setSpanForScope(scope, span) {
746
+ if (span) addNonEnumerableProperty(scope, SCOPE_SPAN_FIELD, span);
747
+ else delete scope[SCOPE_SPAN_FIELD];
748
+ }
749
+ /**
750
+ * Get the active span for a given scope.
751
+ * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
752
+ */
753
+ function _getSpanForScope(scope) {
754
+ return scope[SCOPE_SPAN_FIELD];
755
+ }
756
+ //#endregion
757
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/scope.js
758
+ /**
759
+ * Default value for maximum number of breadcrumbs added to an event.
760
+ */
761
+ const DEFAULT_MAX_BREADCRUMBS = 100;
762
+ /**
763
+ * A context to be used for capturing an event.
764
+ * This can either be a Scope, or a partial ScopeContext,
765
+ * or a callback that receives the current scope and returns a new scope to use.
766
+ */
767
+ /**
768
+ * Holds additional event information.
769
+ */
770
+ var Scope = class Scope {
771
+ /** Flag if notifying is happening. */
772
+ /** Callback for client to receive scope changes. */
773
+ /** Callback list that will be called during event processing. */
774
+ /** Array of breadcrumbs. */
775
+ /** User */
776
+ /** Tags */
777
+ /** Extra */
778
+ /** Contexts */
779
+ /** Attachments */
780
+ /** Propagation Context for distributed tracing */
781
+ /**
782
+ * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
783
+ * sent to Sentry
784
+ */
785
+ /** Fingerprint */
786
+ /** Severity */
787
+ /**
788
+ * Transaction Name
789
+ *
790
+ * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.
791
+ * It's purpose is to assign a transaction to the scope that's added to non-transaction events.
792
+ */
793
+ /** Session */
794
+ /** The client on this scope */
795
+ /** Contains the last event id of a captured event. */
796
+ constructor() {
797
+ this._notifyingListeners = false;
798
+ this._scopeListeners = [];
799
+ this._eventProcessors = [];
800
+ this._breadcrumbs = [];
801
+ this._attachments = [];
802
+ this._user = {};
803
+ this._tags = {};
804
+ this._extra = {};
805
+ this._contexts = {};
806
+ this._sdkProcessingMetadata = {};
807
+ this._propagationContext = {
808
+ traceId: generateTraceId(),
809
+ sampleRand: Math.random()
810
+ };
811
+ }
812
+ /**
813
+ * Clone all data from this scope into a new scope.
814
+ */
815
+ clone() {
816
+ const newScope = new Scope();
817
+ newScope._breadcrumbs = [...this._breadcrumbs];
818
+ newScope._tags = { ...this._tags };
819
+ newScope._extra = { ...this._extra };
820
+ newScope._contexts = { ...this._contexts };
821
+ if (this._contexts.flags) newScope._contexts.flags = { values: [...this._contexts.flags.values] };
822
+ newScope._user = this._user;
823
+ newScope._level = this._level;
824
+ newScope._session = this._session;
825
+ newScope._transactionName = this._transactionName;
826
+ newScope._fingerprint = this._fingerprint;
827
+ newScope._eventProcessors = [...this._eventProcessors];
828
+ newScope._attachments = [...this._attachments];
829
+ newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };
830
+ newScope._propagationContext = { ...this._propagationContext };
831
+ newScope._client = this._client;
832
+ newScope._lastEventId = this._lastEventId;
833
+ _setSpanForScope(newScope, _getSpanForScope(this));
834
+ return newScope;
835
+ }
836
+ /**
837
+ * Update the client assigned to this scope.
838
+ * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,
839
+ * as well as manually created scopes.
840
+ */
841
+ setClient(client) {
842
+ this._client = client;
843
+ }
844
+ /**
845
+ * Set the ID of the last captured error event.
846
+ * This is generally only captured on the isolation scope.
847
+ */
848
+ setLastEventId(lastEventId) {
849
+ this._lastEventId = lastEventId;
850
+ }
851
+ /**
852
+ * Get the client assigned to this scope.
853
+ */
854
+ getClient() {
855
+ return this._client;
856
+ }
857
+ /**
858
+ * Get the ID of the last captured error event.
859
+ * This is generally only available on the isolation scope.
860
+ */
861
+ lastEventId() {
862
+ return this._lastEventId;
863
+ }
864
+ /**
865
+ * @inheritDoc
866
+ */
867
+ addScopeListener(callback) {
868
+ this._scopeListeners.push(callback);
869
+ }
870
+ /**
871
+ * Add an event processor that will be called before an event is sent.
872
+ */
873
+ addEventProcessor(callback) {
874
+ this._eventProcessors.push(callback);
875
+ return this;
876
+ }
877
+ /**
878
+ * Set the user for this scope.
879
+ * Set to `null` to unset the user.
880
+ */
881
+ setUser(user) {
882
+ this._user = user || {
883
+ email: void 0,
884
+ id: void 0,
885
+ ip_address: void 0,
886
+ username: void 0
887
+ };
888
+ if (this._session) updateSession(this._session, { user });
889
+ this._notifyScopeListeners();
890
+ return this;
891
+ }
892
+ /**
893
+ * Get the user from this scope.
894
+ */
895
+ getUser() {
896
+ return this._user;
897
+ }
898
+ /**
899
+ * Set an object that will be merged into existing tags on the scope,
900
+ * and will be sent as tags data with the event.
901
+ */
902
+ setTags(tags) {
903
+ this._tags = {
904
+ ...this._tags,
905
+ ...tags
906
+ };
907
+ this._notifyScopeListeners();
908
+ return this;
909
+ }
910
+ /**
911
+ * Set a single tag that will be sent as tags data with the event.
912
+ */
913
+ setTag(key, value) {
914
+ this._tags = {
915
+ ...this._tags,
916
+ [key]: value
917
+ };
918
+ this._notifyScopeListeners();
919
+ return this;
920
+ }
921
+ /**
922
+ * Set an object that will be merged into existing extra on the scope,
923
+ * and will be sent as extra data with the event.
924
+ */
925
+ setExtras(extras) {
926
+ this._extra = {
927
+ ...this._extra,
928
+ ...extras
929
+ };
930
+ this._notifyScopeListeners();
931
+ return this;
932
+ }
933
+ /**
934
+ * Set a single key:value extra entry that will be sent as extra data with the event.
935
+ */
936
+ setExtra(key, extra) {
937
+ this._extra = {
938
+ ...this._extra,
939
+ [key]: extra
940
+ };
941
+ this._notifyScopeListeners();
942
+ return this;
943
+ }
944
+ /**
945
+ * Sets the fingerprint on the scope to send with the events.
946
+ * @param {string[]} fingerprint Fingerprint to group events in Sentry.
947
+ */
948
+ setFingerprint(fingerprint) {
949
+ this._fingerprint = fingerprint;
950
+ this._notifyScopeListeners();
951
+ return this;
952
+ }
953
+ /**
954
+ * Sets the level on the scope for future events.
955
+ */
956
+ setLevel(level) {
957
+ this._level = level;
958
+ this._notifyScopeListeners();
959
+ return this;
960
+ }
961
+ /**
962
+ * Sets the transaction name on the scope so that the name of e.g. taken server route or
963
+ * the page location is attached to future events.
964
+ *
965
+ * IMPORTANT: Calling this function does NOT change the name of the currently active
966
+ * root span. If you want to change the name of the active root span, use
967
+ * `Sentry.updateSpanName(rootSpan, 'new name')` instead.
968
+ *
969
+ * By default, the SDK updates the scope's transaction name automatically on sensible
970
+ * occasions, such as a page navigation or when handling a new request on the server.
971
+ */
972
+ setTransactionName(name) {
973
+ this._transactionName = name;
974
+ this._notifyScopeListeners();
975
+ return this;
976
+ }
977
+ /**
978
+ * Sets context data with the given name.
979
+ * Data passed as context will be normalized. You can also pass `null` to unset the context.
980
+ * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.
981
+ */
982
+ setContext(key, context) {
983
+ if (context === null) delete this._contexts[key];
984
+ else this._contexts[key] = context;
985
+ this._notifyScopeListeners();
986
+ return this;
987
+ }
988
+ /**
989
+ * Set the session for the scope.
990
+ */
991
+ setSession(session) {
992
+ if (!session) delete this._session;
993
+ else this._session = session;
994
+ this._notifyScopeListeners();
995
+ return this;
996
+ }
997
+ /**
998
+ * Get the session from the scope.
999
+ */
1000
+ getSession() {
1001
+ return this._session;
1002
+ }
1003
+ /**
1004
+ * Updates the scope with provided data. Can work in three variations:
1005
+ * - plain object containing updatable attributes
1006
+ * - Scope instance that'll extract the attributes from
1007
+ * - callback function that'll receive the current scope as an argument and allow for modifications
1008
+ */
1009
+ update(captureContext) {
1010
+ if (!captureContext) return this;
1011
+ const scopeToMerge = typeof captureContext === "function" ? captureContext(this) : captureContext;
1012
+ const { tags, extra, user, contexts, level, fingerprint = [], propagationContext } = (scopeToMerge instanceof Scope ? scopeToMerge.getScopeData() : isPlainObject(scopeToMerge) ? captureContext : void 0) || {};
1013
+ this._tags = {
1014
+ ...this._tags,
1015
+ ...tags
1016
+ };
1017
+ this._extra = {
1018
+ ...this._extra,
1019
+ ...extra
1020
+ };
1021
+ this._contexts = {
1022
+ ...this._contexts,
1023
+ ...contexts
1024
+ };
1025
+ if (user && Object.keys(user).length) this._user = user;
1026
+ if (level) this._level = level;
1027
+ if (fingerprint.length) this._fingerprint = fingerprint;
1028
+ if (propagationContext) this._propagationContext = propagationContext;
1029
+ return this;
1030
+ }
1031
+ /**
1032
+ * Clears the current scope and resets its properties.
1033
+ * Note: The client will not be cleared.
1034
+ */
1035
+ clear() {
1036
+ this._breadcrumbs = [];
1037
+ this._tags = {};
1038
+ this._extra = {};
1039
+ this._user = {};
1040
+ this._contexts = {};
1041
+ this._level = void 0;
1042
+ this._transactionName = void 0;
1043
+ this._fingerprint = void 0;
1044
+ this._session = void 0;
1045
+ _setSpanForScope(this, void 0);
1046
+ this._attachments = [];
1047
+ this.setPropagationContext({
1048
+ traceId: generateTraceId(),
1049
+ sampleRand: Math.random()
1050
+ });
1051
+ this._notifyScopeListeners();
1052
+ return this;
1053
+ }
1054
+ /**
1055
+ * Adds a breadcrumb to the scope.
1056
+ * By default, the last 100 breadcrumbs are kept.
1057
+ */
1058
+ addBreadcrumb(breadcrumb, maxBreadcrumbs) {
1059
+ const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
1060
+ if (maxCrumbs <= 0) return this;
1061
+ const mergedBreadcrumb = {
1062
+ timestamp: dateTimestampInSeconds(),
1063
+ ...breadcrumb,
1064
+ message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message
1065
+ };
1066
+ this._breadcrumbs.push(mergedBreadcrumb);
1067
+ if (this._breadcrumbs.length > maxCrumbs) {
1068
+ this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);
1069
+ this._client?.recordDroppedEvent("buffer_overflow", "log_item");
1070
+ }
1071
+ this._notifyScopeListeners();
1072
+ return this;
1073
+ }
1074
+ /**
1075
+ * Get the last breadcrumb of the scope.
1076
+ */
1077
+ getLastBreadcrumb() {
1078
+ return this._breadcrumbs[this._breadcrumbs.length - 1];
1079
+ }
1080
+ /**
1081
+ * Clear all breadcrumbs from the scope.
1082
+ */
1083
+ clearBreadcrumbs() {
1084
+ this._breadcrumbs = [];
1085
+ this._notifyScopeListeners();
1086
+ return this;
1087
+ }
1088
+ /**
1089
+ * Add an attachment to the scope.
1090
+ */
1091
+ addAttachment(attachment) {
1092
+ this._attachments.push(attachment);
1093
+ return this;
1094
+ }
1095
+ /**
1096
+ * Clear all attachments from the scope.
1097
+ */
1098
+ clearAttachments() {
1099
+ this._attachments = [];
1100
+ return this;
1101
+ }
1102
+ /**
1103
+ * Get the data of this scope, which should be applied to an event during processing.
1104
+ */
1105
+ getScopeData() {
1106
+ return {
1107
+ breadcrumbs: this._breadcrumbs,
1108
+ attachments: this._attachments,
1109
+ contexts: this._contexts,
1110
+ tags: this._tags,
1111
+ extra: this._extra,
1112
+ user: this._user,
1113
+ level: this._level,
1114
+ fingerprint: this._fingerprint || [],
1115
+ eventProcessors: this._eventProcessors,
1116
+ propagationContext: this._propagationContext,
1117
+ sdkProcessingMetadata: this._sdkProcessingMetadata,
1118
+ transactionName: this._transactionName,
1119
+ span: _getSpanForScope(this)
1120
+ };
1121
+ }
1122
+ /**
1123
+ * Add data which will be accessible during event processing but won't get sent to Sentry.
1124
+ */
1125
+ setSDKProcessingMetadata(newData) {
1126
+ this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);
1127
+ return this;
1128
+ }
1129
+ /**
1130
+ * Add propagation context to the scope, used for distributed tracing
1131
+ */
1132
+ setPropagationContext(context) {
1133
+ this._propagationContext = context;
1134
+ return this;
1135
+ }
1136
+ /**
1137
+ * Get propagation context from the scope, used for distributed tracing
1138
+ */
1139
+ getPropagationContext() {
1140
+ return this._propagationContext;
1141
+ }
1142
+ /**
1143
+ * Capture an exception for this scope.
1144
+ *
1145
+ * @returns {string} The id of the captured Sentry event.
1146
+ */
1147
+ captureException(exception, hint) {
1148
+ const eventId = hint?.event_id || uuid4();
1149
+ if (!this._client) {
1150
+ DEBUG_BUILD$1 && debug.warn("No client configured on scope - will not capture exception!");
1151
+ return eventId;
1152
+ }
1153
+ const syntheticException = /* @__PURE__ */ new Error("Sentry syntheticException");
1154
+ this._client.captureException(exception, {
1155
+ originalException: exception,
1156
+ syntheticException,
1157
+ ...hint,
1158
+ event_id: eventId
1159
+ }, this);
1160
+ return eventId;
1161
+ }
1162
+ /**
1163
+ * Capture a message for this scope.
1164
+ *
1165
+ * @returns {string} The id of the captured message.
1166
+ */
1167
+ captureMessage(message, level, hint) {
1168
+ const eventId = hint?.event_id || uuid4();
1169
+ if (!this._client) {
1170
+ DEBUG_BUILD$1 && debug.warn("No client configured on scope - will not capture message!");
1171
+ return eventId;
1172
+ }
1173
+ const syntheticException = new Error(message);
1174
+ this._client.captureMessage(message, level, {
1175
+ originalException: message,
1176
+ syntheticException,
1177
+ ...hint,
1178
+ event_id: eventId
1179
+ }, this);
1180
+ return eventId;
1181
+ }
1182
+ /**
1183
+ * Capture a Sentry event for this scope.
1184
+ *
1185
+ * @returns {string} The id of the captured event.
1186
+ */
1187
+ captureEvent(event, hint) {
1188
+ const eventId = hint?.event_id || uuid4();
1189
+ if (!this._client) {
1190
+ DEBUG_BUILD$1 && debug.warn("No client configured on scope - will not capture event!");
1191
+ return eventId;
1192
+ }
1193
+ this._client.captureEvent(event, {
1194
+ ...hint,
1195
+ event_id: eventId
1196
+ }, this);
1197
+ return eventId;
1198
+ }
1199
+ /**
1200
+ * This will be called on every set call.
1201
+ */
1202
+ _notifyScopeListeners() {
1203
+ if (!this._notifyingListeners) {
1204
+ this._notifyingListeners = true;
1205
+ this._scopeListeners.forEach((callback) => {
1206
+ callback(this);
1207
+ });
1208
+ this._notifyingListeners = false;
1209
+ }
1210
+ }
1211
+ };
1212
+ //#endregion
1213
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/defaultScopes.js
1214
+ /** Get the default current scope. */
1215
+ function getDefaultCurrentScope() {
1216
+ return getGlobalSingleton("defaultCurrentScope", () => new Scope());
1217
+ }
1218
+ /** Get the default isolation scope. */
1219
+ function getDefaultIsolationScope() {
1220
+ return getGlobalSingleton("defaultIsolationScope", () => new Scope());
1221
+ }
1222
+ //#endregion
1223
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/asyncContext/stackStrategy.js
1224
+ /**
1225
+ * This is an object that holds a stack of scopes.
1226
+ */
1227
+ var AsyncContextStack = class {
1228
+ constructor(scope, isolationScope) {
1229
+ let assignedScope;
1230
+ if (!scope) assignedScope = new Scope();
1231
+ else assignedScope = scope;
1232
+ let assignedIsolationScope;
1233
+ if (!isolationScope) assignedIsolationScope = new Scope();
1234
+ else assignedIsolationScope = isolationScope;
1235
+ this._stack = [{ scope: assignedScope }];
1236
+ this._isolationScope = assignedIsolationScope;
1237
+ }
1238
+ /**
1239
+ * Fork a scope for the stack.
1240
+ */
1241
+ withScope(callback) {
1242
+ const scope = this._pushScope();
1243
+ let maybePromiseResult;
1244
+ try {
1245
+ maybePromiseResult = callback(scope);
1246
+ } catch (e) {
1247
+ this._popScope();
1248
+ throw e;
1249
+ }
1250
+ if (isThenable(maybePromiseResult)) return maybePromiseResult.then((res) => {
1251
+ this._popScope();
1252
+ return res;
1253
+ }, (e) => {
1254
+ this._popScope();
1255
+ throw e;
1256
+ });
1257
+ this._popScope();
1258
+ return maybePromiseResult;
1259
+ }
1260
+ /**
1261
+ * Get the client of the stack.
1262
+ */
1263
+ getClient() {
1264
+ return this.getStackTop().client;
1265
+ }
1266
+ /**
1267
+ * Returns the scope of the top stack.
1268
+ */
1269
+ getScope() {
1270
+ return this.getStackTop().scope;
1271
+ }
1272
+ /**
1273
+ * Get the isolation scope for the stack.
1274
+ */
1275
+ getIsolationScope() {
1276
+ return this._isolationScope;
1277
+ }
1278
+ /**
1279
+ * Returns the topmost scope layer in the order domain > local > process.
1280
+ */
1281
+ getStackTop() {
1282
+ return this._stack[this._stack.length - 1];
1283
+ }
1284
+ /**
1285
+ * Push a scope to the stack.
1286
+ */
1287
+ _pushScope() {
1288
+ const scope = this.getScope().clone();
1289
+ this._stack.push({
1290
+ client: this.getClient(),
1291
+ scope
1292
+ });
1293
+ return scope;
1294
+ }
1295
+ /**
1296
+ * Pop a scope from the stack.
1297
+ */
1298
+ _popScope() {
1299
+ if (this._stack.length <= 1) return false;
1300
+ return !!this._stack.pop();
1301
+ }
1302
+ };
1303
+ /**
1304
+ * Get the global async context stack.
1305
+ * This will be removed during the v8 cycle and is only here to make migration easier.
1306
+ */
1307
+ function getAsyncContextStack() {
1308
+ const sentry = getSentryCarrier(getMainCarrier());
1309
+ return sentry.stack = sentry.stack || new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope());
1310
+ }
1311
+ function withScope(callback) {
1312
+ return getAsyncContextStack().withScope(callback);
1313
+ }
1314
+ function withSetScope(scope, callback) {
1315
+ const stack = getAsyncContextStack();
1316
+ return stack.withScope(() => {
1317
+ stack.getStackTop().scope = scope;
1318
+ return callback(scope);
1319
+ });
1320
+ }
1321
+ function withIsolationScope(callback) {
1322
+ return getAsyncContextStack().withScope(() => {
1323
+ return callback(getAsyncContextStack().getIsolationScope());
1324
+ });
1325
+ }
1326
+ /**
1327
+ * Get the stack-based async context strategy.
1328
+ */
1329
+ function getStackAsyncContextStrategy() {
1330
+ return {
1331
+ withIsolationScope,
1332
+ withScope,
1333
+ withSetScope,
1334
+ withSetIsolationScope: (_isolationScope, callback) => {
1335
+ return withIsolationScope(callback);
1336
+ },
1337
+ getCurrentScope: () => getAsyncContextStack().getScope(),
1338
+ getIsolationScope: () => getAsyncContextStack().getIsolationScope()
1339
+ };
1340
+ }
1341
+ //#endregion
1342
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/asyncContext/index.js
1343
+ /**
1344
+ * Get the current async context strategy.
1345
+ * If none has been setup, the default will be used.
1346
+ */
1347
+ function getAsyncContextStrategy(carrier) {
1348
+ const sentry = getSentryCarrier(carrier);
1349
+ if (sentry.acs) return sentry.acs;
1350
+ return getStackAsyncContextStrategy();
1351
+ }
1352
+ //#endregion
1353
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/currentScopes.js
1354
+ /**
1355
+ * Get the currently active scope.
1356
+ */
1357
+ function getCurrentScope() {
1358
+ return getAsyncContextStrategy(getMainCarrier()).getCurrentScope();
1359
+ }
1360
+ /**
1361
+ * Get the currently active isolation scope.
1362
+ * The isolation scope is active for the current execution context.
1363
+ */
1364
+ function getIsolationScope() {
1365
+ return getAsyncContextStrategy(getMainCarrier()).getIsolationScope();
1366
+ }
1367
+ /**
1368
+ * Get the global scope.
1369
+ * This scope is applied to _all_ events.
1370
+ */
1371
+ function getGlobalScope() {
1372
+ return getGlobalSingleton("globalScope", () => new Scope());
1373
+ }
1374
+ /**
1375
+ * Get the currently active client.
1376
+ */
1377
+ function getClient() {
1378
+ return getCurrentScope().getClient();
1379
+ }
1380
+ /**
1381
+ * Get a trace context for the given scope.
1382
+ */
1383
+ function getTraceContextFromScope(scope) {
1384
+ const { traceId, parentSpanId, propagationSpanId } = scope.getPropagationContext();
1385
+ const traceContext = {
1386
+ trace_id: traceId,
1387
+ span_id: propagationSpanId || generateSpanId()
1388
+ };
1389
+ if (parentSpanId) traceContext.parent_span_id = parentSpanId;
1390
+ return traceContext;
1391
+ }
1392
+ //#endregion
1393
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/semanticAttributes.js
1394
+ /**
1395
+ * Use this attribute to represent the source of a span.
1396
+ * Should be one of: custom, url, route, view, component, task, unknown
1397
+ *
1398
+ */
1399
+ const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = "sentry.source";
1400
+ /**
1401
+ * Use this attribute to represent the operation of a span.
1402
+ */
1403
+ const SEMANTIC_ATTRIBUTE_SENTRY_OP = "sentry.op";
1404
+ /**
1405
+ * Use this attribute to represent the origin of a span.
1406
+ */
1407
+ const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = "sentry.origin";
1408
+ /**
1409
+ * The id of the profile that this span occurred in.
1410
+ */
1411
+ const SEMANTIC_ATTRIBUTE_PROFILE_ID = "sentry.profile_id";
1412
+ const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = "sentry.exclusive_time";
1413
+ //#endregion
1414
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/tracing/utils.js
1415
+ const SCOPE_ON_START_SPAN_FIELD = "_sentryScope";
1416
+ const ISOLATION_SCOPE_ON_START_SPAN_FIELD = "_sentryIsolationScope";
1417
+ /**
1418
+ * Grabs the scope and isolation scope off a span that were active when the span was started.
1419
+ */
1420
+ function getCapturedScopesOnSpan(span) {
1421
+ return {
1422
+ scope: span[SCOPE_ON_START_SPAN_FIELD],
1423
+ isolationScope: span[ISOLATION_SCOPE_ON_START_SPAN_FIELD]
1424
+ };
1425
+ }
1426
+ //#endregion
1427
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/baggage.js
1428
+ const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;
1429
+ /**
1430
+ * Takes a baggage header and turns it into Dynamic Sampling Context, by extracting all the "sentry-" prefixed values
1431
+ * from it.
1432
+ *
1433
+ * @param baggageHeader A very bread definition of a baggage header as it might appear in various frameworks.
1434
+ * @returns The Dynamic Sampling Context that was found on `baggageHeader`, if there was any, `undefined` otherwise.
1435
+ */
1436
+ function baggageHeaderToDynamicSamplingContext(baggageHeader) {
1437
+ const baggageObject = parseBaggageHeader(baggageHeader);
1438
+ if (!baggageObject) return;
1439
+ const dynamicSamplingContext = Object.entries(baggageObject).reduce((acc, [key, value]) => {
1440
+ if (key.match(SENTRY_BAGGAGE_KEY_PREFIX_REGEX)) {
1441
+ const nonPrefixedKey = key.slice(7);
1442
+ acc[nonPrefixedKey] = value;
1443
+ }
1444
+ return acc;
1445
+ }, {});
1446
+ if (Object.keys(dynamicSamplingContext).length > 0) return dynamicSamplingContext;
1447
+ else return;
1448
+ }
1449
+ /**
1450
+ * Take a baggage header and parse it into an object.
1451
+ */
1452
+ function parseBaggageHeader(baggageHeader) {
1453
+ if (!baggageHeader || !isString(baggageHeader) && !Array.isArray(baggageHeader)) return;
1454
+ if (Array.isArray(baggageHeader)) return baggageHeader.reduce((acc, curr) => {
1455
+ const currBaggageObject = baggageHeaderToObject(curr);
1456
+ Object.entries(currBaggageObject).forEach(([key, value]) => {
1457
+ acc[key] = value;
1458
+ });
1459
+ return acc;
1460
+ }, {});
1461
+ return baggageHeaderToObject(baggageHeader);
1462
+ }
1463
+ /**
1464
+ * Will parse a baggage header, which is a simple key-value map, into a flat object.
1465
+ *
1466
+ * @param baggageHeader The baggage header to parse.
1467
+ * @returns a flat object containing all the key-value pairs from `baggageHeader`.
1468
+ */
1469
+ function baggageHeaderToObject(baggageHeader) {
1470
+ return baggageHeader.split(",").map((baggageEntry) => baggageEntry.split("=").map((keyOrValue) => {
1471
+ try {
1472
+ return decodeURIComponent(keyOrValue.trim());
1473
+ } catch {
1474
+ return;
1475
+ }
1476
+ })).reduce((acc, [key, value]) => {
1477
+ if (key && value) acc[key] = value;
1478
+ return acc;
1479
+ }, {});
1480
+ }
1481
+ //#endregion
1482
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/parseSampleRate.js
1483
+ /**
1484
+ * Parse a sample rate from a given value.
1485
+ * This will either return a boolean or number sample rate, if the sample rate is valid (between 0 and 1).
1486
+ * If a string is passed, we try to convert it to a number.
1487
+ *
1488
+ * Any invalid sample rate will return `undefined`.
1489
+ */
1490
+ function parseSampleRate(sampleRate) {
1491
+ if (typeof sampleRate === "boolean") return Number(sampleRate);
1492
+ const rate = typeof sampleRate === "string" ? parseFloat(sampleRate) : sampleRate;
1493
+ if (typeof rate !== "number" || isNaN(rate) || rate < 0 || rate > 1) return;
1494
+ return rate;
1495
+ }
1496
+ let hasShownSpanDropWarning = false;
1497
+ /**
1498
+ * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.
1499
+ */
1500
+ function spanToTraceContext(span) {
1501
+ const { spanId, traceId: trace_id, isRemote } = span.spanContext();
1502
+ const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;
1503
+ const scope = getCapturedScopesOnSpan(span).scope;
1504
+ return {
1505
+ parent_span_id,
1506
+ span_id: isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId,
1507
+ trace_id
1508
+ };
1509
+ }
1510
+ /**
1511
+ * Converts the span links array to a flattened version to be sent within an envelope.
1512
+ *
1513
+ * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.
1514
+ */
1515
+ function convertSpanLinksForEnvelope(links) {
1516
+ if (links && links.length > 0) return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({
1517
+ span_id: spanId,
1518
+ trace_id: traceId,
1519
+ sampled: traceFlags === 1,
1520
+ attributes,
1521
+ ...restContext
1522
+ }));
1523
+ else return;
1524
+ }
1525
+ /**
1526
+ * Convert a span time input into a timestamp in seconds.
1527
+ */
1528
+ function spanTimeInputToSeconds(input) {
1529
+ if (typeof input === "number") return ensureTimestampInSeconds(input);
1530
+ if (Array.isArray(input)) return input[0] + input[1] / 1e9;
1531
+ if (input instanceof Date) return ensureTimestampInSeconds(input.getTime());
1532
+ return timestampInSeconds();
1533
+ }
1534
+ /**
1535
+ * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.
1536
+ */
1537
+ function ensureTimestampInSeconds(timestamp) {
1538
+ return timestamp > 9999999999 ? timestamp / 1e3 : timestamp;
1539
+ }
1540
+ /**
1541
+ * Convert a span to a JSON representation.
1542
+ */
1543
+ function spanToJSON(span) {
1544
+ if (spanIsSentrySpan(span)) return span.getSpanJSON();
1545
+ const { spanId: span_id, traceId: trace_id } = span.spanContext();
1546
+ if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
1547
+ const { attributes, startTime, name, endTime, status, links } = span;
1548
+ return {
1549
+ span_id,
1550
+ trace_id,
1551
+ data: attributes,
1552
+ description: name,
1553
+ parent_span_id: "parentSpanId" in span ? span.parentSpanId : "parentSpanContext" in span ? span.parentSpanContext?.spanId : void 0,
1554
+ start_timestamp: spanTimeInputToSeconds(startTime),
1555
+ timestamp: spanTimeInputToSeconds(endTime) || void 0,
1556
+ status: getStatusMessage(status),
1557
+ op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
1558
+ origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN],
1559
+ links: convertSpanLinksForEnvelope(links)
1560
+ };
1561
+ }
1562
+ return {
1563
+ span_id,
1564
+ trace_id,
1565
+ start_timestamp: 0,
1566
+ data: {}
1567
+ };
1568
+ }
1569
+ function spanIsOpenTelemetrySdkTraceBaseSpan(span) {
1570
+ const castSpan = span;
1571
+ return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;
1572
+ }
1573
+ /** Exported only for tests. */
1574
+ /**
1575
+ * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.
1576
+ * :( So instead we approximate this by checking if it has the `getSpanJSON` method.
1577
+ */
1578
+ function spanIsSentrySpan(span) {
1579
+ return typeof span.getSpanJSON === "function";
1580
+ }
1581
+ /**
1582
+ * Returns true if a span is sampled.
1583
+ * In most cases, you should just use `span.isRecording()` instead.
1584
+ * However, this has a slightly different semantic, as it also returns false if the span is finished.
1585
+ * So in the case where this distinction is important, use this method.
1586
+ */
1587
+ function spanIsSampled(span) {
1588
+ const { traceFlags } = span.spanContext();
1589
+ return traceFlags === 1;
1590
+ }
1591
+ /** Get the status message to use for a JSON representation of a span. */
1592
+ function getStatusMessage(status) {
1593
+ if (!status || status.code === 0) return;
1594
+ if (status.code === 1) return "ok";
1595
+ return status.message || "unknown_error";
1596
+ }
1597
+ const ROOT_SPAN_FIELD = "_sentryRootSpan";
1598
+ /**
1599
+ * Returns the root span of a given span.
1600
+ */
1601
+ function getRootSpan(span) {
1602
+ return span[ROOT_SPAN_FIELD] || span;
1603
+ }
1604
+ /**
1605
+ * Logs a warning once if `beforeSendSpan` is used to drop spans.
1606
+ */
1607
+ function showSpanDropWarning() {
1608
+ if (!hasShownSpanDropWarning) {
1609
+ consoleSandbox(() => {
1610
+ console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.");
1611
+ });
1612
+ hasShownSpanDropWarning = true;
1613
+ }
1614
+ }
1615
+ //#endregion
1616
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/hasSpansEnabled.js
1617
+ /**
1618
+ * Determines if span recording is currently enabled.
1619
+ *
1620
+ * Spans are recorded when at least one of `tracesSampleRate` and `tracesSampler`
1621
+ * is defined in the SDK config. This function does not make any assumption about
1622
+ * sampling decisions, it only checks if the SDK is configured to record spans.
1623
+ *
1624
+ * Important: This function only determines if span recording is enabled. Trace
1625
+ * continuation and propagation is separately controlled and not covered by this function.
1626
+ * If this function returns `false`, traces can still be propagated (which is what
1627
+ * we refer to by "Tracing without Performance")
1628
+ * @see https://develop.sentry.dev/sdk/telemetry/traces/tracing-without-performance/
1629
+ *
1630
+ * @param maybeOptions An SDK options object to be passed to this function.
1631
+ * If this option is not provided, the function will use the current client's options.
1632
+ */
1633
+ function hasSpansEnabled(maybeOptions) {
1634
+ if (typeof __SENTRY_TRACING__ === "boolean" && !__SENTRY_TRACING__) return false;
1635
+ const options = maybeOptions || getClient()?.getOptions();
1636
+ return !!options && (options.tracesSampleRate != null || !!options.tracesSampler);
1637
+ }
1638
+ //#endregion
1639
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/constants.js
1640
+ const DEFAULT_ENVIRONMENT = "production";
1641
+ //#endregion
1642
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/dsn.js
1643
+ /** Regular expression used to extract org ID from a DSN host. */
1644
+ const ORG_ID_REGEX = /^o(\d+)\./;
1645
+ /** Regular expression used to parse a Dsn. */
1646
+ const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;
1647
+ function isValidProtocol(protocol) {
1648
+ return protocol === "http" || protocol === "https";
1649
+ }
1650
+ /**
1651
+ * Renders the string representation of this Dsn.
1652
+ *
1653
+ * By default, this will render the public representation without the password
1654
+ * component. To get the deprecated private representation, set `withPassword`
1655
+ * to true.
1656
+ *
1657
+ * @param withPassword When set to true, the password will be included.
1658
+ */
1659
+ function dsnToString(dsn, withPassword = false) {
1660
+ const { host, path, pass, port, projectId, protocol, publicKey } = dsn;
1661
+ return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path ? `${path}/` : path}${projectId}`;
1662
+ }
1663
+ /**
1664
+ * Parses a Dsn from a given string.
1665
+ *
1666
+ * @param str A Dsn as string
1667
+ * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string
1668
+ */
1669
+ function dsnFromString(str) {
1670
+ const match = DSN_REGEX.exec(str);
1671
+ if (!match) {
1672
+ consoleSandbox(() => {
1673
+ console.error(`Invalid Sentry Dsn: ${str}`);
1674
+ });
1675
+ return;
1676
+ }
1677
+ const [protocol, publicKey, pass = "", host = "", port = "", lastPath = ""] = match.slice(1);
1678
+ let path = "";
1679
+ let projectId = lastPath;
1680
+ const split = projectId.split("/");
1681
+ if (split.length > 1) {
1682
+ path = split.slice(0, -1).join("/");
1683
+ projectId = split.pop();
1684
+ }
1685
+ if (projectId) {
1686
+ const projectMatch = projectId.match(/^\d+/);
1687
+ if (projectMatch) projectId = projectMatch[0];
1688
+ }
1689
+ return dsnFromComponents({
1690
+ host,
1691
+ pass,
1692
+ path,
1693
+ projectId,
1694
+ port,
1695
+ protocol,
1696
+ publicKey
1697
+ });
1698
+ }
1699
+ function dsnFromComponents(components) {
1700
+ return {
1701
+ protocol: components.protocol,
1702
+ publicKey: components.publicKey || "",
1703
+ pass: components.pass || "",
1704
+ host: components.host,
1705
+ port: components.port || "",
1706
+ path: components.path || "",
1707
+ projectId: components.projectId
1708
+ };
1709
+ }
1710
+ function validateDsn(dsn) {
1711
+ if (!DEBUG_BUILD$1) return true;
1712
+ const { port, projectId, protocol } = dsn;
1713
+ if ([
1714
+ "protocol",
1715
+ "publicKey",
1716
+ "host",
1717
+ "projectId"
1718
+ ].find((component) => {
1719
+ if (!dsn[component]) {
1720
+ debug.error(`Invalid Sentry Dsn: ${component} missing`);
1721
+ return true;
1722
+ }
1723
+ return false;
1724
+ })) return false;
1725
+ if (!projectId.match(/^\d+$/)) {
1726
+ debug.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
1727
+ return false;
1728
+ }
1729
+ if (!isValidProtocol(protocol)) {
1730
+ debug.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
1731
+ return false;
1732
+ }
1733
+ if (port && isNaN(parseInt(port, 10))) {
1734
+ debug.error(`Invalid Sentry Dsn: Invalid port ${port}`);
1735
+ return false;
1736
+ }
1737
+ return true;
1738
+ }
1739
+ /**
1740
+ * Extract the org ID from a DSN host.
1741
+ *
1742
+ * @param host The host from a DSN
1743
+ * @returns The org ID if found, undefined otherwise
1744
+ */
1745
+ function extractOrgIdFromDsnHost(host) {
1746
+ return host.match(ORG_ID_REGEX)?.[1];
1747
+ }
1748
+ /**
1749
+ * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.
1750
+ * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source
1751
+ */
1752
+ function makeDsn(from) {
1753
+ const components = typeof from === "string" ? dsnFromString(from) : dsnFromComponents(from);
1754
+ if (!components || !validateDsn(components)) return;
1755
+ return components;
1756
+ }
1757
+ //#endregion
1758
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/tracing/dynamicSamplingContext.js
1759
+ /**
1760
+ * If you change this value, also update the terser plugin config to
1761
+ * avoid minification of the object property!
1762
+ */
1763
+ const FROZEN_DSC_FIELD = "_frozenDsc";
1764
+ /**
1765
+ * Creates a dynamic sampling context from a client.
1766
+ *
1767
+ * Dispatches the `createDsc` lifecycle hook as a side effect.
1768
+ */
1769
+ function getDynamicSamplingContextFromClient(trace_id, client) {
1770
+ const options = client.getOptions();
1771
+ const { publicKey: public_key, host } = client.getDsn() || {};
1772
+ let org_id;
1773
+ if (options.orgId) org_id = String(options.orgId);
1774
+ else if (host) org_id = extractOrgIdFromDsnHost(host);
1775
+ const dsc = {
1776
+ environment: options.environment || "production",
1777
+ release: options.release,
1778
+ public_key,
1779
+ trace_id,
1780
+ org_id
1781
+ };
1782
+ client.emit("createDsc", dsc);
1783
+ return dsc;
1784
+ }
1785
+ /**
1786
+ * Get the dynamic sampling context for the currently active scopes.
1787
+ */
1788
+ function getDynamicSamplingContextFromScope(client, scope) {
1789
+ const propagationContext = scope.getPropagationContext();
1790
+ return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);
1791
+ }
1792
+ /**
1793
+ * Creates a dynamic sampling context from a span (and client and scope)
1794
+ *
1795
+ * @param span the span from which a few values like the root span name and sample rate are extracted.
1796
+ *
1797
+ * @returns a dynamic sampling context
1798
+ */
1799
+ function getDynamicSamplingContextFromSpan(span) {
1800
+ const client = getClient();
1801
+ if (!client) return {};
1802
+ const rootSpan = getRootSpan(span);
1803
+ const rootSpanJson = spanToJSON(rootSpan);
1804
+ const rootSpanAttributes = rootSpanJson.data;
1805
+ const traceState = rootSpan.spanContext().traceState;
1806
+ const rootSpanSampleRate = traceState?.get("sentry.sample_rate") ?? rootSpanAttributes["sentry.sample_rate"] ?? rootSpanAttributes["sentry.previous_trace_sample_rate"];
1807
+ function applyLocalSampleRateToDsc(dsc) {
1808
+ if (typeof rootSpanSampleRate === "number" || typeof rootSpanSampleRate === "string") dsc.sample_rate = `${rootSpanSampleRate}`;
1809
+ return dsc;
1810
+ }
1811
+ const frozenDsc = rootSpan[FROZEN_DSC_FIELD];
1812
+ if (frozenDsc) return applyLocalSampleRateToDsc(frozenDsc);
1813
+ const traceStateDsc = traceState?.get("sentry.dsc");
1814
+ const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);
1815
+ if (dscOnTraceState) return applyLocalSampleRateToDsc(dscOnTraceState);
1816
+ const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
1817
+ const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
1818
+ const name = rootSpanJson.description;
1819
+ if (source !== "url" && name) dsc.transaction = name;
1820
+ if (hasSpansEnabled()) {
1821
+ dsc.sampled = String(spanIsSampled(rootSpan));
1822
+ dsc.sample_rand = traceState?.get("sentry.sample_rand") ?? getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();
1823
+ }
1824
+ applyLocalSampleRateToDsc(dsc);
1825
+ client.emit("createDsc", dsc, rootSpan);
1826
+ return dsc;
1827
+ }
1828
+ //#endregion
1829
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/normalize.js
1830
+ /**
1831
+ * Recursively normalizes the given object.
1832
+ *
1833
+ * - Creates a copy to prevent original input mutation
1834
+ * - Skips non-enumerable properties
1835
+ * - When stringifying, calls `toJSON` if implemented
1836
+ * - Removes circular references
1837
+ * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
1838
+ * - Translates known global objects/classes to a string representations
1839
+ * - Takes care of `Error` object serialization
1840
+ * - Optionally limits depth of final output
1841
+ * - Optionally limits number of properties/elements included in any single object/array
1842
+ *
1843
+ * @param input The object to be normalized.
1844
+ * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
1845
+ * @param maxProperties The max number of elements or properties to be included in any single array or
1846
+ * object in the normalized output.
1847
+ * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
1848
+ */
1849
+ function normalize(input, depth = 100, maxProperties = Infinity) {
1850
+ try {
1851
+ return visit("", input, depth, maxProperties);
1852
+ } catch (err) {
1853
+ return { ERROR: `**non-serializable** (${err})` };
1854
+ }
1855
+ }
1856
+ /** JSDoc */
1857
+ function normalizeToSize(object, depth = 3, maxSize = 102400) {
1858
+ const normalized = normalize(object, depth);
1859
+ if (jsonSize(normalized) > maxSize) return normalizeToSize(object, depth - 1, maxSize);
1860
+ return normalized;
1861
+ }
1862
+ /**
1863
+ * Visits a node to perform normalization on it
1864
+ *
1865
+ * @param key The key corresponding to the given node
1866
+ * @param value The node to be visited
1867
+ * @param depth Optional number indicating the maximum recursion depth
1868
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
1869
+ * @param memo Optional Memo class handling decycling
1870
+ */
1871
+ function visit(key, value, depth = Infinity, maxProperties = Infinity, memo = memoBuilder()) {
1872
+ const [memoize, unmemoize] = memo;
1873
+ if (value == null || ["boolean", "string"].includes(typeof value) || typeof value === "number" && Number.isFinite(value)) return value;
1874
+ const stringified = stringifyValue(key, value);
1875
+ if (!stringified.startsWith("[object ")) return stringified;
1876
+ if (value["__sentry_skip_normalization__"]) return value;
1877
+ const remainingDepth = typeof value["__sentry_override_normalization_depth__"] === "number" ? value["__sentry_override_normalization_depth__"] : depth;
1878
+ if (remainingDepth === 0) return stringified.replace("object ", "");
1879
+ if (memoize(value)) return "[Circular ~]";
1880
+ const valueWithToJSON = value;
1881
+ if (valueWithToJSON && typeof valueWithToJSON.toJSON === "function") try {
1882
+ return visit("", valueWithToJSON.toJSON(), remainingDepth - 1, maxProperties, memo);
1883
+ } catch {}
1884
+ const normalized = Array.isArray(value) ? [] : {};
1885
+ let numAdded = 0;
1886
+ const visitable = convertToPlainObject(value);
1887
+ for (const visitKey in visitable) {
1888
+ if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) continue;
1889
+ if (numAdded >= maxProperties) {
1890
+ normalized[visitKey] = "[MaxProperties ~]";
1891
+ break;
1892
+ }
1893
+ const visitValue = visitable[visitKey];
1894
+ normalized[visitKey] = visit(visitKey, visitValue, remainingDepth - 1, maxProperties, memo);
1895
+ numAdded++;
1896
+ }
1897
+ unmemoize(value);
1898
+ return normalized;
1899
+ }
1900
+ /**
1901
+ * Stringify the given value. Handles various known special values and types.
1902
+ *
1903
+ * Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn
1904
+ * the number 1231 into "[Object Number]", nor on `null`, as it will throw.
1905
+ *
1906
+ * @param value The value to stringify
1907
+ * @returns A stringified representation of the given value
1908
+ */
1909
+ function stringifyValue(key, value) {
1910
+ try {
1911
+ if (key === "domain" && value && typeof value === "object" && value._events) return "[Domain]";
1912
+ if (key === "domainEmitter") return "[DomainEmitter]";
1913
+ if (typeof global !== "undefined" && value === global) return "[Global]";
1914
+ if (typeof window !== "undefined" && value === window) return "[Window]";
1915
+ if (typeof document !== "undefined" && value === document) return "[Document]";
1916
+ if (isVueViewModel(value)) return "[VueViewModel]";
1917
+ if (isSyntheticEvent(value)) return "[SyntheticEvent]";
1918
+ if (typeof value === "number" && !Number.isFinite(value)) return `[${value}]`;
1919
+ if (typeof value === "function") return `[Function: ${getFunctionName(value)}]`;
1920
+ if (typeof value === "symbol") return `[${String(value)}]`;
1921
+ if (typeof value === "bigint") return `[BigInt: ${String(value)}]`;
1922
+ const objName = getConstructorName(value);
1923
+ if (/^HTML(\w*)Element$/.test(objName)) return `[HTMLElement: ${objName}]`;
1924
+ return `[object ${objName}]`;
1925
+ } catch (err) {
1926
+ return `**non-serializable** (${err})`;
1927
+ }
1928
+ }
1929
+ function getConstructorName(value) {
1930
+ const prototype = Object.getPrototypeOf(value);
1931
+ return prototype?.constructor ? prototype.constructor.name : "null prototype";
1932
+ }
1933
+ /** Calculates bytes size of input string */
1934
+ function utf8Length(value) {
1935
+ return ~-encodeURI(value).split(/%..|./).length;
1936
+ }
1937
+ /** Calculates bytes size of input object */
1938
+ function jsonSize(value) {
1939
+ return utf8Length(JSON.stringify(value));
1940
+ }
1941
+ /**
1942
+ * Helper to decycle json objects
1943
+ */
1944
+ function memoBuilder() {
1945
+ const inner = /* @__PURE__ */ new WeakSet();
1946
+ function memoize(obj) {
1947
+ if (inner.has(obj)) return true;
1948
+ inner.add(obj);
1949
+ return false;
1950
+ }
1951
+ function unmemoize(obj) {
1952
+ inner.delete(obj);
1953
+ }
1954
+ return [memoize, unmemoize];
1955
+ }
1956
+ //#endregion
1957
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/envelope.js
1958
+ /**
1959
+ * Creates an envelope.
1960
+ * Make sure to always explicitly provide the generic to this function
1961
+ * so that the envelope types resolve correctly.
1962
+ */
1963
+ function createEnvelope(headers, items = []) {
1964
+ return [headers, items];
1965
+ }
1966
+ /**
1967
+ * Add an item to an envelope.
1968
+ * Make sure to always explicitly provide the generic to this function
1969
+ * so that the envelope types resolve correctly.
1970
+ */
1971
+ function addItemToEnvelope(envelope, newItem) {
1972
+ const [headers, items] = envelope;
1973
+ return [headers, [...items, newItem]];
1974
+ }
1975
+ /**
1976
+ * Convenience function to loop through the items and item types of an envelope.
1977
+ * (This function was mostly created because working with envelope types is painful at the moment)
1978
+ *
1979
+ * If the callback returns true, the rest of the items will be skipped.
1980
+ */
1981
+ function forEachEnvelopeItem(envelope, callback) {
1982
+ const envelopeItems = envelope[1];
1983
+ for (const envelopeItem of envelopeItems) {
1984
+ const envelopeItemType = envelopeItem[0].type;
1985
+ if (callback(envelopeItem, envelopeItemType)) return true;
1986
+ }
1987
+ return false;
1988
+ }
1989
+ /**
1990
+ * Encode a string to UTF8 array.
1991
+ */
1992
+ function encodeUTF8(input) {
1993
+ const carrier = getSentryCarrier(GLOBAL_OBJ);
1994
+ return carrier.encodePolyfill ? carrier.encodePolyfill(input) : new TextEncoder().encode(input);
1995
+ }
1996
+ /**
1997
+ * Serializes an envelope.
1998
+ */
1999
+ function serializeEnvelope(envelope) {
2000
+ const [envHeaders, items] = envelope;
2001
+ let parts = JSON.stringify(envHeaders);
2002
+ function append(next) {
2003
+ if (typeof parts === "string") parts = typeof next === "string" ? parts + next : [encodeUTF8(parts), next];
2004
+ else parts.push(typeof next === "string" ? encodeUTF8(next) : next);
2005
+ }
2006
+ for (const item of items) {
2007
+ const [itemHeaders, payload] = item;
2008
+ append(`\n${JSON.stringify(itemHeaders)}\n`);
2009
+ if (typeof payload === "string" || payload instanceof Uint8Array) append(payload);
2010
+ else {
2011
+ let stringifiedPayload;
2012
+ try {
2013
+ stringifiedPayload = JSON.stringify(payload);
2014
+ } catch {
2015
+ stringifiedPayload = JSON.stringify(normalize(payload));
2016
+ }
2017
+ append(stringifiedPayload);
2018
+ }
2019
+ }
2020
+ return typeof parts === "string" ? parts : concatBuffers(parts);
2021
+ }
2022
+ function concatBuffers(buffers) {
2023
+ const totalLength = buffers.reduce((acc, buf) => acc + buf.length, 0);
2024
+ const merged = new Uint8Array(totalLength);
2025
+ let offset = 0;
2026
+ for (const buffer of buffers) {
2027
+ merged.set(buffer, offset);
2028
+ offset += buffer.length;
2029
+ }
2030
+ return merged;
2031
+ }
2032
+ /**
2033
+ * Creates attachment envelope items
2034
+ */
2035
+ function createAttachmentEnvelopeItem(attachment) {
2036
+ const buffer = typeof attachment.data === "string" ? encodeUTF8(attachment.data) : attachment.data;
2037
+ return [{
2038
+ type: "attachment",
2039
+ length: buffer.length,
2040
+ filename: attachment.filename,
2041
+ content_type: attachment.contentType,
2042
+ attachment_type: attachment.attachmentType
2043
+ }, buffer];
2044
+ }
2045
+ const ITEM_TYPE_TO_DATA_CATEGORY_MAP = {
2046
+ session: "session",
2047
+ sessions: "session",
2048
+ attachment: "attachment",
2049
+ transaction: "transaction",
2050
+ event: "error",
2051
+ client_report: "internal",
2052
+ user_report: "default",
2053
+ profile: "profile",
2054
+ profile_chunk: "profile",
2055
+ replay_event: "replay",
2056
+ replay_recording: "replay",
2057
+ check_in: "monitor",
2058
+ feedback: "feedback",
2059
+ span: "span",
2060
+ raw_security: "security",
2061
+ log: "log_item"
2062
+ };
2063
+ /**
2064
+ * Maps the type of an envelope item to a data category.
2065
+ */
2066
+ function envelopeItemTypeToDataCategory(type) {
2067
+ return ITEM_TYPE_TO_DATA_CATEGORY_MAP[type];
2068
+ }
2069
+ /** Extracts the minimal SDK info from the metadata or an events */
2070
+ function getSdkMetadataForEnvelopeHeader(metadataOrEvent) {
2071
+ if (!metadataOrEvent?.sdk) return;
2072
+ const { name, version } = metadataOrEvent.sdk;
2073
+ return {
2074
+ name,
2075
+ version
2076
+ };
2077
+ }
2078
+ /**
2079
+ * Creates event envelope headers, based on event, sdk info and tunnel
2080
+ * Note: This function was extracted from the core package to make it available in Replay
2081
+ */
2082
+ function createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn) {
2083
+ const dynamicSamplingContext = event.sdkProcessingMetadata?.dynamicSamplingContext;
2084
+ return {
2085
+ event_id: event.event_id,
2086
+ sent_at: (/* @__PURE__ */ new Date()).toISOString(),
2087
+ ...sdkInfo && { sdk: sdkInfo },
2088
+ ...!!tunnel && dsn && { dsn: dsnToString(dsn) },
2089
+ ...dynamicSamplingContext && { trace: dynamicSamplingContext }
2090
+ };
2091
+ }
2092
+ //#endregion
2093
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/envelope.js
2094
+ /**
2095
+ * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key.
2096
+ * Merge with existing data if any.
2097
+ **/
2098
+ function enhanceEventWithSdkInfo(event, sdkInfo) {
2099
+ if (!sdkInfo) return event;
2100
+ event.sdk = event.sdk || {};
2101
+ event.sdk.name = event.sdk.name || sdkInfo.name;
2102
+ event.sdk.version = event.sdk.version || sdkInfo.version;
2103
+ event.sdk.integrations = [...event.sdk.integrations || [], ...sdkInfo.integrations || []];
2104
+ event.sdk.packages = [...event.sdk.packages || [], ...sdkInfo.packages || []];
2105
+ return event;
2106
+ }
2107
+ /** Creates an envelope from a Session */
2108
+ function createSessionEnvelope(session, dsn, metadata, tunnel) {
2109
+ const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
2110
+ return createEnvelope({
2111
+ sent_at: (/* @__PURE__ */ new Date()).toISOString(),
2112
+ ...sdkInfo && { sdk: sdkInfo },
2113
+ ...!!tunnel && dsn && { dsn: dsnToString(dsn) }
2114
+ }, ["aggregates" in session ? [{ type: "sessions" }, session] : [{ type: "session" }, session.toJSON()]]);
2115
+ }
2116
+ /**
2117
+ * Create an Envelope from an event.
2118
+ */
2119
+ function createEventEnvelope(event, dsn, metadata, tunnel) {
2120
+ const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
2121
+ const eventType = event.type && event.type !== "replay_event" ? event.type : "event";
2122
+ enhanceEventWithSdkInfo(event, metadata?.sdk);
2123
+ const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);
2124
+ delete event.sdkProcessingMetadata;
2125
+ return createEnvelope(envelopeHeaders, [[{ type: eventType }, event]]);
2126
+ }
2127
+ //#endregion
2128
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/syncpromise.js
2129
+ /** SyncPromise internal states */
2130
+ const STATE_PENDING = 0;
2131
+ const STATE_RESOLVED = 1;
2132
+ const STATE_REJECTED = 2;
2133
+ /**
2134
+ * Creates a resolved sync promise.
2135
+ *
2136
+ * @param value the value to resolve the promise with
2137
+ * @returns the resolved sync promise
2138
+ */
2139
+ function resolvedSyncPromise(value) {
2140
+ return new SyncPromise((resolve) => {
2141
+ resolve(value);
2142
+ });
2143
+ }
2144
+ /**
2145
+ * Creates a rejected sync promise.
2146
+ *
2147
+ * @param value the value to reject the promise with
2148
+ * @returns the rejected sync promise
2149
+ */
2150
+ function rejectedSyncPromise(reason) {
2151
+ return new SyncPromise((_, reject) => {
2152
+ reject(reason);
2153
+ });
2154
+ }
2155
+ /**
2156
+ * Thenable class that behaves like a Promise and follows it's interface
2157
+ * but is not async internally
2158
+ */
2159
+ var SyncPromise = class SyncPromise {
2160
+ constructor(executor) {
2161
+ this._state = STATE_PENDING;
2162
+ this._handlers = [];
2163
+ this._runExecutor(executor);
2164
+ }
2165
+ /** @inheritdoc */
2166
+ then(onfulfilled, onrejected) {
2167
+ return new SyncPromise((resolve, reject) => {
2168
+ this._handlers.push([
2169
+ false,
2170
+ (result) => {
2171
+ if (!onfulfilled) resolve(result);
2172
+ else try {
2173
+ resolve(onfulfilled(result));
2174
+ } catch (e) {
2175
+ reject(e);
2176
+ }
2177
+ },
2178
+ (reason) => {
2179
+ if (!onrejected) reject(reason);
2180
+ else try {
2181
+ resolve(onrejected(reason));
2182
+ } catch (e) {
2183
+ reject(e);
2184
+ }
2185
+ }
2186
+ ]);
2187
+ this._executeHandlers();
2188
+ });
2189
+ }
2190
+ /** @inheritdoc */
2191
+ catch(onrejected) {
2192
+ return this.then((val) => val, onrejected);
2193
+ }
2194
+ /** @inheritdoc */
2195
+ finally(onfinally) {
2196
+ return new SyncPromise((resolve, reject) => {
2197
+ let val;
2198
+ let isRejected;
2199
+ return this.then((value) => {
2200
+ isRejected = false;
2201
+ val = value;
2202
+ if (onfinally) onfinally();
2203
+ }, (reason) => {
2204
+ isRejected = true;
2205
+ val = reason;
2206
+ if (onfinally) onfinally();
2207
+ }).then(() => {
2208
+ if (isRejected) {
2209
+ reject(val);
2210
+ return;
2211
+ }
2212
+ resolve(val);
2213
+ });
2214
+ });
2215
+ }
2216
+ /** Excute the resolve/reject handlers. */
2217
+ _executeHandlers() {
2218
+ if (this._state === STATE_PENDING) return;
2219
+ const cachedHandlers = this._handlers.slice();
2220
+ this._handlers = [];
2221
+ cachedHandlers.forEach((handler) => {
2222
+ if (handler[0]) return;
2223
+ if (this._state === STATE_RESOLVED) handler[1](this._value);
2224
+ if (this._state === STATE_REJECTED) handler[2](this._value);
2225
+ handler[0] = true;
2226
+ });
2227
+ }
2228
+ /** Run the executor for the SyncPromise. */
2229
+ _runExecutor(executor) {
2230
+ const setResult = (state, value) => {
2231
+ if (this._state !== STATE_PENDING) return;
2232
+ if (isThenable(value)) {
2233
+ value.then(resolve, reject);
2234
+ return;
2235
+ }
2236
+ this._state = state;
2237
+ this._value = value;
2238
+ this._executeHandlers();
2239
+ };
2240
+ const resolve = (value) => {
2241
+ setResult(STATE_RESOLVED, value);
2242
+ };
2243
+ const reject = (reason) => {
2244
+ setResult(STATE_REJECTED, reason);
2245
+ };
2246
+ try {
2247
+ executor(resolve, reject);
2248
+ } catch (e) {
2249
+ reject(e);
2250
+ }
2251
+ }
2252
+ };
2253
+ //#endregion
2254
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/eventProcessors.js
2255
+ /**
2256
+ * Process an array of event processors, returning the processed event (or `null` if the event was dropped).
2257
+ */
2258
+ function notifyEventProcessors(processors, event, hint, index = 0) {
2259
+ return new SyncPromise((resolve, reject) => {
2260
+ const processor = processors[index];
2261
+ if (event === null || typeof processor !== "function") resolve(event);
2262
+ else {
2263
+ const result = processor({ ...event }, hint);
2264
+ DEBUG_BUILD$1 && processor.id && result === null && debug.log(`Event processor "${processor.id}" dropped event`);
2265
+ if (isThenable(result)) result.then((final) => notifyEventProcessors(processors, final, hint, index + 1).then(resolve)).then(null, reject);
2266
+ else notifyEventProcessors(processors, result, hint, index + 1).then(resolve).then(null, reject);
2267
+ }
2268
+ });
2269
+ }
2270
+ //#endregion
2271
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/applyScopeDataToEvent.js
2272
+ /**
2273
+ * Applies data from the scope to the event and runs all event processors on it.
2274
+ */
2275
+ function applyScopeDataToEvent(event, data) {
2276
+ const { fingerprint, span, breadcrumbs, sdkProcessingMetadata } = data;
2277
+ applyDataToEvent(event, data);
2278
+ if (span) applySpanToEvent(event, span);
2279
+ applyFingerprintToEvent(event, fingerprint);
2280
+ applyBreadcrumbsToEvent(event, breadcrumbs);
2281
+ applySdkMetadataToEvent(event, sdkProcessingMetadata);
2282
+ }
2283
+ /** Merge data of two scopes together. */
2284
+ function mergeScopeData(data, mergeData) {
2285
+ const { extra, tags, user, contexts, level, sdkProcessingMetadata, breadcrumbs, fingerprint, eventProcessors, attachments, propagationContext, transactionName, span } = mergeData;
2286
+ mergeAndOverwriteScopeData(data, "extra", extra);
2287
+ mergeAndOverwriteScopeData(data, "tags", tags);
2288
+ mergeAndOverwriteScopeData(data, "user", user);
2289
+ mergeAndOverwriteScopeData(data, "contexts", contexts);
2290
+ data.sdkProcessingMetadata = merge(data.sdkProcessingMetadata, sdkProcessingMetadata, 2);
2291
+ if (level) data.level = level;
2292
+ if (transactionName) data.transactionName = transactionName;
2293
+ if (span) data.span = span;
2294
+ if (breadcrumbs.length) data.breadcrumbs = [...data.breadcrumbs, ...breadcrumbs];
2295
+ if (fingerprint.length) data.fingerprint = [...data.fingerprint, ...fingerprint];
2296
+ if (eventProcessors.length) data.eventProcessors = [...data.eventProcessors, ...eventProcessors];
2297
+ if (attachments.length) data.attachments = [...data.attachments, ...attachments];
2298
+ data.propagationContext = {
2299
+ ...data.propagationContext,
2300
+ ...propagationContext
2301
+ };
2302
+ }
2303
+ /**
2304
+ * Merges certain scope data. Undefined values will overwrite any existing values.
2305
+ * Exported only for tests.
2306
+ */
2307
+ function mergeAndOverwriteScopeData(data, prop, mergeVal) {
2308
+ data[prop] = merge(data[prop], mergeVal, 1);
2309
+ }
2310
+ function applyDataToEvent(event, data) {
2311
+ const { extra, tags, user, contexts, level, transactionName } = data;
2312
+ if (Object.keys(extra).length) event.extra = {
2313
+ ...extra,
2314
+ ...event.extra
2315
+ };
2316
+ if (Object.keys(tags).length) event.tags = {
2317
+ ...tags,
2318
+ ...event.tags
2319
+ };
2320
+ if (Object.keys(user).length) event.user = {
2321
+ ...user,
2322
+ ...event.user
2323
+ };
2324
+ if (Object.keys(contexts).length) event.contexts = {
2325
+ ...contexts,
2326
+ ...event.contexts
2327
+ };
2328
+ if (level) event.level = level;
2329
+ if (transactionName && event.type !== "transaction") event.transaction = transactionName;
2330
+ }
2331
+ function applyBreadcrumbsToEvent(event, breadcrumbs) {
2332
+ const mergedBreadcrumbs = [...event.breadcrumbs || [], ...breadcrumbs];
2333
+ event.breadcrumbs = mergedBreadcrumbs.length ? mergedBreadcrumbs : void 0;
2334
+ }
2335
+ function applySdkMetadataToEvent(event, sdkProcessingMetadata) {
2336
+ event.sdkProcessingMetadata = {
2337
+ ...event.sdkProcessingMetadata,
2338
+ ...sdkProcessingMetadata
2339
+ };
2340
+ }
2341
+ function applySpanToEvent(event, span) {
2342
+ event.contexts = {
2343
+ trace: spanToTraceContext(span),
2344
+ ...event.contexts
2345
+ };
2346
+ event.sdkProcessingMetadata = {
2347
+ dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),
2348
+ ...event.sdkProcessingMetadata
2349
+ };
2350
+ const transactionName = spanToJSON(getRootSpan(span)).description;
2351
+ if (transactionName && !event.transaction && event.type === "transaction") event.transaction = transactionName;
2352
+ }
2353
+ /**
2354
+ * Applies fingerprint from the scope to the event if there's one,
2355
+ * uses message if there's one instead or get rid of empty fingerprint
2356
+ */
2357
+ function applyFingerprintToEvent(event, fingerprint) {
2358
+ event.fingerprint = event.fingerprint ? Array.isArray(event.fingerprint) ? event.fingerprint : [event.fingerprint] : [];
2359
+ if (fingerprint) event.fingerprint = event.fingerprint.concat(fingerprint);
2360
+ if (!event.fingerprint.length) delete event.fingerprint;
2361
+ }
2362
+ //#endregion
2363
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/debug-ids.js
2364
+ let parsedStackResults;
2365
+ let lastKeysCount;
2366
+ let cachedFilenameDebugIds;
2367
+ /**
2368
+ * Returns a map of filenames to debug identifiers.
2369
+ */
2370
+ function getFilenameToDebugIdMap(stackParser) {
2371
+ const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
2372
+ if (!debugIdMap) return {};
2373
+ const debugIdKeys = Object.keys(debugIdMap);
2374
+ if (cachedFilenameDebugIds && debugIdKeys.length === lastKeysCount) return cachedFilenameDebugIds;
2375
+ lastKeysCount = debugIdKeys.length;
2376
+ cachedFilenameDebugIds = debugIdKeys.reduce((acc, stackKey) => {
2377
+ if (!parsedStackResults) parsedStackResults = {};
2378
+ const result = parsedStackResults[stackKey];
2379
+ if (result) acc[result[0]] = result[1];
2380
+ else {
2381
+ const parsedStack = stackParser(stackKey);
2382
+ for (let i = parsedStack.length - 1; i >= 0; i--) {
2383
+ const filename = parsedStack[i]?.filename;
2384
+ const debugId = debugIdMap[stackKey];
2385
+ if (filename && debugId) {
2386
+ acc[filename] = debugId;
2387
+ parsedStackResults[stackKey] = [filename, debugId];
2388
+ break;
2389
+ }
2390
+ }
2391
+ }
2392
+ return acc;
2393
+ }, {});
2394
+ return cachedFilenameDebugIds;
2395
+ }
2396
+ //#endregion
2397
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/prepareEvent.js
2398
+ /**
2399
+ * This type makes sure that we get either a CaptureContext, OR an EventHint.
2400
+ * It does not allow mixing them, which could lead to unexpected outcomes, e.g. this is disallowed:
2401
+ * { user: { id: '123' }, mechanism: { handled: false } }
2402
+ */
2403
+ /**
2404
+ * Adds common information to events.
2405
+ *
2406
+ * The information includes release and environment from `options`,
2407
+ * breadcrumbs and context (extra, tags and user) from the scope.
2408
+ *
2409
+ * Information that is already present in the event is never overwritten. For
2410
+ * nested objects, such as the context, keys are merged.
2411
+ *
2412
+ * @param event The original event.
2413
+ * @param hint May contain additional information about the original exception.
2414
+ * @param scope A scope containing event metadata.
2415
+ * @returns A new event with more information.
2416
+ * @hidden
2417
+ */
2418
+ function prepareEvent(options, event, hint, scope, client, isolationScope) {
2419
+ const { normalizeDepth = 3, normalizeMaxBreadth = 1e3 } = options;
2420
+ const prepared = {
2421
+ ...event,
2422
+ event_id: event.event_id || hint.event_id || uuid4(),
2423
+ timestamp: event.timestamp || dateTimestampInSeconds()
2424
+ };
2425
+ const integrations = hint.integrations || options.integrations.map((i) => i.name);
2426
+ applyClientOptions(prepared, options);
2427
+ applyIntegrationsMetadata(prepared, integrations);
2428
+ if (client) client.emit("applyFrameMetadata", event);
2429
+ if (event.type === void 0) applyDebugIds(prepared, options.stackParser);
2430
+ const finalScope = getFinalScope(scope, hint.captureContext);
2431
+ if (hint.mechanism) addExceptionMechanism(prepared, hint.mechanism);
2432
+ const clientEventProcessors = client ? client.getEventProcessors() : [];
2433
+ const data = getGlobalScope().getScopeData();
2434
+ if (isolationScope) mergeScopeData(data, isolationScope.getScopeData());
2435
+ if (finalScope) mergeScopeData(data, finalScope.getScopeData());
2436
+ const attachments = [...hint.attachments || [], ...data.attachments];
2437
+ if (attachments.length) hint.attachments = attachments;
2438
+ applyScopeDataToEvent(prepared, data);
2439
+ return notifyEventProcessors([...clientEventProcessors, ...data.eventProcessors], prepared, hint).then((evt) => {
2440
+ if (evt) applyDebugMeta(evt);
2441
+ if (typeof normalizeDepth === "number" && normalizeDepth > 0) return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
2442
+ return evt;
2443
+ });
2444
+ }
2445
+ /**
2446
+ * Enhances event using the client configuration.
2447
+ * It takes care of all "static" values like environment, release and `dist`,
2448
+ * as well as truncating overly long values.
2449
+ *
2450
+ * Only exported for tests.
2451
+ *
2452
+ * @param event event instance to be enhanced
2453
+ */
2454
+ function applyClientOptions(event, options) {
2455
+ const { environment, release, dist, maxValueLength = 250 } = options;
2456
+ event.environment = event.environment || environment || "production";
2457
+ if (!event.release && release) event.release = release;
2458
+ if (!event.dist && dist) event.dist = dist;
2459
+ const request = event.request;
2460
+ if (request?.url) request.url = truncate(request.url, maxValueLength);
2461
+ }
2462
+ /**
2463
+ * Puts debug IDs into the stack frames of an error event.
2464
+ */
2465
+ function applyDebugIds(event, stackParser) {
2466
+ const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
2467
+ event.exception?.values?.forEach((exception) => {
2468
+ exception.stacktrace?.frames?.forEach((frame) => {
2469
+ if (frame.filename) frame.debug_id = filenameDebugIdMap[frame.filename];
2470
+ });
2471
+ });
2472
+ }
2473
+ /**
2474
+ * Moves debug IDs from the stack frames of an error event into the debug_meta field.
2475
+ */
2476
+ function applyDebugMeta(event) {
2477
+ const filenameDebugIdMap = {};
2478
+ event.exception?.values?.forEach((exception) => {
2479
+ exception.stacktrace?.frames?.forEach((frame) => {
2480
+ if (frame.debug_id) {
2481
+ if (frame.abs_path) filenameDebugIdMap[frame.abs_path] = frame.debug_id;
2482
+ else if (frame.filename) filenameDebugIdMap[frame.filename] = frame.debug_id;
2483
+ delete frame.debug_id;
2484
+ }
2485
+ });
2486
+ });
2487
+ if (Object.keys(filenameDebugIdMap).length === 0) return;
2488
+ event.debug_meta = event.debug_meta || {};
2489
+ event.debug_meta.images = event.debug_meta.images || [];
2490
+ const images = event.debug_meta.images;
2491
+ Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => {
2492
+ images.push({
2493
+ type: "sourcemap",
2494
+ code_file: filename,
2495
+ debug_id
2496
+ });
2497
+ });
2498
+ }
2499
+ /**
2500
+ * This function adds all used integrations to the SDK info in the event.
2501
+ * @param event The event that will be filled with all integrations.
2502
+ */
2503
+ function applyIntegrationsMetadata(event, integrationNames) {
2504
+ if (integrationNames.length > 0) {
2505
+ event.sdk = event.sdk || {};
2506
+ event.sdk.integrations = [...event.sdk.integrations || [], ...integrationNames];
2507
+ }
2508
+ }
2509
+ /**
2510
+ * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.
2511
+ * Normalized keys:
2512
+ * - `breadcrumbs.data`
2513
+ * - `user`
2514
+ * - `contexts`
2515
+ * - `extra`
2516
+ * @param event Event
2517
+ * @returns Normalized event
2518
+ */
2519
+ function normalizeEvent(event, depth, maxBreadth) {
2520
+ if (!event) return null;
2521
+ const normalized = {
2522
+ ...event,
2523
+ ...event.breadcrumbs && { breadcrumbs: event.breadcrumbs.map((b) => ({
2524
+ ...b,
2525
+ ...b.data && { data: normalize(b.data, depth, maxBreadth) }
2526
+ })) },
2527
+ ...event.user && { user: normalize(event.user, depth, maxBreadth) },
2528
+ ...event.contexts && { contexts: normalize(event.contexts, depth, maxBreadth) },
2529
+ ...event.extra && { extra: normalize(event.extra, depth, maxBreadth) }
2530
+ };
2531
+ if (event.contexts?.trace && normalized.contexts) {
2532
+ normalized.contexts.trace = event.contexts.trace;
2533
+ if (event.contexts.trace.data) normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);
2534
+ }
2535
+ if (event.spans) normalized.spans = event.spans.map((span) => {
2536
+ return {
2537
+ ...span,
2538
+ ...span.data && { data: normalize(span.data, depth, maxBreadth) }
2539
+ };
2540
+ });
2541
+ if (event.contexts?.flags && normalized.contexts) normalized.contexts.flags = normalize(event.contexts.flags, 3, maxBreadth);
2542
+ return normalized;
2543
+ }
2544
+ function getFinalScope(scope, captureContext) {
2545
+ if (!captureContext) return scope;
2546
+ const finalScope = scope ? scope.clone() : new Scope();
2547
+ finalScope.update(captureContext);
2548
+ return finalScope;
2549
+ }
2550
+ //#endregion
2551
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/api.js
2552
+ const SENTRY_API_VERSION = "7";
2553
+ /** Returns the prefix to construct Sentry ingestion API endpoints. */
2554
+ function getBaseApiEndpoint(dsn) {
2555
+ const protocol = dsn.protocol ? `${dsn.protocol}:` : "";
2556
+ const port = dsn.port ? `:${dsn.port}` : "";
2557
+ return `${protocol}//${dsn.host}${port}${dsn.path ? `/${dsn.path}` : ""}/api/`;
2558
+ }
2559
+ /** Returns the ingest API endpoint for target. */
2560
+ function _getIngestEndpoint(dsn) {
2561
+ return `${getBaseApiEndpoint(dsn)}${dsn.projectId}/envelope/`;
2562
+ }
2563
+ /** Returns a URL-encoded string with auth config suitable for a query string. */
2564
+ function _encodedAuth(dsn, sdkInfo) {
2565
+ const params = { sentry_version: SENTRY_API_VERSION };
2566
+ if (dsn.publicKey) params.sentry_key = dsn.publicKey;
2567
+ if (sdkInfo) params.sentry_client = `${sdkInfo.name}/${sdkInfo.version}`;
2568
+ return new URLSearchParams(params).toString();
2569
+ }
2570
+ /**
2571
+ * Returns the envelope endpoint URL with auth in the query string.
2572
+ *
2573
+ * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.
2574
+ */
2575
+ function getEnvelopeEndpointWithUrlEncodedAuth(dsn, tunnel, sdkInfo) {
2576
+ return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, sdkInfo)}`;
2577
+ }
2578
+ //#endregion
2579
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/integration.js
2580
+ const installedIntegrations = [];
2581
+ /**
2582
+ * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default
2583
+ * integrations are added unless they were already provided before.
2584
+ * @param integrations array of integration instances
2585
+ * @param withDefault should enable default integrations
2586
+ */
2587
+ function setupIntegrations(client, integrations) {
2588
+ const integrationIndex = {};
2589
+ integrations.forEach((integration) => {
2590
+ if (integration) setupIntegration(client, integration, integrationIndex);
2591
+ });
2592
+ return integrationIndex;
2593
+ }
2594
+ /**
2595
+ * Execute the `afterAllSetup` hooks of the given integrations.
2596
+ */
2597
+ function afterSetupIntegrations(client, integrations) {
2598
+ for (const integration of integrations) if (integration?.afterAllSetup) integration.afterAllSetup(client);
2599
+ }
2600
+ /** Setup a single integration. */
2601
+ function setupIntegration(client, integration, integrationIndex) {
2602
+ if (integrationIndex[integration.name]) {
2603
+ DEBUG_BUILD$1 && debug.log(`Integration skipped because it was already installed: ${integration.name}`);
2604
+ return;
2605
+ }
2606
+ integrationIndex[integration.name] = integration;
2607
+ if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === "function") {
2608
+ integration.setupOnce();
2609
+ installedIntegrations.push(integration.name);
2610
+ }
2611
+ if (integration.setup && typeof integration.setup === "function") integration.setup(client);
2612
+ if (typeof integration.preprocessEvent === "function") {
2613
+ const callback = integration.preprocessEvent.bind(integration);
2614
+ client.on("preprocessEvent", (event, hint) => callback(event, hint, client));
2615
+ }
2616
+ if (typeof integration.processEvent === "function") {
2617
+ const callback = integration.processEvent.bind(integration);
2618
+ const processor = Object.assign((event, hint) => callback(event, hint, client), { id: integration.name });
2619
+ client.addEventProcessor(processor);
2620
+ }
2621
+ DEBUG_BUILD$1 && debug.log(`Integration installed: ${integration.name}`);
2622
+ }
2623
+ //#endregion
2624
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/clientreport.js
2625
+ /**
2626
+ * Creates client report envelope
2627
+ * @param discarded_events An array of discard events
2628
+ * @param dsn A DSN that can be set on the header. Optional.
2629
+ */
2630
+ function createClientReportEnvelope(discarded_events, dsn, timestamp) {
2631
+ const clientReportItem = [{ type: "client_report" }, {
2632
+ timestamp: timestamp || dateTimestampInSeconds(),
2633
+ discarded_events
2634
+ }];
2635
+ return createEnvelope(dsn ? { dsn } : {}, [clientReportItem]);
2636
+ }
2637
+ //#endregion
2638
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/eventUtils.js
2639
+ /**
2640
+ * Get a list of possible event messages from a Sentry event.
2641
+ */
2642
+ function getPossibleEventMessages(event) {
2643
+ const possibleMessages = [];
2644
+ if (event.message) possibleMessages.push(event.message);
2645
+ try {
2646
+ const lastException = event.exception.values[event.exception.values.length - 1];
2647
+ if (lastException?.value) {
2648
+ possibleMessages.push(lastException.value);
2649
+ if (lastException.type) possibleMessages.push(`${lastException.type}: ${lastException.value}`);
2650
+ }
2651
+ } catch {}
2652
+ return possibleMessages;
2653
+ }
2654
+ //#endregion
2655
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/transactionEvent.js
2656
+ /**
2657
+ * Converts a transaction event to a span JSON object.
2658
+ */
2659
+ function convertTransactionEventToSpanJson(event) {
2660
+ const { trace_id, parent_span_id, span_id, status, origin, data, op } = event.contexts?.trace ?? {};
2661
+ return {
2662
+ data: data ?? {},
2663
+ description: event.transaction,
2664
+ op,
2665
+ parent_span_id,
2666
+ span_id: span_id ?? "",
2667
+ start_timestamp: event.start_timestamp ?? 0,
2668
+ status,
2669
+ timestamp: event.timestamp,
2670
+ trace_id: trace_id ?? "",
2671
+ origin,
2672
+ profile_id: data?.[SEMANTIC_ATTRIBUTE_PROFILE_ID],
2673
+ exclusive_time: data?.[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME],
2674
+ measurements: event.measurements,
2675
+ is_segment: true
2676
+ };
2677
+ }
2678
+ /**
2679
+ * Converts a span JSON object to a transaction event.
2680
+ */
2681
+ function convertSpanJsonToTransactionEvent(span) {
2682
+ return {
2683
+ type: "transaction",
2684
+ timestamp: span.timestamp,
2685
+ start_timestamp: span.start_timestamp,
2686
+ transaction: span.description,
2687
+ contexts: { trace: {
2688
+ trace_id: span.trace_id,
2689
+ span_id: span.span_id,
2690
+ parent_span_id: span.parent_span_id,
2691
+ op: span.op,
2692
+ status: span.status,
2693
+ origin: span.origin,
2694
+ data: {
2695
+ ...span.data,
2696
+ ...span.profile_id && { ["sentry.profile_id"]: span.profile_id },
2697
+ ...span.exclusive_time && { ["sentry.exclusive_time"]: span.exclusive_time }
2698
+ }
2699
+ } },
2700
+ measurements: span.measurements
2701
+ };
2702
+ }
2703
+ //#endregion
2704
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/client.js
2705
+ const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
2706
+ const MISSING_RELEASE_FOR_SESSION_ERROR = "Discarded session because of missing or non-string release";
2707
+ const INTERNAL_ERROR_SYMBOL = Symbol.for("SentryInternalError");
2708
+ const DO_NOT_SEND_EVENT_SYMBOL = Symbol.for("SentryDoNotSendEventError");
2709
+ function _makeInternalError(message) {
2710
+ return {
2711
+ message,
2712
+ [INTERNAL_ERROR_SYMBOL]: true
2713
+ };
2714
+ }
2715
+ function _makeDoNotSendEventError(message) {
2716
+ return {
2717
+ message,
2718
+ [DO_NOT_SEND_EVENT_SYMBOL]: true
2719
+ };
2720
+ }
2721
+ function _isInternalError(error) {
2722
+ return !!error && typeof error === "object" && INTERNAL_ERROR_SYMBOL in error;
2723
+ }
2724
+ function _isDoNotSendEventError(error) {
2725
+ return !!error && typeof error === "object" && DO_NOT_SEND_EVENT_SYMBOL in error;
2726
+ }
2727
+ /**
2728
+ * Base implementation for all JavaScript SDK clients.
2729
+ *
2730
+ * Call the constructor with the corresponding options
2731
+ * specific to the client subclass. To access these options later, use
2732
+ * {@link Client.getOptions}.
2733
+ *
2734
+ * If a Dsn is specified in the options, it will be parsed and stored. Use
2735
+ * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is
2736
+ * invalid, the constructor will throw a {@link SentryException}. Note that
2737
+ * without a valid Dsn, the SDK will not send any events to Sentry.
2738
+ *
2739
+ * Before sending an event, it is passed through
2740
+ * {@link Client._prepareEvent} to add SDK information and scope data
2741
+ * (breadcrumbs and context). To add more custom information, override this
2742
+ * method and extend the resulting prepared event.
2743
+ *
2744
+ * To issue automatically created events (e.g. via instrumentation), use
2745
+ * {@link Client.captureEvent}. It will prepare the event and pass it through
2746
+ * the callback lifecycle. To issue auto-breadcrumbs, use
2747
+ * {@link Client.addBreadcrumb}.
2748
+ *
2749
+ * @example
2750
+ * class NodeClient extends Client<NodeOptions> {
2751
+ * public constructor(options: NodeOptions) {
2752
+ * super(options);
2753
+ * }
2754
+ *
2755
+ * // ...
2756
+ * }
2757
+ */
2758
+ var Client = class {
2759
+ /** Options passed to the SDK. */
2760
+ /** The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled. */
2761
+ /** Array of set up integrations. */
2762
+ /** Number of calls being processed */
2763
+ /** Holds flushable */
2764
+ /**
2765
+ * Initializes this client instance.
2766
+ *
2767
+ * @param options Options for the client.
2768
+ */
2769
+ constructor(options) {
2770
+ this._options = options;
2771
+ this._integrations = {};
2772
+ this._numProcessing = 0;
2773
+ this._outcomes = {};
2774
+ this._hooks = {};
2775
+ this._eventProcessors = [];
2776
+ if (options.dsn) this._dsn = makeDsn(options.dsn);
2777
+ else DEBUG_BUILD$1 && debug.warn("No DSN provided, client will not send events.");
2778
+ if (this._dsn) {
2779
+ const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options.tunnel, options._metadata ? options._metadata.sdk : void 0);
2780
+ this._transport = options.transport({
2781
+ tunnel: this._options.tunnel,
2782
+ recordDroppedEvent: this.recordDroppedEvent.bind(this),
2783
+ ...options.transportOptions,
2784
+ url
2785
+ });
2786
+ }
2787
+ }
2788
+ /**
2789
+ * Captures an exception event and sends it to Sentry.
2790
+ *
2791
+ * Unlike `captureException` exported from every SDK, this method requires that you pass it the current scope.
2792
+ */
2793
+ captureException(exception, hint, scope) {
2794
+ const eventId = uuid4();
2795
+ if (checkOrSetAlreadyCaught(exception)) {
2796
+ DEBUG_BUILD$1 && debug.log(ALREADY_SEEN_ERROR);
2797
+ return eventId;
2798
+ }
2799
+ const hintWithEventId = {
2800
+ event_id: eventId,
2801
+ ...hint
2802
+ };
2803
+ this._process(this.eventFromException(exception, hintWithEventId).then((event) => this._captureEvent(event, hintWithEventId, scope)));
2804
+ return hintWithEventId.event_id;
2805
+ }
2806
+ /**
2807
+ * Captures a message event and sends it to Sentry.
2808
+ *
2809
+ * Unlike `captureMessage` exported from every SDK, this method requires that you pass it the current scope.
2810
+ */
2811
+ captureMessage(message, level, hint, currentScope) {
2812
+ const hintWithEventId = {
2813
+ event_id: uuid4(),
2814
+ ...hint
2815
+ };
2816
+ const eventMessage = isParameterizedString(message) ? message : String(message);
2817
+ const promisedEvent = isPrimitive(message) ? this.eventFromMessage(eventMessage, level, hintWithEventId) : this.eventFromException(message, hintWithEventId);
2818
+ this._process(promisedEvent.then((event) => this._captureEvent(event, hintWithEventId, currentScope)));
2819
+ return hintWithEventId.event_id;
2820
+ }
2821
+ /**
2822
+ * Captures a manually created event and sends it to Sentry.
2823
+ *
2824
+ * Unlike `captureEvent` exported from every SDK, this method requires that you pass it the current scope.
2825
+ */
2826
+ captureEvent(event, hint, currentScope) {
2827
+ const eventId = uuid4();
2828
+ if (hint?.originalException && checkOrSetAlreadyCaught(hint.originalException)) {
2829
+ DEBUG_BUILD$1 && debug.log(ALREADY_SEEN_ERROR);
2830
+ return eventId;
2831
+ }
2832
+ const hintWithEventId = {
2833
+ event_id: eventId,
2834
+ ...hint
2835
+ };
2836
+ const sdkProcessingMetadata = event.sdkProcessingMetadata || {};
2837
+ const capturedSpanScope = sdkProcessingMetadata.capturedSpanScope;
2838
+ const capturedSpanIsolationScope = sdkProcessingMetadata.capturedSpanIsolationScope;
2839
+ this._process(this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope, capturedSpanIsolationScope));
2840
+ return hintWithEventId.event_id;
2841
+ }
2842
+ /**
2843
+ * Captures a session.
2844
+ */
2845
+ captureSession(session) {
2846
+ this.sendSession(session);
2847
+ updateSession(session, { init: false });
2848
+ }
2849
+ /**
2850
+ * Create a cron monitor check in and send it to Sentry. This method is not available on all clients.
2851
+ *
2852
+ * @param checkIn An object that describes a check in.
2853
+ * @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
2854
+ * to create a monitor automatically when sending a check in.
2855
+ * @param scope An optional scope containing event metadata.
2856
+ * @returns A string representing the id of the check in.
2857
+ */
2858
+ /**
2859
+ * Get the current Dsn.
2860
+ */
2861
+ getDsn() {
2862
+ return this._dsn;
2863
+ }
2864
+ /**
2865
+ * Get the current options.
2866
+ */
2867
+ getOptions() {
2868
+ return this._options;
2869
+ }
2870
+ /**
2871
+ * Get the SDK metadata.
2872
+ * @see SdkMetadata
2873
+ */
2874
+ getSdkMetadata() {
2875
+ return this._options._metadata;
2876
+ }
2877
+ /**
2878
+ * Returns the transport that is used by the client.
2879
+ * Please note that the transport gets lazy initialized so it will only be there once the first event has been sent.
2880
+ */
2881
+ getTransport() {
2882
+ return this._transport;
2883
+ }
2884
+ /**
2885
+ * Wait for all events to be sent or the timeout to expire, whichever comes first.
2886
+ *
2887
+ * @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
2888
+ * cause the client to wait until all events are sent before resolving the promise.
2889
+ * @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
2890
+ * still events in the queue when the timeout is reached.
2891
+ */
2892
+ flush(timeout) {
2893
+ const transport = this._transport;
2894
+ if (transport) {
2895
+ this.emit("flush");
2896
+ return this._isClientDoneProcessing(timeout).then((clientFinished) => {
2897
+ return transport.flush(timeout).then((transportFlushed) => clientFinished && transportFlushed);
2898
+ });
2899
+ } else return resolvedSyncPromise(true);
2900
+ }
2901
+ /**
2902
+ * Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
2903
+ *
2904
+ * @param {number} timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
2905
+ * the client to wait until all events are sent before disabling itself.
2906
+ * @returns {Promise<boolean>} A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
2907
+ * it doesn't.
2908
+ */
2909
+ close(timeout) {
2910
+ return this.flush(timeout).then((result) => {
2911
+ this.getOptions().enabled = false;
2912
+ this.emit("close");
2913
+ return result;
2914
+ });
2915
+ }
2916
+ /**
2917
+ * Get all installed event processors.
2918
+ */
2919
+ getEventProcessors() {
2920
+ return this._eventProcessors;
2921
+ }
2922
+ /**
2923
+ * Adds an event processor that applies to any event processed by this client.
2924
+ */
2925
+ addEventProcessor(eventProcessor) {
2926
+ this._eventProcessors.push(eventProcessor);
2927
+ }
2928
+ /**
2929
+ * Initialize this client.
2930
+ * Call this after the client was set on a scope.
2931
+ */
2932
+ init() {
2933
+ if (this._isEnabled() || this._options.integrations.some(({ name }) => name.startsWith("Spotlight"))) this._setupIntegrations();
2934
+ }
2935
+ /**
2936
+ * Gets an installed integration by its name.
2937
+ *
2938
+ * @returns {Integration|undefined} The installed integration or `undefined` if no integration with that `name` was installed.
2939
+ */
2940
+ getIntegrationByName(integrationName) {
2941
+ return this._integrations[integrationName];
2942
+ }
2943
+ /**
2944
+ * Add an integration to the client.
2945
+ * This can be used to e.g. lazy load integrations.
2946
+ * In most cases, this should not be necessary,
2947
+ * and you're better off just passing the integrations via `integrations: []` at initialization time.
2948
+ * However, if you find the need to conditionally load & add an integration, you can use `addIntegration` to do so.
2949
+ */
2950
+ addIntegration(integration) {
2951
+ const isAlreadyInstalled = this._integrations[integration.name];
2952
+ setupIntegration(this, integration, this._integrations);
2953
+ if (!isAlreadyInstalled) afterSetupIntegrations(this, [integration]);
2954
+ }
2955
+ /**
2956
+ * Send a fully prepared event to Sentry.
2957
+ */
2958
+ sendEvent(event, hint = {}) {
2959
+ this.emit("beforeSendEvent", event, hint);
2960
+ let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel);
2961
+ for (const attachment of hint.attachments || []) env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment));
2962
+ const promise = this.sendEnvelope(env);
2963
+ if (promise) promise.then((sendResponse) => this.emit("afterSendEvent", event, sendResponse), null);
2964
+ }
2965
+ /**
2966
+ * Send a session or session aggregrates to Sentry.
2967
+ */
2968
+ sendSession(session) {
2969
+ const { release: clientReleaseOption, environment: clientEnvironmentOption = DEFAULT_ENVIRONMENT } = this._options;
2970
+ if ("aggregates" in session) {
2971
+ const sessionAttrs = session.attrs || {};
2972
+ if (!sessionAttrs.release && !clientReleaseOption) {
2973
+ DEBUG_BUILD$1 && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
2974
+ return;
2975
+ }
2976
+ sessionAttrs.release = sessionAttrs.release || clientReleaseOption;
2977
+ sessionAttrs.environment = sessionAttrs.environment || clientEnvironmentOption;
2978
+ session.attrs = sessionAttrs;
2979
+ } else {
2980
+ if (!session.release && !clientReleaseOption) {
2981
+ DEBUG_BUILD$1 && debug.warn(MISSING_RELEASE_FOR_SESSION_ERROR);
2982
+ return;
2983
+ }
2984
+ session.release = session.release || clientReleaseOption;
2985
+ session.environment = session.environment || clientEnvironmentOption;
2986
+ }
2987
+ this.emit("beforeSendSession", session);
2988
+ const env = createSessionEnvelope(session, this._dsn, this._options._metadata, this._options.tunnel);
2989
+ this.sendEnvelope(env);
2990
+ }
2991
+ /**
2992
+ * Record on the client that an event got dropped (ie, an event that will not be sent to Sentry).
2993
+ */
2994
+ recordDroppedEvent(reason, category, count = 1) {
2995
+ if (this._options.sendClientReports) {
2996
+ const key = `${reason}:${category}`;
2997
+ DEBUG_BUILD$1 && debug.log(`Recording outcome: "${key}"${count > 1 ? ` (${count} times)` : ""}`);
2998
+ this._outcomes[key] = (this._outcomes[key] || 0) + count;
2999
+ }
3000
+ }
3001
+ /**
3002
+ * Register a callback for whenever a span is started.
3003
+ * Receives the span as argument.
3004
+ * @returns {() => void} A function that, when executed, removes the registered callback.
3005
+ */
3006
+ /**
3007
+ * Register a hook on this client.
3008
+ */
3009
+ on(hook, callback) {
3010
+ const hooks = this._hooks[hook] = this._hooks[hook] || [];
3011
+ hooks.push(callback);
3012
+ return () => {
3013
+ const cbIndex = hooks.indexOf(callback);
3014
+ if (cbIndex > -1) hooks.splice(cbIndex, 1);
3015
+ };
3016
+ }
3017
+ /** Fire a hook whenever a span starts. */
3018
+ /**
3019
+ * Emit a hook that was previously registered via `on()`.
3020
+ */
3021
+ emit(hook, ...rest) {
3022
+ const callbacks = this._hooks[hook];
3023
+ if (callbacks) callbacks.forEach((callback) => callback(...rest));
3024
+ }
3025
+ /**
3026
+ * Send an envelope to Sentry.
3027
+ */
3028
+ sendEnvelope(envelope) {
3029
+ this.emit("beforeEnvelope", envelope);
3030
+ if (this._isEnabled() && this._transport) return this._transport.send(envelope).then(null, (reason) => {
3031
+ DEBUG_BUILD$1 && debug.error("Error while sending envelope:", reason);
3032
+ return reason;
3033
+ });
3034
+ DEBUG_BUILD$1 && debug.error("Transport disabled");
3035
+ return resolvedSyncPromise({});
3036
+ }
3037
+ /** Setup integrations for this client. */
3038
+ _setupIntegrations() {
3039
+ const { integrations } = this._options;
3040
+ this._integrations = setupIntegrations(this, integrations);
3041
+ afterSetupIntegrations(this, integrations);
3042
+ }
3043
+ /** Updates existing session based on the provided event */
3044
+ _updateSessionFromEvent(session, event) {
3045
+ let crashed = event.level === "fatal";
3046
+ let errored = false;
3047
+ const exceptions = event.exception?.values;
3048
+ if (exceptions) {
3049
+ errored = true;
3050
+ for (const ex of exceptions) if (ex.mechanism?.handled === false) {
3051
+ crashed = true;
3052
+ break;
3053
+ }
3054
+ }
3055
+ const sessionNonTerminal = session.status === "ok";
3056
+ if (sessionNonTerminal && session.errors === 0 || sessionNonTerminal && crashed) {
3057
+ updateSession(session, {
3058
+ ...crashed && { status: "crashed" },
3059
+ errors: session.errors || Number(errored || crashed)
3060
+ });
3061
+ this.captureSession(session);
3062
+ }
3063
+ }
3064
+ /**
3065
+ * Determine if the client is finished processing. Returns a promise because it will wait `timeout` ms before saying
3066
+ * "no" (resolving to `false`) in order to give the client a chance to potentially finish first.
3067
+ *
3068
+ * @param timeout The time, in ms, after which to resolve to `false` if the client is still busy. Passing `0` (or not
3069
+ * passing anything) will make the promise wait as long as it takes for processing to finish before resolving to
3070
+ * `true`.
3071
+ * @returns A promise which will resolve to `true` if processing is already done or finishes before the timeout, and
3072
+ * `false` otherwise
3073
+ */
3074
+ _isClientDoneProcessing(timeout) {
3075
+ return new SyncPromise((resolve) => {
3076
+ let ticked = 0;
3077
+ const tick = 1;
3078
+ const interval = setInterval(() => {
3079
+ if (this._numProcessing == 0) {
3080
+ clearInterval(interval);
3081
+ resolve(true);
3082
+ } else {
3083
+ ticked += tick;
3084
+ if (timeout && ticked >= timeout) {
3085
+ clearInterval(interval);
3086
+ resolve(false);
3087
+ }
3088
+ }
3089
+ }, tick);
3090
+ });
3091
+ }
3092
+ /** Determines whether this SDK is enabled and a transport is present. */
3093
+ _isEnabled() {
3094
+ return this.getOptions().enabled !== false && this._transport !== void 0;
3095
+ }
3096
+ /**
3097
+ * Adds common information to events.
3098
+ *
3099
+ * The information includes release and environment from `options`,
3100
+ * breadcrumbs and context (extra, tags and user) from the scope.
3101
+ *
3102
+ * Information that is already present in the event is never overwritten. For
3103
+ * nested objects, such as the context, keys are merged.
3104
+ *
3105
+ * @param event The original event.
3106
+ * @param hint May contain additional information about the original exception.
3107
+ * @param currentScope A scope containing event metadata.
3108
+ * @returns A new event with more information.
3109
+ */
3110
+ _prepareEvent(event, hint, currentScope, isolationScope) {
3111
+ const options = this.getOptions();
3112
+ const integrations = Object.keys(this._integrations);
3113
+ if (!hint.integrations && integrations?.length) hint.integrations = integrations;
3114
+ this.emit("preprocessEvent", event, hint);
3115
+ if (!event.type) isolationScope.setLastEventId(event.event_id || hint.event_id);
3116
+ return prepareEvent(options, event, hint, currentScope, this, isolationScope).then((evt) => {
3117
+ if (evt === null) return evt;
3118
+ this.emit("postprocessEvent", evt, hint);
3119
+ evt.contexts = {
3120
+ trace: getTraceContextFromScope(currentScope),
3121
+ ...evt.contexts
3122
+ };
3123
+ evt.sdkProcessingMetadata = {
3124
+ dynamicSamplingContext: getDynamicSamplingContextFromScope(this, currentScope),
3125
+ ...evt.sdkProcessingMetadata
3126
+ };
3127
+ return evt;
3128
+ });
3129
+ }
3130
+ /**
3131
+ * Processes the event and logs an error in case of rejection
3132
+ * @param event
3133
+ * @param hint
3134
+ * @param scope
3135
+ */
3136
+ _captureEvent(event, hint = {}, currentScope = getCurrentScope(), isolationScope = getIsolationScope()) {
3137
+ if (DEBUG_BUILD$1 && isErrorEvent(event)) debug.log(`Captured error event \`${getPossibleEventMessages(event)[0] || "<unknown>"}\``);
3138
+ return this._processEvent(event, hint, currentScope, isolationScope).then((finalEvent) => {
3139
+ return finalEvent.event_id;
3140
+ }, (reason) => {
3141
+ if (DEBUG_BUILD$1) {
3142
+ if (_isDoNotSendEventError(reason)) debug.log(reason.message);
3143
+ else if (_isInternalError(reason)) debug.warn(reason.message);
3144
+ else debug.warn(reason);
3145
+ }
3146
+ });
3147
+ }
3148
+ /**
3149
+ * Processes an event (either error or message) and sends it to Sentry.
3150
+ *
3151
+ * This also adds breadcrumbs and context information to the event. However,
3152
+ * platform specific meta data (such as the User's IP address) must be added
3153
+ * by the SDK implementor.
3154
+ *
3155
+ *
3156
+ * @param event The event to send to Sentry.
3157
+ * @param hint May contain additional information about the original exception.
3158
+ * @param currentScope A scope containing event metadata.
3159
+ * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
3160
+ */
3161
+ _processEvent(event, hint, currentScope, isolationScope) {
3162
+ const options = this.getOptions();
3163
+ const { sampleRate } = options;
3164
+ const isTransaction = isTransactionEvent(event);
3165
+ const isError = isErrorEvent(event);
3166
+ const eventType = event.type || "error";
3167
+ const beforeSendLabel = `before send for type \`${eventType}\``;
3168
+ const parsedSampleRate = typeof sampleRate === "undefined" ? void 0 : parseSampleRate(sampleRate);
3169
+ if (isError && typeof parsedSampleRate === "number" && Math.random() > parsedSampleRate) {
3170
+ this.recordDroppedEvent("sample_rate", "error");
3171
+ return rejectedSyncPromise(_makeDoNotSendEventError(`Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`));
3172
+ }
3173
+ const dataCategory = eventType === "replay_event" ? "replay" : eventType;
3174
+ return this._prepareEvent(event, hint, currentScope, isolationScope).then((prepared) => {
3175
+ if (prepared === null) {
3176
+ this.recordDroppedEvent("event_processor", dataCategory);
3177
+ throw _makeDoNotSendEventError("An event processor returned `null`, will not send event.");
3178
+ }
3179
+ if (hint.data && hint.data.__sentry__ === true) return prepared;
3180
+ return _validateBeforeSendResult(processBeforeSend(this, options, prepared, hint), beforeSendLabel);
3181
+ }).then((processedEvent) => {
3182
+ if (processedEvent === null) {
3183
+ this.recordDroppedEvent("before_send", dataCategory);
3184
+ if (isTransaction) {
3185
+ const spanCount = 1 + (event.spans || []).length;
3186
+ this.recordDroppedEvent("before_send", "span", spanCount);
3187
+ }
3188
+ throw _makeDoNotSendEventError(`${beforeSendLabel} returned \`null\`, will not send event.`);
3189
+ }
3190
+ const session = currentScope.getSession() || isolationScope.getSession();
3191
+ if (isError && session) this._updateSessionFromEvent(session, processedEvent);
3192
+ if (isTransaction) {
3193
+ const droppedSpanCount = (processedEvent.sdkProcessingMetadata?.spanCountBeforeProcessing || 0) - (processedEvent.spans ? processedEvent.spans.length : 0);
3194
+ if (droppedSpanCount > 0) this.recordDroppedEvent("before_send", "span", droppedSpanCount);
3195
+ }
3196
+ const transactionInfo = processedEvent.transaction_info;
3197
+ if (isTransaction && transactionInfo && processedEvent.transaction !== event.transaction) {
3198
+ const source = "custom";
3199
+ processedEvent.transaction_info = {
3200
+ ...transactionInfo,
3201
+ source
3202
+ };
3203
+ }
3204
+ this.sendEvent(processedEvent, hint);
3205
+ return processedEvent;
3206
+ }).then(null, (reason) => {
3207
+ if (_isDoNotSendEventError(reason) || _isInternalError(reason)) throw reason;
3208
+ this.captureException(reason, {
3209
+ data: { __sentry__: true },
3210
+ originalException: reason
3211
+ });
3212
+ throw _makeInternalError(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${reason}`);
3213
+ });
3214
+ }
3215
+ /**
3216
+ * Occupies the client with processing and event
3217
+ */
3218
+ _process(promise) {
3219
+ this._numProcessing++;
3220
+ promise.then((value) => {
3221
+ this._numProcessing--;
3222
+ return value;
3223
+ }, (reason) => {
3224
+ this._numProcessing--;
3225
+ return reason;
3226
+ });
3227
+ }
3228
+ /**
3229
+ * Clears outcomes on this client and returns them.
3230
+ */
3231
+ _clearOutcomes() {
3232
+ const outcomes = this._outcomes;
3233
+ this._outcomes = {};
3234
+ return Object.entries(outcomes).map(([key, quantity]) => {
3235
+ const [reason, category] = key.split(":");
3236
+ return {
3237
+ reason,
3238
+ category,
3239
+ quantity
3240
+ };
3241
+ });
3242
+ }
3243
+ /**
3244
+ * Sends client reports as an envelope.
3245
+ */
3246
+ _flushOutcomes() {
3247
+ DEBUG_BUILD$1 && debug.log("Flushing outcomes...");
3248
+ const outcomes = this._clearOutcomes();
3249
+ if (outcomes.length === 0) {
3250
+ DEBUG_BUILD$1 && debug.log("No outcomes to send");
3251
+ return;
3252
+ }
3253
+ if (!this._dsn) {
3254
+ DEBUG_BUILD$1 && debug.log("No dsn provided, will not send outcomes");
3255
+ return;
3256
+ }
3257
+ DEBUG_BUILD$1 && debug.log("Sending outcomes:", outcomes);
3258
+ const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
3259
+ this.sendEnvelope(envelope);
3260
+ }
3261
+ };
3262
+ /**
3263
+ * Verifies that return value of configured `beforeSend` or `beforeSendTransaction` is of expected type, and returns the value if so.
3264
+ */
3265
+ function _validateBeforeSendResult(beforeSendResult, beforeSendLabel) {
3266
+ const invalidValueError = `${beforeSendLabel} must return \`null\` or a valid event.`;
3267
+ if (isThenable(beforeSendResult)) return beforeSendResult.then((event) => {
3268
+ if (!isPlainObject(event) && event !== null) throw _makeInternalError(invalidValueError);
3269
+ return event;
3270
+ }, (e) => {
3271
+ throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`);
3272
+ });
3273
+ else if (!isPlainObject(beforeSendResult) && beforeSendResult !== null) throw _makeInternalError(invalidValueError);
3274
+ return beforeSendResult;
3275
+ }
3276
+ /**
3277
+ * Process the matching `beforeSendXXX` callback.
3278
+ */
3279
+ function processBeforeSend(client, options, event, hint) {
3280
+ const { beforeSend, beforeSendTransaction, beforeSendSpan } = options;
3281
+ let processedEvent = event;
3282
+ if (isErrorEvent(processedEvent) && beforeSend) return beforeSend(processedEvent, hint);
3283
+ if (isTransactionEvent(processedEvent)) {
3284
+ if (beforeSendSpan) {
3285
+ const processedRootSpanJson = beforeSendSpan(convertTransactionEventToSpanJson(processedEvent));
3286
+ if (!processedRootSpanJson) showSpanDropWarning();
3287
+ else processedEvent = merge(event, convertSpanJsonToTransactionEvent(processedRootSpanJson));
3288
+ if (processedEvent.spans) {
3289
+ const processedSpans = [];
3290
+ for (const span of processedEvent.spans) {
3291
+ const processedSpan = beforeSendSpan(span);
3292
+ if (!processedSpan) {
3293
+ showSpanDropWarning();
3294
+ processedSpans.push(span);
3295
+ } else processedSpans.push(processedSpan);
3296
+ }
3297
+ processedEvent.spans = processedSpans;
3298
+ }
3299
+ }
3300
+ if (beforeSendTransaction) {
3301
+ if (processedEvent.spans) {
3302
+ const spanCountBefore = processedEvent.spans.length;
3303
+ processedEvent.sdkProcessingMetadata = {
3304
+ ...event.sdkProcessingMetadata,
3305
+ spanCountBeforeProcessing: spanCountBefore
3306
+ };
3307
+ }
3308
+ return beforeSendTransaction(processedEvent, hint);
3309
+ }
3310
+ }
3311
+ return processedEvent;
3312
+ }
3313
+ function isErrorEvent(event) {
3314
+ return event.type === void 0;
3315
+ }
3316
+ function isTransactionEvent(event) {
3317
+ return event.type === "transaction";
3318
+ }
3319
+ //#endregion
3320
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/logs/envelope.js
3321
+ /**
3322
+ * Creates a log container envelope item for a list of logs.
3323
+ *
3324
+ * @param items - The logs to include in the envelope.
3325
+ * @returns The created log container envelope item.
3326
+ */
3327
+ function createLogContainerEnvelopeItem(items) {
3328
+ return [{
3329
+ type: "log",
3330
+ item_count: items.length,
3331
+ content_type: "application/vnd.sentry.items.log+json"
3332
+ }, { items }];
3333
+ }
3334
+ /**
3335
+ * Creates an envelope for a list of logs.
3336
+ *
3337
+ * Logs from multiple traces can be included in the same envelope.
3338
+ *
3339
+ * @param logs - The logs to include in the envelope.
3340
+ * @param metadata - The metadata to include in the envelope.
3341
+ * @param tunnel - The tunnel to include in the envelope.
3342
+ * @param dsn - The DSN to include in the envelope.
3343
+ * @returns The created envelope.
3344
+ */
3345
+ function createLogEnvelope(logs, metadata, tunnel, dsn) {
3346
+ const headers = {};
3347
+ if (metadata?.sdk) headers.sdk = {
3348
+ name: metadata.sdk.name,
3349
+ version: metadata.sdk.version
3350
+ };
3351
+ if (!!tunnel && !!dsn) headers.dsn = dsnToString(dsn);
3352
+ return createEnvelope(headers, [createLogContainerEnvelopeItem(logs)]);
3353
+ }
3354
+ //#endregion
3355
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/logs/exports.js
3356
+ /**
3357
+ * Flushes the logs buffer to Sentry.
3358
+ *
3359
+ * @param client - A client.
3360
+ * @param maybeLogBuffer - A log buffer. Uses the log buffer for the given client if not provided.
3361
+ *
3362
+ * @experimental This method will experience breaking changes. This is not yet part of
3363
+ * the stable Sentry SDK API and can be changed or removed without warning.
3364
+ */
3365
+ function _INTERNAL_flushLogsBuffer(client, maybeLogBuffer) {
3366
+ const logBuffer = maybeLogBuffer ?? _INTERNAL_getLogBuffer(client) ?? [];
3367
+ if (logBuffer.length === 0) return;
3368
+ const clientOptions = client.getOptions();
3369
+ const envelope = createLogEnvelope(logBuffer, clientOptions._metadata, clientOptions.tunnel, client.getDsn());
3370
+ _getBufferMap().set(client, []);
3371
+ client.emit("flushLogs");
3372
+ client.sendEnvelope(envelope);
3373
+ }
3374
+ /**
3375
+ * Returns the log buffer for a given client.
3376
+ *
3377
+ * Exported for testing purposes.
3378
+ *
3379
+ * @param client - The client to get the log buffer for.
3380
+ * @returns The log buffer for the given client.
3381
+ */
3382
+ function _INTERNAL_getLogBuffer(client) {
3383
+ return _getBufferMap().get(client);
3384
+ }
3385
+ function _getBufferMap() {
3386
+ return getGlobalSingleton("clientToLogBufferMap", () => /* @__PURE__ */ new WeakMap());
3387
+ }
3388
+ //#endregion
3389
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/promisebuffer.js
3390
+ const SENTRY_BUFFER_FULL_ERROR = Symbol.for("SentryBufferFullError");
3391
+ /**
3392
+ * Creates an new PromiseBuffer object with the specified limit
3393
+ * @param limit max number of promises that can be stored in the buffer
3394
+ */
3395
+ function makePromiseBuffer(limit) {
3396
+ const buffer = [];
3397
+ function isReady() {
3398
+ return limit === void 0 || buffer.length < limit;
3399
+ }
3400
+ /**
3401
+ * Remove a promise from the queue.
3402
+ *
3403
+ * @param task Can be any PromiseLike<T>
3404
+ * @returns Removed promise.
3405
+ */
3406
+ function remove(task) {
3407
+ return buffer.splice(buffer.indexOf(task), 1)[0] || Promise.resolve(void 0);
3408
+ }
3409
+ /**
3410
+ * Add a promise (representing an in-flight action) to the queue, and set it to remove itself on fulfillment.
3411
+ *
3412
+ * @param taskProducer A function producing any PromiseLike<T>; In previous versions this used to be `task:
3413
+ * PromiseLike<T>`, but under that model, Promises were instantly created on the call-site and their executor
3414
+ * functions therefore ran immediately. Thus, even if the buffer was full, the action still happened. By
3415
+ * requiring the promise to be wrapped in a function, we can defer promise creation until after the buffer
3416
+ * limit check.
3417
+ * @returns The original promise.
3418
+ */
3419
+ function add(taskProducer) {
3420
+ if (!isReady()) return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR);
3421
+ const task = taskProducer();
3422
+ if (buffer.indexOf(task) === -1) buffer.push(task);
3423
+ task.then(() => remove(task)).then(null, () => remove(task).then(null, () => {}));
3424
+ return task;
3425
+ }
3426
+ /**
3427
+ * Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first.
3428
+ *
3429
+ * @param timeout The time, in ms, after which to resolve to `false` if the queue is still non-empty. Passing `0` (or
3430
+ * not passing anything) will make the promise wait as long as it takes for the queue to drain before resolving to
3431
+ * `true`.
3432
+ * @returns A promise which will resolve to `true` if the queue is already empty or drains before the timeout, and
3433
+ * `false` otherwise
3434
+ */
3435
+ function drain(timeout) {
3436
+ return new SyncPromise((resolve, reject) => {
3437
+ let counter = buffer.length;
3438
+ if (!counter) return resolve(true);
3439
+ const capturedSetTimeout = setTimeout(() => {
3440
+ if (timeout && timeout > 0) resolve(false);
3441
+ }, timeout);
3442
+ buffer.forEach((item) => {
3443
+ resolvedSyncPromise(item).then(() => {
3444
+ if (!--counter) {
3445
+ clearTimeout(capturedSetTimeout);
3446
+ resolve(true);
3447
+ }
3448
+ }, reject);
3449
+ });
3450
+ });
3451
+ }
3452
+ return {
3453
+ $: buffer,
3454
+ add,
3455
+ drain
3456
+ };
3457
+ }
3458
+ //#endregion
3459
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/ratelimit.js
3460
+ const DEFAULT_RETRY_AFTER = 6e4;
3461
+ /**
3462
+ * Extracts Retry-After value from the request header or returns default value
3463
+ * @param header string representation of 'Retry-After' header
3464
+ * @param now current unix timestamp
3465
+ *
3466
+ */
3467
+ function parseRetryAfterHeader(header, now = Date.now()) {
3468
+ const headerDelay = parseInt(`${header}`, 10);
3469
+ if (!isNaN(headerDelay)) return headerDelay * 1e3;
3470
+ const headerDate = Date.parse(`${header}`);
3471
+ if (!isNaN(headerDate)) return headerDate - now;
3472
+ return DEFAULT_RETRY_AFTER;
3473
+ }
3474
+ /**
3475
+ * Gets the time that the given category is disabled until for rate limiting.
3476
+ * In case no category-specific limit is set but a general rate limit across all categories is active,
3477
+ * that time is returned.
3478
+ *
3479
+ * @return the time in ms that the category is disabled until or 0 if there's no active rate limit.
3480
+ */
3481
+ function disabledUntil(limits, dataCategory) {
3482
+ return limits[dataCategory] || limits.all || 0;
3483
+ }
3484
+ /**
3485
+ * Checks if a category is rate limited
3486
+ */
3487
+ function isRateLimited(limits, dataCategory, now = Date.now()) {
3488
+ return disabledUntil(limits, dataCategory) > now;
3489
+ }
3490
+ /**
3491
+ * Update ratelimits from incoming headers.
3492
+ *
3493
+ * @return the updated RateLimits object.
3494
+ */
3495
+ function updateRateLimits(limits, { statusCode, headers }, now = Date.now()) {
3496
+ const updatedRateLimits = { ...limits };
3497
+ const rateLimitHeader = headers?.["x-sentry-rate-limits"];
3498
+ const retryAfterHeader = headers?.["retry-after"];
3499
+ if (rateLimitHeader)
3500
+ /**
3501
+ * rate limit headers are of the form
3502
+ * <header>,<header>,..
3503
+ * where each <header> is of the form
3504
+ * <retry_after>: <categories>: <scope>: <reason_code>: <namespaces>
3505
+ * where
3506
+ * <retry_after> is a delay in seconds
3507
+ * <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
3508
+ * <category>;<category>;...
3509
+ * <scope> is what's being limited (org, project, or key) - ignored by SDK
3510
+ * <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
3511
+ * <namespaces> Semicolon-separated list of metric namespace identifiers. Defines which namespace(s) will be affected.
3512
+ * Only present if rate limit applies to the metric_bucket data category.
3513
+ */
3514
+ for (const limit of rateLimitHeader.trim().split(",")) {
3515
+ const [retryAfter, categories, , , namespaces] = limit.split(":", 5);
3516
+ const headerDelay = parseInt(retryAfter, 10);
3517
+ const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1e3;
3518
+ if (!categories) updatedRateLimits.all = now + delay;
3519
+ else for (const category of categories.split(";")) if (category === "metric_bucket") {
3520
+ if (!namespaces || namespaces.split(";").includes("custom")) updatedRateLimits[category] = now + delay;
3521
+ } else updatedRateLimits[category] = now + delay;
3522
+ }
3523
+ else if (retryAfterHeader) updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);
3524
+ else if (statusCode === 429) updatedRateLimits.all = now + 6e4;
3525
+ return updatedRateLimits;
3526
+ }
3527
+ /**
3528
+ * Creates an instance of a Sentry `Transport`
3529
+ *
3530
+ * @param options
3531
+ * @param makeRequest
3532
+ */
3533
+ function createTransport(options, makeRequest, buffer = makePromiseBuffer(options.bufferSize || 64)) {
3534
+ let rateLimits = {};
3535
+ const flush = (timeout) => buffer.drain(timeout);
3536
+ function send(envelope) {
3537
+ const filteredEnvelopeItems = [];
3538
+ forEachEnvelopeItem(envelope, (item, type) => {
3539
+ const dataCategory = envelopeItemTypeToDataCategory(type);
3540
+ if (isRateLimited(rateLimits, dataCategory)) options.recordDroppedEvent("ratelimit_backoff", dataCategory);
3541
+ else filteredEnvelopeItems.push(item);
3542
+ });
3543
+ if (filteredEnvelopeItems.length === 0) return resolvedSyncPromise({});
3544
+ const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems);
3545
+ const recordEnvelopeLoss = (reason) => {
3546
+ forEachEnvelopeItem(filteredEnvelope, (item, type) => {
3547
+ options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type));
3548
+ });
3549
+ };
3550
+ const requestTask = () => makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then((response) => {
3551
+ if (response.statusCode !== void 0 && (response.statusCode < 200 || response.statusCode >= 300)) DEBUG_BUILD$1 && debug.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);
3552
+ rateLimits = updateRateLimits(rateLimits, response);
3553
+ return response;
3554
+ }, (error) => {
3555
+ recordEnvelopeLoss("network_error");
3556
+ DEBUG_BUILD$1 && debug.error("Encountered error running transport request:", error);
3557
+ throw error;
3558
+ });
3559
+ return buffer.add(requestTask).then((result) => result, (error) => {
3560
+ if (error === SENTRY_BUFFER_FULL_ERROR) {
3561
+ DEBUG_BUILD$1 && debug.error("Skipped sending event because buffer is full.");
3562
+ recordEnvelopeLoss("queue_overflow");
3563
+ return resolvedSyncPromise({});
3564
+ } else throw error;
3565
+ });
3566
+ }
3567
+ return {
3568
+ send,
3569
+ flush
3570
+ };
3571
+ }
3572
+ //#endregion
3573
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/ipAddress.js
3574
+ /**
3575
+ * @internal
3576
+ */
3577
+ function addAutoIpAddressToUser(objWithMaybeUser) {
3578
+ if (objWithMaybeUser.user?.ip_address === void 0) objWithMaybeUser.user = {
3579
+ ...objWithMaybeUser.user,
3580
+ ip_address: "{{auto}}"
3581
+ };
3582
+ }
3583
+ /**
3584
+ * @internal
3585
+ */
3586
+ function addAutoIpAddressToSession(session) {
3587
+ if ("aggregates" in session) {
3588
+ if (session.attrs?.["ip_address"] === void 0) session.attrs = {
3589
+ ...session.attrs,
3590
+ ip_address: "{{auto}}"
3591
+ };
3592
+ } else if (session.ipAddress === void 0) session.ipAddress = "{{auto}}";
3593
+ }
3594
+ //#endregion
3595
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/sdkMetadata.js
3596
+ /**
3597
+ * A builder for the SDK metadata in the options for the SDK initialization.
3598
+ *
3599
+ * Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.
3600
+ * We don't extract it for bundle size reasons.
3601
+ * @see https://github.com/getsentry/sentry-javascript/pull/7404
3602
+ * @see https://github.com/getsentry/sentry-javascript/pull/4196
3603
+ *
3604
+ * If you make changes to this function consider updating the others as well.
3605
+ *
3606
+ * @param options SDK options object that gets mutated
3607
+ * @param names list of package names
3608
+ */
3609
+ function applySdkMetadata(options, name, names = [name], source = "npm") {
3610
+ const metadata = options._metadata || {};
3611
+ if (!metadata.sdk) metadata.sdk = {
3612
+ name: `sentry.javascript.${name}`,
3613
+ packages: names.map((name) => ({
3614
+ name: `${source}:@sentry/${name}`,
3615
+ version: SDK_VERSION
3616
+ })),
3617
+ version: SDK_VERSION
3618
+ };
3619
+ options._metadata = metadata;
3620
+ }
3621
+ //#endregion
3622
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/supports.js
3623
+ /**
3624
+ * isNative checks if the given function is a native implementation
3625
+ */
3626
+ function isNativeFunction(func) {
3627
+ return func && /^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(func.toString());
3628
+ }
3629
+ //#endregion
3630
+ //#region ../../node_modules/.pnpm/@sentry+core@9.47.1/node_modules/@sentry/core/build/esm/utils/env.js
3631
+ /**
3632
+ * Get source of SDK.
3633
+ */
3634
+ function getSDKSource() {
3635
+ return "npm";
3636
+ }
3637
+ //#endregion
3638
+ //#region ../../node_modules/.pnpm/@sentry+browser@9.47.1/node_modules/@sentry/browser/build/npm/esm/helpers.js
3639
+ const WINDOW$1 = GLOBAL_OBJ;
3640
+ //#endregion
3641
+ //#region ../../node_modules/.pnpm/@sentry+browser@9.47.1/node_modules/@sentry/browser/build/npm/esm/eventbuilder.js
3642
+ /**
3643
+ * This function creates an exception from a JavaScript Error
3644
+ */
3645
+ function exceptionFromError(stackParser, ex) {
3646
+ const frames = parseStackFrames(stackParser, ex);
3647
+ const exception = {
3648
+ type: extractType(ex),
3649
+ value: extractMessage(ex)
3650
+ };
3651
+ if (frames.length) exception.stacktrace = { frames };
3652
+ if (exception.type === void 0 && exception.value === "") exception.value = "Unrecoverable error caught";
3653
+ return exception;
3654
+ }
3655
+ function eventFromPlainObject(stackParser, exception, syntheticException, isUnhandledRejection) {
3656
+ const normalizeDepth = getClient()?.getOptions().normalizeDepth;
3657
+ const errorFromProp = getErrorPropertyFromObject(exception);
3658
+ const extra = { __serialized__: normalizeToSize(exception, normalizeDepth) };
3659
+ if (errorFromProp) return {
3660
+ exception: { values: [exceptionFromError(stackParser, errorFromProp)] },
3661
+ extra
3662
+ };
3663
+ const event = {
3664
+ exception: { values: [{
3665
+ type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? "UnhandledRejection" : "Error",
3666
+ value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection })
3667
+ }] },
3668
+ extra
3669
+ };
3670
+ if (syntheticException) {
3671
+ const frames = parseStackFrames(stackParser, syntheticException);
3672
+ if (frames.length) event.exception.values[0].stacktrace = { frames };
3673
+ }
3674
+ return event;
3675
+ }
3676
+ function eventFromError(stackParser, ex) {
3677
+ return { exception: { values: [exceptionFromError(stackParser, ex)] } };
3678
+ }
3679
+ /** Parses stack frames from an error */
3680
+ function parseStackFrames(stackParser, ex) {
3681
+ const stacktrace = ex.stacktrace || ex.stack || "";
3682
+ const skipLines = getSkipFirstStackStringLines(ex);
3683
+ const framesToPop = getPopFirstTopFrames(ex);
3684
+ try {
3685
+ return stackParser(stacktrace, skipLines, framesToPop);
3686
+ } catch {}
3687
+ return [];
3688
+ }
3689
+ const reactMinifiedRegexp = /Minified React error #\d+;/i;
3690
+ /**
3691
+ * Certain known React errors contain links that would be falsely
3692
+ * parsed as frames. This function check for these errors and
3693
+ * returns number of the stack string lines to skip.
3694
+ */
3695
+ function getSkipFirstStackStringLines(ex) {
3696
+ if (ex && reactMinifiedRegexp.test(ex.message)) return 1;
3697
+ return 0;
3698
+ }
3699
+ /**
3700
+ * If error has `framesToPop` property, it means that the
3701
+ * creator tells us the first x frames will be useless
3702
+ * and should be discarded. Typically error from wrapper function
3703
+ * which don't point to the actual location in the developer's code.
3704
+ *
3705
+ * Example: https://github.com/zertosh/invariant/blob/master/invariant.js#L46
3706
+ */
3707
+ function getPopFirstTopFrames(ex) {
3708
+ if (typeof ex.framesToPop === "number") return ex.framesToPop;
3709
+ return 0;
3710
+ }
3711
+ function isWebAssemblyException(exception) {
3712
+ if (typeof WebAssembly !== "undefined" && typeof WebAssembly.Exception !== "undefined") return exception instanceof WebAssembly.Exception;
3713
+ else return false;
3714
+ }
3715
+ /**
3716
+ * Extracts from errors what we use as the exception `type` in error events.
3717
+ *
3718
+ * Usually, this is the `name` property on Error objects but WASM errors need to be treated differently.
3719
+ */
3720
+ function extractType(ex) {
3721
+ const name = ex?.name;
3722
+ if (!name && isWebAssemblyException(ex)) return ex.message && Array.isArray(ex.message) && ex.message.length == 2 ? ex.message[0] : "WebAssembly.Exception";
3723
+ return name;
3724
+ }
3725
+ /**
3726
+ * There are cases where stacktrace.message is an Event object
3727
+ * https://github.com/getsentry/sentry-javascript/issues/1949
3728
+ * In this specific case we try to extract stacktrace.message.error.message
3729
+ */
3730
+ function extractMessage(ex) {
3731
+ const message = ex?.message;
3732
+ if (isWebAssemblyException(ex)) {
3733
+ if (Array.isArray(ex.message) && ex.message.length == 2) return ex.message[1];
3734
+ return "wasm exception";
3735
+ }
3736
+ if (!message) return "No error message";
3737
+ if (message.error && typeof message.error.message === "string") return message.error.message;
3738
+ return message;
3739
+ }
3740
+ /**
3741
+ * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
3742
+ * @hidden
3743
+ */
3744
+ function eventFromException(stackParser, exception, hint, attachStacktrace) {
3745
+ const event = eventFromUnknownInput(stackParser, exception, hint?.syntheticException || void 0, attachStacktrace);
3746
+ addExceptionMechanism(event);
3747
+ event.level = "error";
3748
+ if (hint?.event_id) event.event_id = hint.event_id;
3749
+ return resolvedSyncPromise(event);
3750
+ }
3751
+ /**
3752
+ * Builds and Event from a Message
3753
+ * @hidden
3754
+ */
3755
+ function eventFromMessage(stackParser, message, level = "info", hint, attachStacktrace) {
3756
+ const event = eventFromString(stackParser, message, hint?.syntheticException || void 0, attachStacktrace);
3757
+ event.level = level;
3758
+ if (hint?.event_id) event.event_id = hint.event_id;
3759
+ return resolvedSyncPromise(event);
3760
+ }
3761
+ /**
3762
+ * @hidden
3763
+ */
3764
+ function eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace, isUnhandledRejection) {
3765
+ let event;
3766
+ if (isErrorEvent$1(exception) && exception.error) return eventFromError(stackParser, exception.error);
3767
+ if (isDOMError(exception) || isDOMException(exception)) {
3768
+ const domException = exception;
3769
+ if ("stack" in exception) event = eventFromError(stackParser, exception);
3770
+ else {
3771
+ const name = domException.name || (isDOMError(domException) ? "DOMError" : "DOMException");
3772
+ const message = domException.message ? `${name}: ${domException.message}` : name;
3773
+ event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
3774
+ addExceptionTypeValue(event, message);
3775
+ }
3776
+ if ("code" in domException) event.tags = {
3777
+ ...event.tags,
3778
+ "DOMException.code": `${domException.code}`
3779
+ };
3780
+ return event;
3781
+ }
3782
+ if (isError(exception)) return eventFromError(stackParser, exception);
3783
+ if (isPlainObject(exception) || isEvent(exception)) {
3784
+ event = eventFromPlainObject(stackParser, exception, syntheticException, isUnhandledRejection);
3785
+ addExceptionMechanism(event, { synthetic: true });
3786
+ return event;
3787
+ }
3788
+ event = eventFromString(stackParser, exception, syntheticException, attachStacktrace);
3789
+ addExceptionTypeValue(event, `${exception}`, void 0);
3790
+ addExceptionMechanism(event, { synthetic: true });
3791
+ return event;
3792
+ }
3793
+ function eventFromString(stackParser, message, syntheticException, attachStacktrace) {
3794
+ const event = {};
3795
+ if (attachStacktrace && syntheticException) {
3796
+ const frames = parseStackFrames(stackParser, syntheticException);
3797
+ if (frames.length) event.exception = { values: [{
3798
+ value: message,
3799
+ stacktrace: { frames }
3800
+ }] };
3801
+ addExceptionMechanism(event, { synthetic: true });
3802
+ }
3803
+ if (isParameterizedString(message)) {
3804
+ const { __sentry_template_string__, __sentry_template_values__ } = message;
3805
+ event.logentry = {
3806
+ message: __sentry_template_string__,
3807
+ params: __sentry_template_values__
3808
+ };
3809
+ return event;
3810
+ }
3811
+ event.message = message;
3812
+ return event;
3813
+ }
3814
+ function getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }) {
3815
+ const keys = extractExceptionKeysForMessage(exception);
3816
+ const captureType = isUnhandledRejection ? "promise rejection" : "exception";
3817
+ if (isErrorEvent$1(exception)) return `Event \`ErrorEvent\` captured as ${captureType} with message \`${exception.message}\``;
3818
+ if (isEvent(exception)) return `Event \`${getObjectClassName(exception)}\` (type=${exception.type}) captured as ${captureType}`;
3819
+ return `Object captured as ${captureType} with keys: ${keys}`;
3820
+ }
3821
+ function getObjectClassName(obj) {
3822
+ try {
3823
+ const prototype = Object.getPrototypeOf(obj);
3824
+ return prototype ? prototype.constructor.name : void 0;
3825
+ } catch {}
3826
+ }
3827
+ /** If a plain object has a property that is an `Error`, return this error. */
3828
+ function getErrorPropertyFromObject(obj) {
3829
+ for (const prop in obj) if (Object.prototype.hasOwnProperty.call(obj, prop)) {
3830
+ const value = obj[prop];
3831
+ if (value instanceof Error) return value;
3832
+ }
3833
+ }
3834
+ //#endregion
3835
+ //#region ../../node_modules/.pnpm/@sentry+browser@9.47.1/node_modules/@sentry/browser/build/npm/esm/client.js
3836
+ /**
3837
+ * A magic string that build tooling can leverage in order to inject a release value into the SDK.
3838
+ */
3839
+ const DEFAULT_FLUSH_INTERVAL = 5e3;
3840
+ /**
3841
+ * The Sentry Browser SDK Client.
3842
+ *
3843
+ * @see BrowserOptions for documentation on configuration options.
3844
+ * @see SentryClient for usage documentation.
3845
+ */
3846
+ var BrowserClient = class extends Client {
3847
+ /**
3848
+ * Creates a new Browser SDK instance.
3849
+ *
3850
+ * @param options Configuration options for this SDK.
3851
+ */
3852
+ constructor(options) {
3853
+ const opts = applyDefaultOptions(options);
3854
+ applySdkMetadata(opts, "browser", ["browser"], WINDOW$1.SENTRY_SDK_SOURCE || getSDKSource());
3855
+ super(opts);
3856
+ const { sendDefaultPii, sendClientReports, enableLogs, _experiments } = this._options;
3857
+ const shouldEnableLogs = enableLogs ?? _experiments?.enableLogs;
3858
+ if (WINDOW$1.document && (sendClientReports || shouldEnableLogs)) WINDOW$1.document.addEventListener("visibilitychange", () => {
3859
+ if (WINDOW$1.document.visibilityState === "hidden") {
3860
+ if (sendClientReports) this._flushOutcomes();
3861
+ if (shouldEnableLogs) _INTERNAL_flushLogsBuffer(this);
3862
+ }
3863
+ });
3864
+ if (shouldEnableLogs) {
3865
+ this.on("flush", () => {
3866
+ _INTERNAL_flushLogsBuffer(this);
3867
+ });
3868
+ this.on("afterCaptureLog", () => {
3869
+ if (this._logFlushIdleTimeout) clearTimeout(this._logFlushIdleTimeout);
3870
+ this._logFlushIdleTimeout = setTimeout(() => {
3871
+ _INTERNAL_flushLogsBuffer(this);
3872
+ }, DEFAULT_FLUSH_INTERVAL);
3873
+ });
3874
+ }
3875
+ if (sendDefaultPii) {
3876
+ this.on("postprocessEvent", addAutoIpAddressToUser);
3877
+ this.on("beforeSendSession", addAutoIpAddressToSession);
3878
+ }
3879
+ }
3880
+ /**
3881
+ * @inheritDoc
3882
+ */
3883
+ eventFromException(exception, hint) {
3884
+ return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);
3885
+ }
3886
+ /**
3887
+ * @inheritDoc
3888
+ */
3889
+ eventFromMessage(message, level = "info", hint) {
3890
+ return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
3891
+ }
3892
+ /**
3893
+ * @inheritDoc
3894
+ */
3895
+ _prepareEvent(event, hint, currentScope, isolationScope) {
3896
+ event.platform = event.platform || "javascript";
3897
+ return super._prepareEvent(event, hint, currentScope, isolationScope);
3898
+ }
3899
+ };
3900
+ /** Exported only for tests. */
3901
+ function applyDefaultOptions(optionsArg) {
3902
+ return {
3903
+ release: typeof __SENTRY_RELEASE__ === "string" ? __SENTRY_RELEASE__ : WINDOW$1.SENTRY_RELEASE?.id,
3904
+ sendClientReports: true,
3905
+ parentSpanIsAlwaysRootSpan: true,
3906
+ ...optionsArg
3907
+ };
3908
+ }
3909
+ //#endregion
3910
+ //#region ../../node_modules/.pnpm/@sentry-internal+browser-utils@9.47.1/node_modules/@sentry-internal/browser-utils/build/esm/debug-build.js
3911
+ /**
3912
+ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
3913
+ *
3914
+ * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
3915
+ */
3916
+ const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
3917
+ //#endregion
3918
+ //#region ../../node_modules/.pnpm/@sentry-internal+browser-utils@9.47.1/node_modules/@sentry-internal/browser-utils/build/esm/types.js
3919
+ const WINDOW = GLOBAL_OBJ;
3920
+ //#endregion
3921
+ //#region ../../node_modules/.pnpm/@sentry-internal+browser-utils@9.47.1/node_modules/@sentry-internal/browser-utils/build/esm/getNativeImplementation.js
3922
+ /**
3923
+ * We generally want to use window.fetch / window.setTimeout.
3924
+ * However, in some cases this may be wrapped (e.g. by Zone.js for Angular),
3925
+ * so we try to get an unpatched version of this from a sandboxed iframe.
3926
+ */
3927
+ const cachedImplementations = {};
3928
+ /**
3929
+ * Get the native implementation of a browser function.
3930
+ *
3931
+ * This can be used to ensure we get an unwrapped version of a function, in cases where a wrapped function can lead to problems.
3932
+ *
3933
+ * The following methods can be retrieved:
3934
+ * - `setTimeout`: This can be wrapped by e.g. Angular, causing change detection to be triggered.
3935
+ * - `fetch`: This can be wrapped by e.g. ad-blockers, causing an infinite loop when a request is blocked.
3936
+ */
3937
+ function getNativeImplementation(name) {
3938
+ const cached = cachedImplementations[name];
3939
+ if (cached) return cached;
3940
+ let impl = WINDOW[name];
3941
+ if (isNativeFunction(impl)) return cachedImplementations[name] = impl.bind(WINDOW);
3942
+ const document = WINDOW.document;
3943
+ if (document && typeof document.createElement === "function") try {
3944
+ const sandbox = document.createElement("iframe");
3945
+ sandbox.hidden = true;
3946
+ document.head.appendChild(sandbox);
3947
+ const contentWindow = sandbox.contentWindow;
3948
+ if (contentWindow?.[name]) impl = contentWindow[name];
3949
+ document.head.removeChild(sandbox);
3950
+ } catch (e) {
3951
+ DEBUG_BUILD && debug.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);
3952
+ }
3953
+ if (!impl) return impl;
3954
+ return cachedImplementations[name] = impl.bind(WINDOW);
3955
+ }
3956
+ /** Clear a cached implementation. */
3957
+ function clearCachedImplementation(name) {
3958
+ cachedImplementations[name] = void 0;
3959
+ }
3960
+ //#endregion
3961
+ //#region ../../node_modules/.pnpm/@sentry+browser@9.47.1/node_modules/@sentry/browser/build/npm/esm/transports/fetch.js
3962
+ /**
3963
+ * Creates a Transport that uses the Fetch API to send events to Sentry.
3964
+ */
3965
+ function makeFetchTransport(options, nativeFetch = getNativeImplementation("fetch")) {
3966
+ let pendingBodySize = 0;
3967
+ let pendingCount = 0;
3968
+ function makeRequest(request) {
3969
+ const requestSize = request.body.length;
3970
+ pendingBodySize += requestSize;
3971
+ pendingCount++;
3972
+ const requestOptions = {
3973
+ body: request.body,
3974
+ method: "POST",
3975
+ referrerPolicy: "strict-origin",
3976
+ headers: options.headers,
3977
+ keepalive: pendingBodySize <= 6e4 && pendingCount < 15,
3978
+ ...options.fetchOptions
3979
+ };
3980
+ if (!nativeFetch) {
3981
+ clearCachedImplementation("fetch");
3982
+ return rejectedSyncPromise("No fetch implementation available");
3983
+ }
3984
+ try {
3985
+ return nativeFetch(options.url, requestOptions).then((response) => {
3986
+ pendingBodySize -= requestSize;
3987
+ pendingCount--;
3988
+ return {
3989
+ statusCode: response.status,
3990
+ headers: {
3991
+ "x-sentry-rate-limits": response.headers.get("X-Sentry-Rate-Limits"),
3992
+ "retry-after": response.headers.get("Retry-After")
3993
+ }
3994
+ };
3995
+ });
3996
+ } catch (e) {
3997
+ clearCachedImplementation("fetch");
3998
+ pendingBodySize -= requestSize;
3999
+ pendingCount--;
4000
+ return rejectedSyncPromise(e);
4001
+ }
4002
+ }
4003
+ return createTransport(options, makeRequest);
4004
+ }
4005
+ //#endregion
4006
+ //#region ../../node_modules/.pnpm/@sentry+browser@9.47.1/node_modules/@sentry/browser/build/npm/esm/stack-parsers.js
4007
+ const CHROME_PRIORITY = 30;
4008
+ const GECKO_PRIORITY = 50;
4009
+ function createFrame(filename, func, lineno, colno) {
4010
+ const frame = {
4011
+ filename,
4012
+ function: func === "<anonymous>" ? "?" : func,
4013
+ in_app: true
4014
+ };
4015
+ if (lineno !== void 0) frame.lineno = lineno;
4016
+ if (colno !== void 0) frame.colno = colno;
4017
+ return frame;
4018
+ }
4019
+ const chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
4020
+ const chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4021
+ const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4022
+ const chromeStackParserFn = (line) => {
4023
+ const noFnParts = chromeRegexNoFnName.exec(line);
4024
+ if (noFnParts) {
4025
+ const [, filename, line, col] = noFnParts;
4026
+ return createFrame(filename, "?", +line, +col);
4027
+ }
4028
+ const parts = chromeRegex.exec(line);
4029
+ if (parts) {
4030
+ if (parts[2] && parts[2].indexOf("eval") === 0) {
4031
+ const subMatch = chromeEvalRegex.exec(parts[2]);
4032
+ if (subMatch) {
4033
+ parts[2] = subMatch[1];
4034
+ parts[3] = subMatch[2];
4035
+ parts[4] = subMatch[3];
4036
+ }
4037
+ }
4038
+ const [func, filename] = extractSafariExtensionDetails(parts[1] || "?", parts[2]);
4039
+ return createFrame(filename, func, parts[3] ? +parts[3] : void 0, parts[4] ? +parts[4] : void 0);
4040
+ }
4041
+ };
4042
+ const chromeStackLineParser = [CHROME_PRIORITY, chromeStackParserFn];
4043
+ const geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4044
+ const geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4045
+ const gecko = (line) => {
4046
+ const parts = geckoREgex.exec(line);
4047
+ if (parts) {
4048
+ if (parts[3] && parts[3].indexOf(" > eval") > -1) {
4049
+ const subMatch = geckoEvalRegex.exec(parts[3]);
4050
+ if (subMatch) {
4051
+ parts[1] = parts[1] || "eval";
4052
+ parts[3] = subMatch[1];
4053
+ parts[4] = subMatch[2];
4054
+ parts[5] = "";
4055
+ }
4056
+ }
4057
+ let filename = parts[3];
4058
+ let func = parts[1] || "?";
4059
+ [func, filename] = extractSafariExtensionDetails(func, filename);
4060
+ return createFrame(filename, func, parts[4] ? +parts[4] : void 0, parts[5] ? +parts[5] : void 0);
4061
+ }
4062
+ };
4063
+ const defaultStackParser = createStackParser(...[chromeStackLineParser, [GECKO_PRIORITY, gecko]]);
4064
+ /**
4065
+ * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4066
+ * What it means, is that instead of format like:
4067
+ *
4068
+ * Error: wat
4069
+ * at function@url:row:col
4070
+ * at function@url:row:col
4071
+ * at function@url:row:col
4072
+ *
4073
+ * it produces something like:
4074
+ *
4075
+ * function@url:row:col
4076
+ * function@url:row:col
4077
+ * function@url:row:col
4078
+ *
4079
+ * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
4080
+ * This function is extracted so that we can use it in both places without duplicating the logic.
4081
+ * Unfortunately "just" changing RegExp is too complicated now and making it pass all tests
4082
+ * and fix this case seems like an impossible, or at least way too time-consuming task.
4083
+ */
4084
+ const extractSafariExtensionDetails = (func, filename) => {
4085
+ const isSafariExtension = func.indexOf("safari-extension") !== -1;
4086
+ const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
4087
+ return isSafariExtension || isSafariWebExtension ? [func.indexOf("@") !== -1 ? func.split("@")[0] : "?", isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`] : [func, filename];
4088
+ };
4089
+ //#endregion
4090
+ export { BrowserClient, defaultStackParser, makeFetchTransport };
4091
+
4092
+ //# sourceMappingURL=esm-DUNJOL6b.mjs.map