UNPKG

@wix/cli

Version:

CLI tool for building Wix sites and applications

1,565 lines (1,527 loc) 507 kB
import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url); import { BAGGAGE_HEADER_NAME, BaseClient, BrowserMetricsAggregator, DEFAULT_ENVIRONMENT, GLOBAL_OBJ, SDK_VERSION, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SPAN_STATUS_ERROR, Scope, SentryNonRecordingSpan, TRACING_DEFAULTS, UNKNOWN_FUNCTION, _nullishCoalesce, _optionalChain, addBreadcrumb, addConsoleInstrumentationHandler, addContextToFrame, addEventProcessor, addExceptionMechanism, addExceptionTypeValue, addFetchInstrumentationHandler, addGlobalErrorInstrumentationHandler, addGlobalUnhandledRejectionInstrumentationHandler, addHandler, addIntegration, addNonEnumerableProperty, addTracingExtensions, applyAggregateErrorsToEvent, applySdkMetadata, browserPerformanceTimeOrigin, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleSandbox, continueTrace, createEnvelope, createEventEnvelopeHeaders, createStackParser, createTransport, debugIntegration, dedupeIntegration, defineIntegration, dropUndefinedKeys, dsnToString, dynamicSamplingContextToSentryBaggageHeader, endSession, extraErrorDataIntegration, extractExceptionKeysForMessage, fill, flush, forEachEnvelopeItem, functionToStringIntegration, generatePropagationContext, generateSentryTraceHeader, getActiveSpan, getClient, getComponentName, getCurrentHub, getCurrentScope, getDomElement, getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan, getEventDescription, getFunctionName, getGlobalScope, getIntegrationsToSetup, getIsolationScope, getLocationHref, getOriginalFunction, getReportDialogEndpoint, getRootSpan, getSDKSource, getSdkMetadataForEnvelopeHeader, getSpanDescendants, getSpanStatusFromHttpCode, hasTracingEnabled, htmlTreeAsString, inboundFiltersIntegration, initAndBind, instrumentFetchRequest, isBrowser, isDOMError, isDOMException, isError, isErrorEvent, isEvent, isInitialized, isNativeFunction, isParameterizedString, isPlainObject, isPrimitive, isRateLimited, isSentryRequestUrl, isString, lastEventId, logger, makeMultiplexedTransport, makeOfflineTransport, markFunctionWrapped, maybeInstrument, metrics, moduleMetadataIntegration, normalize, normalizeToSize, parameterize, parseEnvelope, parseSampleRate, parseUrl, prepareEvent, propagationContextFromHeaders, registerSpanErrorInstrumentation, rejectedSyncPromise, resolvedSyncPromise, rewriteFramesIntegration, safeJoin, serializeEnvelope, sessionTimingIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, severityLevelFromString, spanIsSampled, spanToBaggageHeader, spanToJSON, spanToTraceHeader, stackParserFromStackParserOptions, startIdleSpan, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, stringMatchesSomePattern, stripUrlQueryAndFragment, supportsFetch, supportsHistory, supportsNativeFetch, supportsReportingObserver, thirdPartyErrorFilterIntegration, timestampInSeconds, triggerHandlers, updateRateLimits, uuid4, withActiveSpan, withIsolationScope, withScope, zodErrorsIntegration } from "./chunk-C5RTKQVL.js"; import { init_esm_shims } from "./chunk-EXLZF52D.js"; // ../../node_modules/@sentry/browser/build/npm/esm/index.js init_esm_shims(); // ../../node_modules/@sentry/browser/build/npm/esm/helpers.js init_esm_shims(); var WINDOW = GLOBAL_OBJ; var ignoreOnError = 0; function shouldIgnoreOnError() { return ignoreOnError > 0; } function ignoreNextOnError() { ignoreOnError++; setTimeout(() => { ignoreOnError--; }); } function wrap(fn, options = {}, before) { if (typeof fn !== "function") { return fn; } try { const wrapper = fn.__sentry_wrapped__; if (wrapper) { return wrapper; } if (getOriginalFunction(fn)) { return fn; } } catch (e3) { return fn; } const sentryWrapped = function() { const args = Array.prototype.slice.call(arguments); try { if (before && typeof before === "function") { before.apply(this, arguments); } const wrappedArguments = args.map((arg) => wrap(arg, options)); return fn.apply(this, wrappedArguments); } catch (ex) { ignoreNextOnError(); withScope((scope) => { scope.addEventProcessor((event) => { if (options.mechanism) { addExceptionTypeValue(event, void 0, void 0); addExceptionMechanism(event, options.mechanism); } event.extra = { ...event.extra, arguments: args }; return event; }); captureException(ex); }); throw ex; } }; try { for (const property in fn) { if (Object.prototype.hasOwnProperty.call(fn, property)) { sentryWrapped[property] = fn[property]; } } } catch (_oO) { } markFunctionWrapped(sentryWrapped, fn); addNonEnumerableProperty(fn, "__sentry_wrapped__", sentryWrapped); try { const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, "name"); if (descriptor.configurable) { Object.defineProperty(sentryWrapped, "name", { get() { return fn.name; } }); } } catch (_oO) { } return sentryWrapped; } // ../../node_modules/@sentry/browser/build/npm/esm/client.js init_esm_shims(); // ../../node_modules/@sentry/browser/build/npm/esm/debug-build.js init_esm_shims(); var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__; // ../../node_modules/@sentry/browser/build/npm/esm/eventbuilder.js init_esm_shims(); function exceptionFromError(stackParser, ex) { const frames = parseStackFrames(stackParser, ex); const exception = { type: ex && ex.name, value: extractMessage(ex) }; if (frames.length) { exception.stacktrace = { frames }; } if (exception.type === void 0 && exception.value === "") { exception.value = "Unrecoverable error caught"; } return exception; } function eventFromPlainObject(stackParser, exception, syntheticException, isUnhandledRejection) { const client = getClient(); const normalizeDepth = client && client.getOptions().normalizeDepth; const errorFromProp = getErrorPropertyFromObject(exception); const extra = { __serialized__: normalizeToSize(exception, normalizeDepth) }; if (errorFromProp) { return { exception: { values: [exceptionFromError(stackParser, errorFromProp)] }, extra }; } const event = { exception: { values: [ { type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? "UnhandledRejection" : "Error", value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }) } ] }, extra }; if (syntheticException) { const frames = parseStackFrames(stackParser, syntheticException); if (frames.length) { event.exception.values[0].stacktrace = { frames }; } } return event; } function eventFromError(stackParser, ex) { return { exception: { values: [exceptionFromError(stackParser, ex)] } }; } function parseStackFrames(stackParser, ex) { const stacktrace = ex.stacktrace || ex.stack || ""; const skipLines = getSkipFirstStackStringLines(ex); const framesToPop = getPopFirstTopFrames(ex); try { return stackParser(stacktrace, skipLines, framesToPop); } catch (e3) { } return []; } var reactMinifiedRegexp = /Minified React error #\d+;/i; function getSkipFirstStackStringLines(ex) { if (ex && reactMinifiedRegexp.test(ex.message)) { return 1; } return 0; } function getPopFirstTopFrames(ex) { if (typeof ex.framesToPop === "number") { return ex.framesToPop; } return 0; } function extractMessage(ex) { const message = ex && ex.message; if (!message) { return "No error message"; } if (message.error && typeof message.error.message === "string") { return message.error.message; } return message; } function eventFromException(stackParser, exception, hint, attachStacktrace) { const syntheticException = hint && hint.syntheticException || void 0; const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace); addExceptionMechanism(event); event.level = "error"; if (hint && hint.event_id) { event.event_id = hint.event_id; } return resolvedSyncPromise(event); } function eventFromMessage(stackParser, message, level = "info", hint, attachStacktrace) { const syntheticException = hint && hint.syntheticException || void 0; const event = eventFromString(stackParser, message, syntheticException, attachStacktrace); event.level = level; if (hint && hint.event_id) { event.event_id = hint.event_id; } return resolvedSyncPromise(event); } function eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace, isUnhandledRejection) { let event; if (isErrorEvent(exception) && exception.error) { const errorEvent = exception; return eventFromError(stackParser, errorEvent.error); } if (isDOMError(exception) || isDOMException(exception)) { const domException = exception; if ("stack" in exception) { event = eventFromError(stackParser, exception); } else { const name = domException.name || (isDOMError(domException) ? "DOMError" : "DOMException"); const message = domException.message ? `${name}: ${domException.message}` : name; event = eventFromString(stackParser, message, syntheticException, attachStacktrace); addExceptionTypeValue(event, message); } if ("code" in domException) { event.tags = { ...event.tags, "DOMException.code": `${domException.code}` }; } return event; } if (isError(exception)) { return eventFromError(stackParser, exception); } if (isPlainObject(exception) || isEvent(exception)) { const objectException = exception; event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection); addExceptionMechanism(event, { synthetic: true }); return event; } event = eventFromString(stackParser, exception, syntheticException, attachStacktrace); addExceptionTypeValue(event, `${exception}`, void 0); addExceptionMechanism(event, { synthetic: true }); return event; } function eventFromString(stackParser, message, syntheticException, attachStacktrace) { const event = {}; if (attachStacktrace && syntheticException) { const frames = parseStackFrames(stackParser, syntheticException); if (frames.length) { event.exception = { values: [{ value: message, stacktrace: { frames } }] }; } } if (isParameterizedString(message)) { const { __sentry_template_string__, __sentry_template_values__ } = message; event.logentry = { message: __sentry_template_string__, params: __sentry_template_values__ }; return event; } event.message = message; return event; } function getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }) { const keys2 = extractExceptionKeysForMessage(exception); const captureType = isUnhandledRejection ? "promise rejection" : "exception"; if (isErrorEvent(exception)) { return `Event \`ErrorEvent\` captured as ${captureType} with message \`${exception.message}\``; } if (isEvent(exception)) { const className = getObjectClassName(exception); return `Event \`${className}\` (type=${exception.type}) captured as ${captureType}`; } return `Object captured as ${captureType} with keys: ${keys2}`; } function getObjectClassName(obj) { try { const prototype = Object.getPrototypeOf(obj); return prototype ? prototype.constructor.name : void 0; } catch (e3) { } } function getErrorPropertyFromObject(obj) { for (const prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { const value = obj[prop]; if (value instanceof Error) { return value; } } } return void 0; } // ../../node_modules/@sentry/browser/build/npm/esm/userfeedback.js init_esm_shims(); function createUserFeedbackEnvelope(feedback, { metadata, tunnel, dsn }) { const headers = { event_id: feedback.event_id, sent_at: (/* @__PURE__ */ new Date()).toISOString(), ...metadata && metadata.sdk && { sdk: { name: metadata.sdk.name, version: metadata.sdk.version } }, ...!!tunnel && !!dsn && { dsn: dsnToString(dsn) } }; const item = createUserFeedbackEnvelopeItem(feedback); return createEnvelope(headers, [item]); } function createUserFeedbackEnvelopeItem(feedback) { const feedbackHeaders = { type: "user_report" }; return [feedbackHeaders, feedback]; } // ../../node_modules/@sentry/browser/build/npm/esm/client.js var BrowserClient = class extends BaseClient { /** * Creates a new Browser SDK instance. * * @param options Configuration options for this SDK. */ constructor(options) { const opts = { // We default this to true, as it is the safer scenario parentSpanIsAlwaysRootSpan: true, ...options }; const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource(); applySdkMetadata(opts, "browser", ["browser"], sdkSource); super(opts); if (opts.sendClientReports && WINDOW.document) { WINDOW.document.addEventListener("visibilitychange", () => { if (WINDOW.document.visibilityState === "hidden") { this._flushOutcomes(); } }); } } /** * @inheritDoc */ eventFromException(exception, hint) { return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace); } /** * @inheritDoc */ eventFromMessage(message, level = "info", hint) { return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace); } /** * Sends user feedback to Sentry. * * @deprecated Use `captureFeedback` instead. */ captureUserFeedback(feedback) { if (!this._isEnabled()) { DEBUG_BUILD && logger.warn("SDK not enabled, will not capture user feedback."); return; } const envelope = createUserFeedbackEnvelope(feedback, { metadata: this.getSdkMetadata(), dsn: this.getDsn(), tunnel: this.getOptions().tunnel }); this.sendEnvelope(envelope); } /** * @inheritDoc */ _prepareEvent(event, hint, scope) { event.platform = event.platform || "javascript"; return super._prepareEvent(event, hint, scope); } }; // ../../node_modules/@sentry/browser/build/npm/esm/transports/fetch.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/index.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/instrument.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/debug-build.js init_esm_shims(); var DEBUG_BUILD2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getCLS.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/bindReporter.js init_esm_shims(); var getRating = (value, thresholds) => { if (value > thresholds[1]) { return "poor"; } if (value > thresholds[0]) { return "needs-improvement"; } return "good"; }; var bindReporter = (callback, metric, thresholds, reportAllChanges) => { let prevValue; let delta; return (forceReport) => { if (metric.value >= 0) { if (forceReport || reportAllChanges) { delta = metric.value - (prevValue || 0); if (delta || prevValue === void 0) { prevValue = metric.value; metric.delta = delta; metric.rating = getRating(metric.value, thresholds); callback(metric); } } } }; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/initMetric.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/types.js init_esm_shims(); var WINDOW2 = GLOBAL_OBJ; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/generateUniqueID.js init_esm_shims(); var generateUniqueID = () => { return `v3-${Date.now()}-${Math.floor(Math.random() * (9e12 - 1)) + 1e12}`; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getActivationStart.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getNavigationEntry.js init_esm_shims(); var getNavigationEntry = () => { return WINDOW2.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0]; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getActivationStart.js var getActivationStart = () => { const navEntry = getNavigationEntry(); return navEntry && navEntry.activationStart || 0; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/initMetric.js var initMetric = (name, value) => { const navEntry = getNavigationEntry(); let navigationType = "navigate"; if (navEntry) { if (WINDOW2.document && WINDOW2.document.prerendering || getActivationStart() > 0) { navigationType = "prerender"; } else if (WINDOW2.document && WINDOW2.document.wasDiscarded) { navigationType = "restore"; } else if (navEntry.type) { navigationType = navEntry.type.replace(/_/g, "-"); } } const entries = []; return { name, value: typeof value === "undefined" ? -1 : value, rating: "good", // If needed, will be updated when reported. `const` to keep the type from widening to `string`. delta: 0, entries, id: generateUniqueID(), navigationType }; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/observe.js init_esm_shims(); var observe = (type, callback, opts) => { try { if (PerformanceObserver.supportedEntryTypes.includes(type)) { const po2 = new PerformanceObserver((list) => { Promise.resolve().then(() => { callback(list.getEntries()); }); }); po2.observe( Object.assign( { type, buffered: true }, opts || {} ) ); return po2; } } catch (e3) { } return; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/onHidden.js init_esm_shims(); var onHidden = (cb) => { const onHiddenOrPageHide = (event) => { if (event.type === "pagehide" || WINDOW2.document && WINDOW2.document.visibilityState === "hidden") { cb(event); } }; if (WINDOW2.document) { addEventListener("visibilitychange", onHiddenOrPageHide, true); addEventListener("pagehide", onHiddenOrPageHide, true); } }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/runOnce.js init_esm_shims(); var runOnce = (cb) => { let called = false; return (arg) => { if (!called) { cb(arg); called = true; } }; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/onFCP.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js init_esm_shims(); var firstHiddenTime = -1; var initHiddenTime = () => { firstHiddenTime = WINDOW2.document.visibilityState === "hidden" && !WINDOW2.document.prerendering ? 0 : Infinity; }; var onVisibilityUpdate = (event) => { if (WINDOW2.document.visibilityState === "hidden" && firstHiddenTime > -1) { firstHiddenTime = event.type === "visibilitychange" ? event.timeStamp : 0; removeEventListener("visibilitychange", onVisibilityUpdate, true); removeEventListener("prerenderingchange", onVisibilityUpdate, true); } }; var addChangeListeners = () => { addEventListener("visibilitychange", onVisibilityUpdate, true); addEventListener("prerenderingchange", onVisibilityUpdate, true); }; var getVisibilityWatcher = () => { if (WINDOW2.document && firstHiddenTime < 0) { initHiddenTime(); addChangeListeners(); } return { get firstHiddenTime() { return firstHiddenTime; } }; }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/whenActivated.js init_esm_shims(); var whenActivated = (callback) => { if (WINDOW2.document && WINDOW2.document.prerendering) { addEventListener("prerenderingchange", () => callback(), true); } else { callback(); } }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/onFCP.js var FCPThresholds = [1800, 3e3]; var onFCP = (onReport, opts = {}) => { whenActivated(() => { const visibilityWatcher = getVisibilityWatcher(); const metric = initMetric("FCP"); let report; const handleEntries = (entries) => { entries.forEach((entry) => { if (entry.name === "first-contentful-paint") { po2.disconnect(); if (entry.startTime < visibilityWatcher.firstHiddenTime) { metric.value = Math.max(entry.startTime - getActivationStart(), 0); metric.entries.push(entry); report(true); } } }); }; const po2 = observe("paint", handleEntries); if (po2) { report = bindReporter(onReport, metric, FCPThresholds, opts.reportAllChanges); } }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getCLS.js var CLSThresholds = [0.1, 0.25]; var onCLS = (onReport, opts = {}) => { onFCP( runOnce(() => { const metric = initMetric("CLS", 0); let report; let sessionValue = 0; let sessionEntries = []; const handleEntries = (entries) => { entries.forEach((entry) => { if (!entry.hadRecentInput) { const firstSessionEntry = sessionEntries[0]; const lastSessionEntry = sessionEntries[sessionEntries.length - 1]; if (sessionValue && firstSessionEntry && lastSessionEntry && entry.startTime - lastSessionEntry.startTime < 1e3 && entry.startTime - firstSessionEntry.startTime < 5e3) { sessionValue += entry.value; sessionEntries.push(entry); } else { sessionValue = entry.value; sessionEntries = [entry]; } } }); if (sessionValue > metric.value) { metric.value = sessionValue; metric.entries = sessionEntries; report(); } }; const po2 = observe("layout-shift", handleEntries); if (po2) { report = bindReporter(onReport, metric, CLSThresholds, opts.reportAllChanges); onHidden(() => { handleEntries(po2.takeRecords()); report(true); }); setTimeout(report, 0); } }) ); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getFID.js init_esm_shims(); var FIDThresholds = [100, 300]; var onFID = (onReport, opts = {}) => { whenActivated(() => { const visibilityWatcher = getVisibilityWatcher(); const metric = initMetric("FID"); let report; const handleEntry = (entry) => { if (entry.startTime < visibilityWatcher.firstHiddenTime) { metric.value = entry.processingStart - entry.startTime; metric.entries.push(entry); report(true); } }; const handleEntries = (entries) => { entries.forEach(handleEntry); }; const po2 = observe("first-input", handleEntries); report = bindReporter(onReport, metric, FIDThresholds, opts.reportAllChanges); if (po2) { onHidden( runOnce(() => { handleEntries(po2.takeRecords()); po2.disconnect(); }) ); } }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getINP.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js init_esm_shims(); var interactionCountEstimate = 0; var minKnownInteractionId = Infinity; var maxKnownInteractionId = 0; var updateEstimate = (entries) => { entries.forEach((e3) => { if (e3.interactionId) { minKnownInteractionId = Math.min(minKnownInteractionId, e3.interactionId); maxKnownInteractionId = Math.max(maxKnownInteractionId, e3.interactionId); interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0; } }); }; var po; var getInteractionCount = () => { return po ? interactionCountEstimate : performance.interactionCount || 0; }; var initInteractionCountPolyfill = () => { if ("interactionCount" in performance || po) return; po = observe("event", updateEstimate, { type: "event", buffered: true, durationThreshold: 0 }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getINP.js var INPThresholds = [200, 500]; var prevInteractionCount = 0; var getInteractionCountForNavigation = () => { return getInteractionCount() - prevInteractionCount; }; var MAX_INTERACTIONS_TO_CONSIDER = 10; var longestInteractionList = []; var longestInteractionMap = {}; var processEntry = (entry) => { const minLongestInteraction = longestInteractionList[longestInteractionList.length - 1]; const existingInteraction = longestInteractionMap[entry.interactionId]; if (existingInteraction || longestInteractionList.length < MAX_INTERACTIONS_TO_CONSIDER || minLongestInteraction && entry.duration > minLongestInteraction.latency) { if (existingInteraction) { existingInteraction.entries.push(entry); existingInteraction.latency = Math.max(existingInteraction.latency, entry.duration); } else { const interaction = { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion id: entry.interactionId, latency: entry.duration, entries: [entry] }; longestInteractionMap[interaction.id] = interaction; longestInteractionList.push(interaction); } longestInteractionList.sort((a2, b2) => b2.latency - a2.latency); longestInteractionList.splice(MAX_INTERACTIONS_TO_CONSIDER).forEach((i2) => { delete longestInteractionMap[i2.id]; }); } }; var estimateP98LongestInteraction = () => { const candidateInteractionIndex = Math.min( longestInteractionList.length - 1, Math.floor(getInteractionCountForNavigation() / 50) ); return longestInteractionList[candidateInteractionIndex]; }; var onINP = (onReport, opts = {}) => { whenActivated(() => { initInteractionCountPolyfill(); const metric = initMetric("INP"); let report; const handleEntries = (entries) => { entries.forEach((entry) => { if (entry.interactionId) { processEntry(entry); } if (entry.entryType === "first-input") { const noMatchingEntry = !longestInteractionList.some((interaction) => { return interaction.entries.some((prevEntry) => { return entry.duration === prevEntry.duration && entry.startTime === prevEntry.startTime; }); }); if (noMatchingEntry) { processEntry(entry); } } }); const inp = estimateP98LongestInteraction(); if (inp && inp.latency !== metric.value) { metric.value = inp.latency; metric.entries = inp.entries; report(); } }; const po2 = observe("event", handleEntries, { // Event Timing entries have their durations rounded to the nearest 8ms, // so a duration of 40ms would be any event that spans 2.5 or more frames // at 60Hz. This threshold is chosen to strike a balance between usefulness // and performance. Running this callback for any interaction that spans // just one or two frames is likely not worth the insight that could be // gained. durationThreshold: opts.durationThreshold != null ? opts.durationThreshold : 40 }); report = bindReporter(onReport, metric, INPThresholds, opts.reportAllChanges); if (po2) { if ("PerformanceEventTiming" in WINDOW2 && "interactionId" in PerformanceEventTiming.prototype) { po2.observe({ type: "first-input", buffered: true }); } onHidden(() => { handleEntries(po2.takeRecords()); if (metric.value < 0 && getInteractionCountForNavigation() > 0) { metric.value = 0; metric.entries = []; } report(true); }); } }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getLCP.js init_esm_shims(); var LCPThresholds = [2500, 4e3]; var reportedMetricIDs = {}; var onLCP = (onReport, opts = {}) => { whenActivated(() => { const visibilityWatcher = getVisibilityWatcher(); const metric = initMetric("LCP"); let report; const handleEntries = (entries) => { const lastEntry = entries[entries.length - 1]; if (lastEntry) { if (lastEntry.startTime < visibilityWatcher.firstHiddenTime) { metric.value = Math.max(lastEntry.startTime - getActivationStart(), 0); metric.entries = [lastEntry]; report(); } } }; const po2 = observe("largest-contentful-paint", handleEntries); if (po2) { report = bindReporter(onReport, metric, LCPThresholds, opts.reportAllChanges); const stopListening = runOnce(() => { if (!reportedMetricIDs[metric.id]) { handleEntries(po2.takeRecords()); po2.disconnect(); reportedMetricIDs[metric.id] = true; report(true); } }); ["keydown", "click"].forEach((type) => { if (WINDOW2.document) { addEventListener(type, () => setTimeout(stopListening, 0), true); } }); onHidden(stopListening); } }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/onTTFB.js init_esm_shims(); var TTFBThresholds = [800, 1800]; var whenReady = (callback) => { if (WINDOW2.document && WINDOW2.document.prerendering) { whenActivated(() => whenReady(callback)); } else if (WINDOW2.document && WINDOW2.document.readyState !== "complete") { addEventListener("load", () => whenReady(callback), true); } else { setTimeout(callback, 0); } }; var onTTFB = (onReport, opts = {}) => { const metric = initMetric("TTFB"); const report = bindReporter(onReport, metric, TTFBThresholds, opts.reportAllChanges); whenReady(() => { const navEntry = getNavigationEntry(); if (navEntry) { const responseStart = navEntry.responseStart; if (responseStart <= 0 || responseStart > performance.now()) return; metric.value = Math.max(responseStart - getActivationStart(), 0); metric.entries = [navEntry]; report(true); } }); }; // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/instrument.js var handlers = {}; var instrumented = {}; var _previousCls; var _previousFid; var _previousLcp; var _previousTtfb; var _previousInp; function addClsInstrumentationHandler(callback, stopOnCallback = false) { return addMetricObserver("cls", callback, instrumentCls, _previousCls, stopOnCallback); } function addLcpInstrumentationHandler(callback, stopOnCallback = false) { return addMetricObserver("lcp", callback, instrumentLcp, _previousLcp, stopOnCallback); } function addFidInstrumentationHandler(callback) { return addMetricObserver("fid", callback, instrumentFid, _previousFid); } function addTtfbInstrumentationHandler(callback) { return addMetricObserver("ttfb", callback, instrumentTtfb, _previousTtfb); } function addInpInstrumentationHandler(callback) { return addMetricObserver("inp", callback, instrumentInp, _previousInp); } function addPerformanceInstrumentationHandler(type, callback) { addHandler2(type, callback); if (!instrumented[type]) { instrumentPerformanceObserver(type); instrumented[type] = true; } return getCleanupCallback(type, callback); } function triggerHandlers2(type, data) { const typeHandlers = handlers[type]; if (!typeHandlers || !typeHandlers.length) { return; } for (const handler of typeHandlers) { try { handler(data); } catch (e3) { DEBUG_BUILD2 && logger.error( `Error while triggering instrumentation handler. Type: ${type} Name: ${getFunctionName(handler)} Error:`, e3 ); } } } function instrumentCls() { return onCLS( (metric) => { triggerHandlers2("cls", { metric }); _previousCls = metric; }, // We want the callback to be called whenever the CLS value updates. // By default, the callback is only called when the tab goes to the background. { reportAllChanges: true } ); } function instrumentFid() { return onFID((metric) => { triggerHandlers2("fid", { metric }); _previousFid = metric; }); } function instrumentLcp() { return onLCP( (metric) => { triggerHandlers2("lcp", { metric }); _previousLcp = metric; }, // We want the callback to be called whenever the LCP value updates. // By default, the callback is only called when the tab goes to the background. { reportAllChanges: true } ); } function instrumentTtfb() { return onTTFB((metric) => { triggerHandlers2("ttfb", { metric }); _previousTtfb = metric; }); } function instrumentInp() { return onINP((metric) => { triggerHandlers2("inp", { metric }); _previousInp = metric; }); } function addMetricObserver(type, callback, instrumentFn, previousValue, stopOnCallback = false) { addHandler2(type, callback); let stopListening; if (!instrumented[type]) { stopListening = instrumentFn(); instrumented[type] = true; } if (previousValue) { callback({ metric: previousValue }); } return getCleanupCallback(type, callback, stopOnCallback ? stopListening : void 0); } function instrumentPerformanceObserver(type) { const options = {}; if (type === "event") { options.durationThreshold = 0; } observe( type, (entries) => { triggerHandlers2(type, { entries }); }, options ); } function addHandler2(type, handler) { handlers[type] = handlers[type] || []; handlers[type].push(handler); } function getCleanupCallback(type, callback, stopListening) { return () => { if (stopListening) { stopListening(); } const typeHandlers = handlers[type]; if (!typeHandlers) { return; } const index = typeHandlers.indexOf(callback); if (index !== -1) { typeHandlers.splice(index, 1); } }; } function isPerformanceEventTiming(entry) { return "duration" in entry; } // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/browserMetrics.js init_esm_shims(); // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/utils.js init_esm_shims(); function isMeasurementValue(value) { return typeof value === "number" && isFinite(value); } function startAndEndSpan(parentSpan, startTimeInSeconds, endTime, { ...ctx }) { const parentStartTime = spanToJSON(parentSpan).start_timestamp; if (parentStartTime && parentStartTime > startTimeInSeconds) { if (typeof parentSpan.updateStartTime === "function") { parentSpan.updateStartTime(startTimeInSeconds); } } return withActiveSpan(parentSpan, () => { const span = startInactiveSpan({ startTime: startTimeInSeconds, ...ctx }); if (span) { span.end(endTime); } return span; }); } function getBrowserPerformanceAPI() { return WINDOW2 && WINDOW2.addEventListener && WINDOW2.performance; } function msToSec(time) { return time / 1e3; } // ../../node_modules/@sentry-internal/browser-utils/build/esm/metrics/browserMetrics.js var MAX_INT_AS_BYTES = 2147483647; var _performanceCursor = 0; var _measurements = {}; var _lcpEntry; var _clsEntry; function startTrackingWebVitals() { const performance2 = getBrowserPerformanceAPI(); if (performance2 && browserPerformanceTimeOrigin) { if (performance2.mark) { WINDOW2.performance.mark("sentry-tracing-init"); } const fidCallback = _trackFID(); const clsCallback = _trackCLS(); const lcpCallback = _trackLCP(); const ttfbCallback = _trackTtfb(); return () => { fidCallback(); clsCallback(); lcpCallback(); ttfbCallback(); }; } return () => void 0; } function startTrackingLongTasks() { addPerformanceInstrumentationHandler("longtask", ({ entries }) => { for (const entry of entries) { if (!getActiveSpan()) { return; } const startTime = msToSec(browserPerformanceTimeOrigin + entry.startTime); const duration = msToSec(entry.duration); const span = startInactiveSpan({ name: "Main UI thread blocked", op: "ui.long-task", startTime, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }); if (span) { span.end(startTime + duration); } } }); } function startTrackingLongAnimationFrames() { const observer = new PerformanceObserver((list) => { for (const entry of list.getEntries()) { if (!getActiveSpan()) { return; } if (!entry.scripts[0]) { return; } const startTime = msToSec(browserPerformanceTimeOrigin + entry.startTime); const duration = msToSec(entry.duration); const attributes = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" }; const initialScript = entry.scripts[0]; if (initialScript) { const { invoker, invokerType, sourceURL, sourceFunctionName, sourceCharPosition } = initialScript; attributes["browser.script.invoker"] = invoker; attributes["browser.script.invoker_type"] = invokerType; if (sourceURL) { attributes["code.filepath"] = sourceURL; } if (sourceFunctionName) { attributes["code.function"] = sourceFunctionName; } if (sourceCharPosition !== -1) { attributes["browser.script.source_char_position"] = sourceCharPosition; } } const span = startInactiveSpan({ name: "Main UI thread blocked", op: "ui.long-animation-frame", startTime, attributes }); if (span) { span.end(startTime + duration); } } }); observer.observe({ type: "long-animation-frame", buffered: true }); } function startTrackingInteractions() { addPerformanceInstrumentationHandler("event", ({ entries }) => { for (const entry of entries) { if (!getActiveSpan()) { return; } if (entry.name === "click") { const startTime = msToSec(browserPerformanceTimeOrigin + entry.startTime); const duration = msToSec(entry.duration); const spanOptions = { name: htmlTreeAsString(entry.target), op: `ui.interaction.${entry.name}`, startTime, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }; const componentName = getComponentName(entry.target); if (componentName) { spanOptions.attributes["ui.component_name"] = componentName; } const span = startInactiveSpan(spanOptions); if (span) { span.end(startTime + duration); } } } }); } function _trackCLS() { return addClsInstrumentationHandler(({ metric }) => { const entry = metric.entries[metric.entries.length - 1]; if (!entry) { return; } DEBUG_BUILD2 && logger.log("[Measurements] Adding CLS"); _measurements["cls"] = { value: metric.value, unit: "" }; _clsEntry = entry; }, true); } function _trackLCP() { return addLcpInstrumentationHandler(({ metric }) => { const entry = metric.entries[metric.entries.length - 1]; if (!entry) { return; } DEBUG_BUILD2 && logger.log("[Measurements] Adding LCP"); _measurements["lcp"] = { value: metric.value, unit: "millisecond" }; _lcpEntry = entry; }, true); } function _trackFID() { return addFidInstrumentationHandler(({ metric }) => { const entry = metric.entries[metric.entries.length - 1]; if (!entry) { return; } const timeOrigin = msToSec(browserPerformanceTimeOrigin); const startTime = msToSec(entry.startTime); DEBUG_BUILD2 && logger.log("[Measurements] Adding FID"); _measurements["fid"] = { value: metric.value, unit: "millisecond" }; _measurements["mark.fid"] = { value: timeOrigin + startTime, unit: "second" }; }); } function _trackTtfb() { return addTtfbInstrumentationHandler(({ metric }) => { const entry = metric.entries[metric.entries.length - 1]; if (!entry) { return; } DEBUG_BUILD2 && logger.log("[Measurements] Adding TTFB"); _measurements["ttfb"] = { value: metric.value, unit: "millisecond" }; }); } function addPerformanceEntries(span) { const performance2 = getBrowserPerformanceAPI(); if (!performance2 || !WINDOW2.performance.getEntries || !browserPerformanceTimeOrigin) { return; } DEBUG_BUILD2 && logger.log("[Tracing] Adding & adjusting spans using Performance API"); const timeOrigin = msToSec(browserPerformanceTimeOrigin); const performanceEntries = performance2.getEntries(); const { op, start_timestamp: transactionStartTime } = spanToJSON(span); performanceEntries.slice(_performanceCursor).forEach((entry) => { const startTime = msToSec(entry.startTime); const duration = msToSec( // Inexplicibly, Chrome sometimes emits a negative duration. We need to work around this. // There is a SO post attempting to explain this, but it leaves one with open questions: https://stackoverflow.com/questions/23191918/peformance-getentries-and-negative-duration-display // The way we clamp the value is probably not accurate, since we have observed this happen for things that may take a while to load, like for example the replay worker. // TODO: Investigate why this happens and how to properly mitigate. For now, this is a workaround to prevent transactions being dropped due to negative duration spans. Math.max(0, entry.duration) ); if (op === "navigation" && transactionStartTime && timeOrigin + startTime < transactionStartTime) { return; } switch (entry.entryType) { case "navigation": { _addNavigationSpans(span, entry, timeOrigin); break; } case "mark": case "paint": case "measure": { _addMeasureSpans(span, entry, startTime, duration, timeOrigin); const firstHidden = getVisibilityWatcher(); const shouldRecord = entry.startTime < firstHidden.firstHiddenTime; if (entry.name === "first-paint" && shouldRecord) { DEBUG_BUILD2 && logger.log("[Measurements] Adding FP"); _measurements["fp"] = { value: entry.startTime, unit: "millisecond" }; } if (entry.name === "first-contentful-paint" && shouldRecord) { DEBUG_BUILD2 && logger.log("[Measurements] Adding FCP"); _measurements["fcp"] = { value: entry.startTime, unit: "millisecond" }; } break; } case "resource": { _addResourceSpans(span, entry, entry.name, startTime, duration, timeOrigin); break; } } }); _performanceCursor = Math.max(performanceEntries.length - 1, 0); _trackNavigator(span); if (op === "pageload") { _addTtfbRequestTimeToMeasurements(_measurements); ["fcp", "fp", "lcp"].forEach((name) => { const measurement = _measurements[name]; if (!measurement || !transactionStartTime || timeOrigin >= transactionStartTime) { return; } const oldValue = measurement.value; const measurementTimestamp = timeOrigin + msToSec(oldValue); const normalizedValue = Math.abs((measurementTimestamp - transactionStartTime) * 1e3); const delta = normalizedValue - oldValue; DEBUG_BUILD2 && logger.log(`[Measurements] Normalized ${name} from ${oldValue} to ${normalizedValue} (${delta})`); measurement.value = normalizedValue; }); const fidMark = _measurements["mark.fid"]; if (fidMark && _measurements["fid"]) { startAndEndSpan(span, fidMark.value, fidMark.value + msToSec(_measurements["fid"].value), { name: "first input delay", op: "ui.action", attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }); delete _measurements["mark.fid"]; } if (!("fcp" in _measurements)) { delete _measurements.cls; } Object.entries(_measurements).forEach(([measurementName, measurement]) => { setMeasurement(measurementName, measurement.value, measurement.unit); }); _tagMetricInfo(span); } _lcpEntry = void 0; _clsEntry = void 0; _measurements = {}; } function _addMeasureSpans(span, entry, startTime, duration, timeOrigin) { const navEntry = getNavigationEntry(); const requestTime = msToSec(navEntry ? navEntry.requestStart : 0); const measureStartTimestamp = timeOrigin + Math.max(startTime, requestTime); const startTimeStamp = timeOrigin + startTime; const measureEndTimestamp = startTimeStamp + duration; const attributes = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.resource.browser.metrics" }; if (measureStartTimestamp !== startTimeStamp) { attributes["sentry.browser.measure_happened_before_request"] = true; attributes["sentry.browser.measure_start_time"] = measureStartTimestamp; } startAndEndSpan(span, measureStartTimestamp, measureEndTimestamp, { name: entry.name, op: entry.entryType, attributes }); return measureStartTimestamp; } function _addNavigationSpans(span, entry, timeOrigin) { ["unloadEvent", "redirect", "domContentLoadedEvent", "loadEvent", "connect"].forEach((event) => { _addPerformanceNavigationTiming(span, entry, event, timeOrigin); }); _addPerformanceNavigationTiming(span, entry, "secureConnection", timeOrigin, "TLS/SSL", "connectEnd"); _addPerformanceNavigationTiming(span, entry, "fetch", timeOrigin, "cache", "domainLookupStart"); _addPerformanceNavigationTiming(span, entry, "domainLookup", timeOrigin, "DNS"); _addRequest(span, entry, timeOrigin); } function _addPerformanceNavigationTiming(span, entry, event, timeOrigin, name, eventEnd) { const end = eventEnd ? entry[eventEnd] : entry[`${event}End`]; const start = entry[`${event}Start`]; if (!start || !end) { return; } startAndEndSpan(span, timeOrigin + msToSec(start), timeOrigin + msToSec(end), { op: "browser", name: name || event, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }); } function _addRequest(span, entry, timeOrigin) { const requestStartTimestamp = timeOrigin + msToSec(entry.requestStart); const responseEndTimestamp = timeOrigin + msToSec(entry.responseEnd); const responseStartTimestamp = timeOrigin + msToSec(entry.responseStart); if (entry.responseEnd) { startAndEndSpan(span, requestStartTimestamp, responseEndTimestamp, { op: "browser", name: "request", attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }); startAndEndSpan(span, responseStartTimestamp, responseEndTimestamp, { op: "browser", name: "response", attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.browser.metrics" } }); } } function _addResourceSpans(span, entry, resourceUrl, startTime, duration, timeOrigin) { if (entry.initiatorType === "xmlhttprequest" || entry.initiatorType === "fetch") { return; } const parsedUrl = parseUrl(resourceUrl); const attributes = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.resource.browser.metrics" }; setResourceEntrySizeData(attributes, entry, "transferSize", "http.response_transfer_size"); setResourceEntrySizeData(attributes, entry, "encodedBodySize", "http.response_content_length"); setResourceEntrySizeData(attributes, entry, "decodedBodySize", "http.decoded_response_content_length"); if ("renderBlockingStatus" in entry) { attributes["resource.render_blocking_status"] = entry.renderBlockingStatus; } if (parsedUrl.protocol) { attributes["url.scheme"] = parsedUrl.protocol.split(":").pop(); } if (parsedUrl.host) { attributes["server.address"] = parsedUrl.host; } attributes["url.same_origin"] = resourceUrl.includes(WINDOW2.location.origin); const startTimestamp = timeOrigin + startTime; const endTimestamp = startTimestamp + duration; startAndEndSpan(span, startTimestamp, endTimestamp, { name: resourceUrl.replace(WINDOW2.location.origin, ""), op: entry.initiatorType ? `resource.${entry.initiatorType}` : "resource.other", attributes }); } function _trackNavigator(span) { const navigator = WINDOW2.navigator; if (!navigator) { return; } const connection = navigator.connection; if (connection) { if (connecti