diff --git a/index.js b/index.js index 84776364ac32235275fe06db089931200d6953de..f22465e4f59215f0c23bd140636c538793b2575a 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,9 @@ const { const { getAccount, saveAccountData } = __webpack_require__(1691) const { isLocal, isDev } = __webpack_require__(1692) const Sentry = __webpack_require__(1601) -const { version } = __webpack_require__(1693) +// eslint-disable-next-line +const Tracing = __webpack_require__(1693) // Needed for tracking performance in Sentry +const { version } = __webpack_require__(1730) moment.locale('fr') // set the language moment.tz.setDefault('Europe/Paris') // set the timezone @@ -94,6 +96,10 @@ Sentry.init({ async function start(fields, cozyParameters) { log('info', 'Konnector configuration ...') log('info', `isManual execution: ${manualExecution}`) + const transaction = Sentry.startTransaction({ + op: 'konnector', + name: 'SGE Konnector', + }) const pointId = parseInt(fields.pointId) let baseUrl = fields.wso2BaseUrl @@ -139,7 +145,7 @@ async function start(fields, cozyParameters) { if (isFirstStart(await getAccount(ACCOUNT_ID))) { log('info', 'First start...') - Sentry.captureMessage('konnector first start') + transaction.startChild({ op: 'First start' }) const user = await verifyUserIdentity(fields, baseUrl, apiAuthKey, sgeLogin) let consent = await createBoConsent( @@ -208,7 +214,7 @@ async function start(fields, cozyParameters) { // firstStartTransaction.finish() } else { log('info', 'Alternate start...') - Sentry.captureMessage('Alternate start') + transaction.startChild({ op: 'Alternate start' }) const accountData = await getAccount(ACCOUNT_ID) const userConsent = await getBoConsent( boBaseUrl, @@ -252,6 +258,7 @@ async function start(fields, cozyParameters) { ) } } + transaction.finish() log('info', 'Successfully logged in') await gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) @@ -538,11 +545,9 @@ function processData(doctype = 'com.grandlyon.enedis.day') { } } catch (e) { if (doctype === 'com.grandlyon.enedis.minute') { - Sentry.captureMessage('No half-hour activated.') - log( - 'warn', - `No half-hour activated. Issue: ${result.Envelope.Body.Fault.faultstring}` - ) + const errorMessage = `No half-hour activated. Issue: ${result.Envelope.Body.Fault.faultstring}` + Sentry.captureMessage(errorMessage) + log('warn', errorMessage) } else { log('warn', `Unknown error ${e}`) } @@ -242280,6 +242285,5342 @@ module.exports = { isLocal, isDev } /***/ }), /* 1693 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "addExtensionMethods": () => (/* reexport safe */ _hubextensions_js__WEBPACK_IMPORTED_MODULE_0__.addExtensionMethods), +/* harmony export */ "startIdleTransaction": () => (/* reexport safe */ _hubextensions_js__WEBPACK_IMPORTED_MODULE_0__.startIdleTransaction), +/* harmony export */ "Integrations": () => (/* reexport module object */ _integrations_index_js__WEBPACK_IMPORTED_MODULE_1__), +/* harmony export */ "Span": () => (/* reexport safe */ _span_js__WEBPACK_IMPORTED_MODULE_2__.Span), +/* harmony export */ "spanStatusfromHttpCode": () => (/* reexport safe */ _span_js__WEBPACK_IMPORTED_MODULE_2__.spanStatusfromHttpCode), +/* harmony export */ "SpanStatus": () => (/* reexport safe */ _spanstatus_js__WEBPACK_IMPORTED_MODULE_3__.SpanStatus), +/* harmony export */ "Transaction": () => (/* reexport safe */ _transaction_js__WEBPACK_IMPORTED_MODULE_4__.Transaction), +/* harmony export */ "IdleTransaction": () => (/* reexport safe */ _idletransaction_js__WEBPACK_IMPORTED_MODULE_5__.IdleTransaction), +/* harmony export */ "getActiveTransaction": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_6__.getActiveTransaction), +/* harmony export */ "hasTracingEnabled": () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_6__.hasTracingEnabled), +/* harmony export */ "BROWSER_TRACING_INTEGRATION_ID": () => (/* reexport safe */ _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__.BROWSER_TRACING_INTEGRATION_ID), +/* harmony export */ "BrowserTracing": () => (/* reexport safe */ _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__.BrowserTracing), +/* harmony export */ "defaultRequestInstrumentationOptions": () => (/* reexport safe */ _browser_request_js__WEBPACK_IMPORTED_MODULE_8__.defaultRequestInstrumentationOptions), +/* harmony export */ "instrumentOutgoingRequests": () => (/* reexport safe */ _browser_request_js__WEBPACK_IMPORTED_MODULE_8__.instrumentOutgoingRequests), +/* harmony export */ "TRACEPARENT_REGEXP": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_9__.TRACEPARENT_REGEXP), +/* harmony export */ "extractTraceparentData": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_9__.extractTraceparentData), +/* harmony export */ "stripUrlQueryAndFragment": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_10__.stripUrlQueryAndFragment) +/* harmony export */ }); +/* harmony import */ var _hubextensions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1694); +/* harmony import */ var _integrations_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1702); +/* harmony import */ var _span_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1697); +/* harmony import */ var _spanstatus_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1729); +/* harmony import */ var _transaction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1696); +/* harmony import */ var _idletransaction_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1698); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1695); +/* harmony import */ var _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1711); +/* harmony import */ var _browser_request_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1714); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1679); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1669); + + + + + + + + + + + + + + +; +; + +// Treeshakable guard to remove all code related to tracing + +// Guard for tree +if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) { + // We are patching the global object with our hub extension methods + (0,_hubextensions_js__WEBPACK_IMPORTED_MODULE_0__.addExtensionMethods)(); +} +//# sourceMappingURL=index.js.map + + +/***/ }), +/* 1694 */ +/***/ ((module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_addTracingExtensions": () => (/* binding */ _addTracingExtensions), +/* harmony export */ "addExtensionMethods": () => (/* binding */ addExtensionMethods), +/* harmony export */ "startIdleTransaction": () => (/* binding */ startIdleTransaction) +/* harmony export */ }); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1602); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1611); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1607); +/* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1699); +/* harmony import */ var _idletransaction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1698); +/* harmony import */ var _transaction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1696); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1695); +/* module decorator */ module = __webpack_require__.hmd(module); + + + + + + + +/** Returns all trace headers that are currently on the top scope. */ +function traceHeaders() { + const scope = this.getScope(); + if (scope) { + const span = scope.getSpan(); + if (span) { + return { + 'sentry-trace': span.toTraceparent(), + }; + } + } + return {}; +} + +/** + * Makes a sampling decision for the given transaction and stores it on the transaction. + * + * Called every time a transaction is created. Only transactions which emerge with a `sampled` value of `true` will be + * sent to Sentry. + * + * @param transaction: The transaction needing a sampling decision + * @param options: The current client's options, so we can access `tracesSampleRate` and/or `tracesSampler` + * @param samplingContext: Default and user-provided data which may be used to help make the decision + * + * @returns The given transaction with its `sampled` value set + */ +function sample( + transaction, + options, + samplingContext, +) { + // nothing to do if tracing is not enabled + if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hasTracingEnabled)(options)) { + transaction.sampled = false; + return transaction; + } + + // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that + if (transaction.sampled !== undefined) { + transaction.setMetadata({ + sampleRate: Number(transaction.sampled), + }); + return transaction; + } + + // we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` were defined, so one of these should + // work; prefer the hook if so + let sampleRate; + if (typeof options.tracesSampler === 'function') { + sampleRate = options.tracesSampler(samplingContext); + transaction.setMetadata({ + sampleRate: Number(sampleRate), + }); + } else if (samplingContext.parentSampled !== undefined) { + sampleRate = samplingContext.parentSampled; + } else { + sampleRate = options.tracesSampleRate; + transaction.setMetadata({ + sampleRate: Number(sampleRate), + }); + } + + // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The + // only valid values are booleans or numbers between 0 and 1.) + if (!isValidSampleRate(sampleRate)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('[Tracing] Discarding transaction because of invalid sample rate.'); + transaction.sampled = false; + return transaction; + } + + // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped + if (!sampleRate) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log( + `[Tracing] Discarding transaction because ${ + typeof options.tracesSampler === 'function' + ? 'tracesSampler returned 0 or false' + : 'a negative sampling decision was inherited or tracesSampleRate is set to 0' + }`, + ); + transaction.sampled = false; + return transaction; + } + + // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is + // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false. + transaction.sampled = Math.random() < (sampleRate ); + + // if we're not going to keep it, we're done + if (!transaction.sampled) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log( + `[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number( + sampleRate, + )})`, + ); + return transaction; + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log(`[Tracing] starting ${transaction.op} transaction - ${transaction.name}`); + return transaction; +} + +/** + * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1). + */ +function isValidSampleRate(rate) { + // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.isNaN)(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn( + `[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify( + rate, + )} of type ${JSON.stringify(typeof rate)}.`, + ); + return false; + } + + // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false + if (rate < 0 || rate > 1) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`); + return false; + } + return true; +} + +/** + * Creates a new transaction and adds a sampling decision if it doesn't yet have one. + * + * The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`, as if + * it had been called on the hub directly. Exists as a separate function so that it can be injected into the class as an + * "extension method." + * + * @param this: The Hub starting the transaction + * @param transactionContext: Data used to configure the transaction + * @param CustomSamplingContext: Optional data to be provided to the `tracesSampler` function (if any) + * + * @returns The new transaction + * + * @see {@link Hub.startTransaction} + */ +function _startTransaction( + + transactionContext, + customSamplingContext, +) { + const client = this.getClient(); + const options = (client && client.getOptions()) || {}; + + const configInstrumenter = options.instrumenter || 'sentry'; + const transactionInstrumenter = transactionContext.instrumenter || 'sentry'; + + if (configInstrumenter !== transactionInstrumenter) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error( + `A transaction was started with instrumenter=\`${transactionInstrumenter}\`, but the SDK is configured with the \`${configInstrumenter}\` instrumenter. +The transaction will not be sampled. Please use the ${configInstrumenter} instrumentation to start transactions.`, + ); + + transactionContext.sampled = false; + } + + let transaction = new _transaction_js__WEBPACK_IMPORTED_MODULE_3__.Transaction(transactionContext, this); + transaction = sample(transaction, options, { + parentSampled: transactionContext.parentSampled, + transactionContext, + ...customSamplingContext, + }); + if (transaction.sampled) { + transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans )); + } + return transaction; +} + +/** + * Create new idle transaction. + */ +function startIdleTransaction( + hub, + transactionContext, + idleTimeout, + finalTimeout, + onScope, + customSamplingContext, + heartbeatInterval, +) { + const client = hub.getClient(); + const options = (client && client.getOptions()) || {}; + + let transaction = new _idletransaction_js__WEBPACK_IMPORTED_MODULE_4__.IdleTransaction(transactionContext, hub, idleTimeout, finalTimeout, heartbeatInterval, onScope); + transaction = sample(transaction, options, { + parentSampled: transactionContext.parentSampled, + transactionContext, + ...customSamplingContext, + }); + if (transaction.sampled) { + transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans )); + } + return transaction; +} + +/** + * @private + */ +function _addTracingExtensions() { + const carrier = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_5__.getMainCarrier)(); + if (!carrier.__SENTRY__) { + return; + } + carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {}; + if (!carrier.__SENTRY__.extensions.startTransaction) { + carrier.__SENTRY__.extensions.startTransaction = _startTransaction; + } + if (!carrier.__SENTRY__.extensions.traceHeaders) { + carrier.__SENTRY__.extensions.traceHeaders = traceHeaders; + } +} + +/** + * @private + */ +function _autoloadDatabaseIntegrations() { + const carrier = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_5__.getMainCarrier)(); + if (!carrier.__SENTRY__) { + return; + } + + const packageToIntegrationMapping = { + mongodb() { + const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.dynamicRequire)(module, './integrations/node/mongo') + +; + return new integration.Mongo(); + }, + mongoose() { + const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.dynamicRequire)(module, './integrations/node/mongo') + +; + return new integration.Mongo({ mongoose: true }); + }, + mysql() { + const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.dynamicRequire)(module, './integrations/node/mysql') + +; + return new integration.Mysql(); + }, + pg() { + const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.dynamicRequire)(module, './integrations/node/postgres') + +; + return new integration.Postgres(); + }, + }; + + const mappedPackages = Object.keys(packageToIntegrationMapping) + .filter(moduleName => !!(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.loadModule)(moduleName)) + .map(pkg => { + try { + return packageToIntegrationMapping[pkg](); + } catch (e) { + return undefined; + } + }) + .filter(p => p) ; + + if (mappedPackages.length > 0) { + carrier.__SENTRY__.integrations = [...(carrier.__SENTRY__.integrations || []), ...mappedPackages]; + } +} + +/** + * This patches the global object and injects the Tracing extensions methods + */ +function addExtensionMethods() { + _addTracingExtensions(); + + // Detect and automatically load specified integrations. + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.isNodeEnv)()) { + _autoloadDatabaseIntegrations(); + } + + // If an error happens globally, we should make sure transaction status is set to error. + (0,_errors_js__WEBPACK_IMPORTED_MODULE_7__.registerErrorInstrumentation)(); +} + + +//# sourceMappingURL=hubextensions.js.map + + +/***/ }), +/* 1695 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TRACEPARENT_REGEXP": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.TRACEPARENT_REGEXP), +/* harmony export */ "extractTraceparentData": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.extractTraceparentData), +/* harmony export */ "stripUrlQueryAndFragment": () => (/* reexport safe */ _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.stripUrlQueryAndFragment), +/* harmony export */ "getActiveTransaction": () => (/* binding */ getActiveTransaction), +/* harmony export */ "hasTracingEnabled": () => (/* binding */ hasTracingEnabled), +/* harmony export */ "msToSec": () => (/* binding */ msToSec), +/* harmony export */ "secToMs": () => (/* binding */ secToMs) +/* harmony export */ }); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1602); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1679); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1669); + + + +/** + * Determines if tracing is currently enabled. + * + * Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config. + */ +function hasTracingEnabled( + maybeOptions, +) { + const client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_2__.getCurrentHub)().getClient(); + const options = maybeOptions || (client && client.getOptions()); + return !!options && ('tracesSampleRate' in options || 'tracesSampler' in options); +} + +/** Grabs active transaction off scope, if any */ +function getActiveTransaction(maybeHub) { + const hub = maybeHub || (0,_sentry_core__WEBPACK_IMPORTED_MODULE_2__.getCurrentHub)(); + const scope = hub.getScope(); + return scope && (scope.getTransaction() ); +} + +/** + * Converts from milliseconds to seconds + * @param time time in ms + */ +function msToSec(time) { + return time / 1000; +} + +/** + * Converts from seconds to milliseconds + * @param time time in seconds + */ +function secToMs(time) { + return time * 1000; +} + + +//# sourceMappingURL=utils.js.map + + +/***/ }), +/* 1696 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Transaction": () => (/* binding */ Transaction) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1650); +/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1602); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1605); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1612); +/* harmony import */ var _span_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1697); + + + + + +/** JSDoc */ +class Transaction extends _span_js__WEBPACK_IMPORTED_MODULE_0__.Span { + + /** + * The reference to the current hub. + */ + + __init() {this._measurements = {};} + + __init2() {this._contexts = {};} + + __init3() {this._frozenDynamicSamplingContext = undefined;} + + /** + * This constructor should never be called manually. Those instrumenting tracing should use + * `Sentry.startTransaction()`, and internal methods should use `hub.startTransaction()`. + * @internal + * @hideconstructor + * @hidden + */ + constructor(transactionContext, hub) { + super(transactionContext);Transaction.prototype.__init.call(this);Transaction.prototype.__init2.call(this);Transaction.prototype.__init3.call(this);; + + this._hub = hub || (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)(); + + this._name = transactionContext.name || ''; + + this.metadata = { + source: 'custom', + ...transactionContext.metadata, + spanMetadata: {}, + changes: [], + propagations: 0, + }; + + this._trimEnd = transactionContext.trimEnd; + + // this is because transactions are also spans, and spans have a transaction pointer + this.transaction = this; + + // If Dynamic Sampling Context is provided during the creation of the transaction, we freeze it as it usually means + // there is incoming Dynamic Sampling Context. (Either through an incoming request, a baggage meta-tag, or other means) + const incomingDynamicSamplingContext = this.metadata.dynamicSamplingContext; + if (incomingDynamicSamplingContext) { + // We shallow copy this in case anything writes to the original reference of the passed in `dynamicSamplingContext` + this._frozenDynamicSamplingContext = { ...incomingDynamicSamplingContext }; + } + } + + /** Getter for `name` property */ + get name() { + return this._name; + } + + /** Setter for `name` property, which also sets `source` as custom */ + set name(newName) { + this.setName(newName); + } + + /** + * JSDoc + */ + setName(name, source = 'custom') { + // `source` could change without the name changing if we discover that an unparameterized route is actually + // parameterized by virtue of having no parameters in its path + if (name !== this.name || source !== this.metadata.source) { + this.metadata.changes.push({ + // log previous source + source: this.metadata.source, + timestamp: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.timestampInSeconds)(), + propagations: this.metadata.propagations, + }); + } + + this._name = name; + this.metadata.source = source; + } + + /** + * Attaches SpanRecorder to the span itself + * @param maxlen maximum number of spans that can be recorded + */ + initSpanRecorder(maxlen = 1000) { + if (!this.spanRecorder) { + this.spanRecorder = new _span_js__WEBPACK_IMPORTED_MODULE_0__.SpanRecorder(maxlen); + } + this.spanRecorder.add(this); + } + + /** + * @inheritDoc + */ + setContext(key, context) { + if (context === null) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this._contexts[key]; + } else { + this._contexts[key] = context; + } + } + + /** + * @inheritDoc + */ + setMeasurement(name, value, unit = '') { + this._measurements[name] = { value, unit }; + } + + /** + * @inheritDoc + */ + setMetadata(newMetadata) { + this.metadata = { ...this.metadata, ...newMetadata }; + } + + /** + * @inheritDoc + */ + finish(endTimestamp) { + // This transaction is already finished, so we should not flush it again. + if (this.endTimestamp !== undefined) { + return undefined; + } + + if (!this.name) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.warn('Transaction has no name, falling back to `<unlabeled transaction>`.'); + this.name = '<unlabeled transaction>'; + } + + // just sets the end timestamp + super.finish(endTimestamp); + + if (this.sampled !== true) { + // At this point if `sampled !== true` we want to discard the transaction. + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.'); + + const client = this._hub.getClient(); + if (client) { + client.recordDroppedEvent('sample_rate', 'transaction'); + } + + return undefined; + } + + const finishedSpans = this.spanRecorder ? this.spanRecorder.spans.filter(s => s !== this && s.endTimestamp) : []; + + if (this._trimEnd && finishedSpans.length > 0) { + this.endTimestamp = finishedSpans.reduce((prev, current) => { + if (prev.endTimestamp && current.endTimestamp) { + return prev.endTimestamp > current.endTimestamp ? prev : current; + } + return prev; + }).endTimestamp; + } + + const metadata = this.metadata; + + const transaction = { + contexts: { + ...this._contexts, + // We don't want to override trace context + trace: this.getTraceContext(), + }, + spans: finishedSpans, + start_timestamp: this.startTimestamp, + tags: this.tags, + timestamp: this.endTimestamp, + transaction: this.name, + type: 'transaction', + sdkProcessingMetadata: { + ...metadata, + dynamicSamplingContext: this.getDynamicSamplingContext(), + }, + ...(metadata.source && { + transaction_info: { + source: metadata.source, + changes: metadata.changes, + propagations: metadata.propagations, + }, + }), + }; + + const hasMeasurements = Object.keys(this._measurements).length > 0; + + if (hasMeasurements) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log( + '[Measurements] Adding measurements to transaction', + JSON.stringify(this._measurements, undefined, 2), + ); + transaction.measurements = this._measurements; + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(`[Tracing] Finishing ${this.op} transaction: ${this.name}.`); + + return this._hub.captureEvent(transaction); + } + + /** + * @inheritDoc + */ + toContext() { + const spanContext = super.toContext(); + + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.dropUndefinedKeys)({ + ...spanContext, + name: this.name, + trimEnd: this._trimEnd, + }); + } + + /** + * @inheritDoc + */ + updateWithContext(transactionContext) { + super.updateWithContext(transactionContext); + + this.name = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._nullishCoalesce)(transactionContext.name, () => ( '')); + + this._trimEnd = transactionContext.trimEnd; + + return this; + } + + /** + * @inheritdoc + * + * @experimental + */ + getDynamicSamplingContext() { + if (this._frozenDynamicSamplingContext) { + return this._frozenDynamicSamplingContext; + } + + const hub = this._hub || (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)(); + const client = hub && hub.getClient(); + + if (!client) return {}; + + const { environment, release } = client.getOptions() || {}; + const { publicKey: public_key } = client.getDsn() || {}; + + const maybeSampleRate = this.metadata.sampleRate; + const sample_rate = maybeSampleRate !== undefined ? maybeSampleRate.toString() : undefined; + + const scope = hub.getScope(); + const { segment: user_segment } = (scope && scope.getUser()) || {}; + + const source = this.metadata.source; + + // We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII + const transaction = source && source !== 'url' ? this.name : undefined; + + const dsc = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.dropUndefinedKeys)({ + environment, + release, + transaction, + user_segment, + public_key, + trace_id: this.traceId, + sample_rate, + }); + + // Uncomment if we want to make DSC immutable + // this._frozenDynamicSamplingContext = dsc; + + return dsc; + } +} + + +//# sourceMappingURL=transaction.js.map + + +/***/ }), +/* 1697 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Span": () => (/* binding */ Span), +/* harmony export */ "SpanRecorder": () => (/* binding */ SpanRecorder), +/* harmony export */ "spanStatusfromHttpCode": () => (/* binding */ spanStatusfromHttpCode) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1650); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1609); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1605); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); + + + +/** + * Keeps track of finished spans for a given transaction + * @internal + * @hideconstructor + * @hidden + */ +class SpanRecorder { + __init() {this.spans = [];} + + constructor(maxlen = 1000) {;SpanRecorder.prototype.__init.call(this); + this._maxlen = maxlen; + } + + /** + * This is just so that we don't run out of memory while recording a lot + * of spans. At some point we just stop and flush out the start of the + * trace tree (i.e.the first n spans with the smallest + * start_timestamp). + */ + add(span) { + if (this.spans.length > this._maxlen) { + span.spanRecorder = undefined; + } else { + this.spans.push(span); + } + } +} + +/** + * Span contains all data about a span + */ +class Span { + /** + * @inheritDoc + */ + __init2() {this.traceId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)();} + + /** + * @inheritDoc + */ + __init3() {this.spanId = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.uuid4)().substring(16);} + + /** + * @inheritDoc + */ + + /** + * Internal keeper of the status + */ + + /** + * @inheritDoc + */ + + /** + * Timestamp in seconds when the span was created. + */ + __init4() {this.startTimestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)();} + + /** + * Timestamp in seconds when the span ended. + */ + + /** + * @inheritDoc + */ + + /** + * @inheritDoc + */ + + /** + * @inheritDoc + */ + __init5() {this.tags = {};} + + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + __init6() {this.data = {};} + + /** + * List of spans that were finalized + */ + + /** + * @inheritDoc + */ + + /** + * The instrumenter that created this span. + */ + __init7() {this.instrumenter = 'sentry';} + + /** + * You should never call the constructor manually, always use `Sentry.startTransaction()` + * or call `startChild()` on an existing span. + * @internal + * @hideconstructor + * @hidden + */ + constructor(spanContext) {;Span.prototype.__init2.call(this);Span.prototype.__init3.call(this);Span.prototype.__init4.call(this);Span.prototype.__init5.call(this);Span.prototype.__init6.call(this);Span.prototype.__init7.call(this); + if (!spanContext) { + return this; + } + if (spanContext.traceId) { + this.traceId = spanContext.traceId; + } + if (spanContext.spanId) { + this.spanId = spanContext.spanId; + } + if (spanContext.parentSpanId) { + this.parentSpanId = spanContext.parentSpanId; + } + // We want to include booleans as well here + if ('sampled' in spanContext) { + this.sampled = spanContext.sampled; + } + if (spanContext.op) { + this.op = spanContext.op; + } + if (spanContext.description) { + this.description = spanContext.description; + } + if (spanContext.data) { + this.data = spanContext.data; + } + if (spanContext.tags) { + this.tags = spanContext.tags; + } + if (spanContext.status) { + this.status = spanContext.status; + } + if (spanContext.startTimestamp) { + this.startTimestamp = spanContext.startTimestamp; + } + if (spanContext.endTimestamp) { + this.endTimestamp = spanContext.endTimestamp; + } + if (spanContext.instrumenter) { + this.instrumenter = spanContext.instrumenter; + } + } + + /** + * @inheritDoc + */ + startChild( + spanContext, + ) { + const childSpan = new Span({ + ...spanContext, + parentSpanId: this.spanId, + sampled: this.sampled, + traceId: this.traceId, + }); + + childSpan.spanRecorder = this.spanRecorder; + if (childSpan.spanRecorder) { + childSpan.spanRecorder.add(childSpan); + } + + childSpan.transaction = this.transaction; + + if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && childSpan.transaction) { + const opStr = (spanContext && spanContext.op) || '< unknown op >'; + const nameStr = childSpan.transaction.name || '< unknown name >'; + const idStr = childSpan.transaction.spanId; + + const logMessage = `[Tracing] Starting '${opStr}' span on transaction '${nameStr}' (${idStr}).`; + childSpan.transaction.metadata.spanMetadata[childSpan.spanId] = { logMessage }; + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log(logMessage); + } + + return childSpan; + } + + /** + * @inheritDoc + */ + setTag(key, value) { + this.tags = { ...this.tags, [key]: value }; + return this; + } + + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + setData(key, value) { + this.data = { ...this.data, [key]: value }; + return this; + } + + /** + * @inheritDoc + */ + setStatus(value) { + this.status = value; + return this; + } + + /** + * @inheritDoc + */ + setHttpStatus(httpStatus) { + this.setTag('http.status_code', String(httpStatus)); + const spanStatus = spanStatusfromHttpCode(httpStatus); + if (spanStatus !== 'unknown_error') { + this.setStatus(spanStatus); + } + return this; + } + + /** + * @inheritDoc + */ + isSuccess() { + return this.status === 'ok'; + } + + /** + * @inheritDoc + */ + finish(endTimestamp) { + if ( + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + // Don't call this for transactions + this.transaction && + this.transaction.spanId !== this.spanId + ) { + const { logMessage } = this.transaction.metadata.spanMetadata[this.spanId]; + if (logMessage) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log((logMessage ).replace('Starting', 'Finishing')); + } + } + + this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); + } + + /** + * @inheritDoc + */ + toTraceparent() { + let sampledString = ''; + if (this.sampled !== undefined) { + sampledString = this.sampled ? '-1' : '-0'; + } + return `${this.traceId}-${this.spanId}${sampledString}`; + } + + /** + * @inheritDoc + */ + toContext() { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dropUndefinedKeys)({ + data: this.data, + description: this.description, + endTimestamp: this.endTimestamp, + op: this.op, + parentSpanId: this.parentSpanId, + sampled: this.sampled, + spanId: this.spanId, + startTimestamp: this.startTimestamp, + status: this.status, + tags: this.tags, + traceId: this.traceId, + }); + } + + /** + * @inheritDoc + */ + updateWithContext(spanContext) { + this.data = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._nullishCoalesce)(spanContext.data, () => ( {})); + this.description = spanContext.description; + this.endTimestamp = spanContext.endTimestamp; + this.op = spanContext.op; + this.parentSpanId = spanContext.parentSpanId; + this.sampled = spanContext.sampled; + this.spanId = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._nullishCoalesce)(spanContext.spanId, () => ( this.spanId)); + this.startTimestamp = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._nullishCoalesce)(spanContext.startTimestamp, () => ( this.startTimestamp)); + this.status = spanContext.status; + this.tags = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._nullishCoalesce)(spanContext.tags, () => ( {})); + this.traceId = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._nullishCoalesce)(spanContext.traceId, () => ( this.traceId)); + + return this; + } + + /** + * @inheritDoc + */ + getTraceContext() + + { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dropUndefinedKeys)({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + trace_id: this.traceId, + }); + } + + /** + * @inheritDoc + */ + toJSON() + + { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dropUndefinedKeys)({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + start_timestamp: this.startTimestamp, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + timestamp: this.endTimestamp, + trace_id: this.traceId, + }); + } +} + +/** + * Converts a HTTP status code into a {@link SpanStatusType}. + * + * @param httpStatus The HTTP response status code. + * @returns The span status or unknown_error. + */ +function spanStatusfromHttpCode(httpStatus) { + if (httpStatus < 400 && httpStatus >= 100) { + return 'ok'; + } + + if (httpStatus >= 400 && httpStatus < 500) { + switch (httpStatus) { + case 401: + return 'unauthenticated'; + case 403: + return 'permission_denied'; + case 404: + return 'not_found'; + case 409: + return 'already_exists'; + case 413: + return 'failed_precondition'; + case 429: + return 'resource_exhausted'; + default: + return 'invalid_argument'; + } + } + + if (httpStatus >= 500 && httpStatus < 600) { + switch (httpStatus) { + case 501: + return 'unimplemented'; + case 503: + return 'unavailable'; + case 504: + return 'deadline_exceeded'; + default: + return 'internal_error'; + } + } + + return 'unknown_error'; +} + + +//# sourceMappingURL=span.js.map + + +/***/ }), +/* 1698 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_FINAL_TIMEOUT": () => (/* binding */ DEFAULT_FINAL_TIMEOUT), +/* harmony export */ "DEFAULT_HEARTBEAT_INTERVAL": () => (/* binding */ DEFAULT_HEARTBEAT_INTERVAL), +/* harmony export */ "DEFAULT_IDLE_TIMEOUT": () => (/* binding */ DEFAULT_IDLE_TIMEOUT), +/* harmony export */ "IdleTransaction": () => (/* binding */ IdleTransaction), +/* harmony export */ "IdleTransactionSpanRecorder": () => (/* binding */ IdleTransactionSpanRecorder) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1605); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1615); +/* harmony import */ var _span_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1697); +/* harmony import */ var _transaction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1696); + + + + +const DEFAULT_IDLE_TIMEOUT = 1000; +const DEFAULT_FINAL_TIMEOUT = 30000; +const DEFAULT_HEARTBEAT_INTERVAL = 5000; + +/** + * @inheritDoc + */ +class IdleTransactionSpanRecorder extends _span_js__WEBPACK_IMPORTED_MODULE_0__.SpanRecorder { + constructor( + _pushActivity, + _popActivity, + transactionSpanId, + maxlen, + ) { + super(maxlen);this._pushActivity = _pushActivity;this._popActivity = _popActivity;this.transactionSpanId = transactionSpanId;; + } + + /** + * @inheritDoc + */ + add(span) { + // We should make sure we do not push and pop activities for + // the transaction that this span recorder belongs to. + if (span.spanId !== this.transactionSpanId) { + // We patch span.finish() to pop an activity after setting an endTimestamp. + span.finish = (endTimestamp) => { + span.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)(); + this._popActivity(span.spanId); + }; + + // We should only push new activities if the span does not have an end timestamp. + if (span.endTimestamp === undefined) { + this._pushActivity(span.spanId); + } + } + + super.add(span); + } +} + +/** + * An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities. + * You can have multiple IdleTransactions active, but if the `onScope` option is specified, the idle transaction will + * put itself on the scope on creation. + */ +class IdleTransaction extends _transaction_js__WEBPACK_IMPORTED_MODULE_2__.Transaction { + // Activities store a list of active spans + __init() {this.activities = {};} + + // Track state of activities in previous heartbeat + + // Amount of times heartbeat has counted. Will cause transaction to finish after 3 beats. + __init2() {this._heartbeatCounter = 0;} + + // We should not use heartbeat if we finished a transaction + __init3() {this._finished = false;} + + __init4() {this._beforeFinishCallbacks = [];} + + /** + * Timer that tracks Transaction idleTimeout + */ + + constructor( + transactionContext, + _idleHub, + /** + * The time to wait in ms until the idle transaction will be finished. This timer is started each time + * there are no active spans on this transaction. + */ + _idleTimeout = DEFAULT_IDLE_TIMEOUT, + /** + * The final value in ms that a transaction cannot exceed + */ + _finalTimeout = DEFAULT_FINAL_TIMEOUT, + _heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL, + // Whether or not the transaction should put itself on the scope when it starts and pop itself off when it ends + _onScope = false, + ) { + super(transactionContext, _idleHub);this._idleHub = _idleHub;this._idleTimeout = _idleTimeout;this._finalTimeout = _finalTimeout;this._heartbeatInterval = _heartbeatInterval;this._onScope = _onScope;IdleTransaction.prototype.__init.call(this);IdleTransaction.prototype.__init2.call(this);IdleTransaction.prototype.__init3.call(this);IdleTransaction.prototype.__init4.call(this);; + + if (_onScope) { + // There should only be one active transaction on the scope + clearActiveTransaction(_idleHub); + + // We set the transaction here on the scope so error events pick up the trace + // context and attach it to the error. + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(`Setting idle transaction on scope. Span ID: ${this.spanId}`); + _idleHub.configureScope(scope => scope.setSpan(this)); + } + + this._startIdleTimeout(); + setTimeout(() => { + if (!this._finished) { + this.setStatus('deadline_exceeded'); + this.finish(); + } + }, this._finalTimeout); + } + + /** {@inheritDoc} */ + finish(endTimestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)()) { + this._finished = true; + this.activities = {}; + + if (this.spanRecorder) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestamp * 1000).toISOString(), this.op); + + for (const callback of this._beforeFinishCallbacks) { + callback(this, endTimestamp); + } + + this.spanRecorder.spans = this.spanRecorder.spans.filter((span) => { + // If we are dealing with the transaction itself, we just return it + if (span.spanId === this.spanId) { + return true; + } + + // We cancel all pending spans with status "cancelled" to indicate the idle transaction was finished early + if (!span.endTimestamp) { + span.endTimestamp = endTimestamp; + span.setStatus('cancelled'); + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] cancelling span since transaction ended early', JSON.stringify(span, undefined, 2)); + } + + const keepSpan = span.startTimestamp < endTimestamp; + if (!keepSpan) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log( + '[Tracing] discarding Span since it happened after Transaction was finished', + JSON.stringify(span, undefined, 2), + ); + } + return keepSpan; + }); + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] flushing IdleTransaction'); + } else { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] No active IdleTransaction'); + } + + // if `this._onScope` is `true`, the transaction put itself on the scope when it started + if (this._onScope) { + clearActiveTransaction(this._idleHub); + } + + return super.finish(endTimestamp); + } + + /** + * Register a callback function that gets excecuted before the transaction finishes. + * Useful for cleanup or if you want to add any additional spans based on current context. + * + * This is exposed because users have no other way of running something before an idle transaction + * finishes. + */ + registerBeforeFinishCallback(callback) { + this._beforeFinishCallbacks.push(callback); + } + + /** + * @inheritDoc + */ + initSpanRecorder(maxlen) { + if (!this.spanRecorder) { + const pushActivity = (id) => { + if (this._finished) { + return; + } + this._pushActivity(id); + }; + const popActivity = (id) => { + if (this._finished) { + return; + } + this._popActivity(id); + }; + + this.spanRecorder = new IdleTransactionSpanRecorder(pushActivity, popActivity, this.spanId, maxlen); + + // Start heartbeat so that transactions do not run forever. + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('Starting heartbeat'); + this._pingHeartbeat(); + } + this.spanRecorder.add(this); + } + + /** + * Cancels the existing idletimeout, if there is one + */ + _cancelIdleTimeout() { + if (this._idleTimeoutID) { + clearTimeout(this._idleTimeoutID); + this._idleTimeoutID = undefined; + } + } + + /** + * Creates an idletimeout + */ + _startIdleTimeout(endTimestamp) { + this._cancelIdleTimeout(); + this._idleTimeoutID = setTimeout(() => { + if (!this._finished && Object.keys(this.activities).length === 0) { + this.finish(endTimestamp); + } + }, this._idleTimeout); + } + + /** + * Start tracking a specific activity. + * @param spanId The span id that represents the activity + */ + _pushActivity(spanId) { + this._cancelIdleTimeout(); + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(`[Tracing] pushActivity: ${spanId}`); + this.activities[spanId] = true; + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] new activities count', Object.keys(this.activities).length); + } + + /** + * Remove an activity from usage + * @param spanId The span id that represents the activity + */ + _popActivity(spanId) { + if (this.activities[spanId]) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(`[Tracing] popActivity ${spanId}`); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this.activities[spanId]; + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] new activities count', Object.keys(this.activities).length); + } + + if (Object.keys(this.activities).length === 0) { + // We need to add the timeout here to have the real endtimestamp of the transaction + // Remember timestampWithMs is in seconds, timeout is in ms + const endTimestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.timestampWithMs)() + this._idleTimeout / 1000; + this._startIdleTimeout(endTimestamp); + } + } + + /** + * Checks when entries of this.activities are not changing for 3 beats. + * If this occurs we finish the transaction. + */ + _beat() { + // We should not be running heartbeat if the idle transaction is finished. + if (this._finished) { + return; + } + + const heartbeatString = Object.keys(this.activities).join(''); + + if (heartbeatString === this._prevHeartbeatString) { + this._heartbeatCounter += 1; + } else { + this._heartbeatCounter = 1; + } + + this._prevHeartbeatString = heartbeatString; + + if (this._heartbeatCounter >= 3) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log('[Tracing] Transaction finished because of no change for 3 heart beats'); + this.setStatus('deadline_exceeded'); + this.finish(); + } else { + this._pingHeartbeat(); + } + } + + /** + * Pings the heartbeat + */ + _pingHeartbeat() { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`); + setTimeout(() => { + this._beat(); + }, this._heartbeatInterval); + } +} + +/** + * Reset transaction on scope to `undefined` + */ +function clearActiveTransaction(hub) { + const scope = hub.getScope(); + if (scope) { + const transaction = scope.getTransaction(); + if (transaction) { + scope.setSpan(undefined); + } + } +} + + +//# sourceMappingURL=idletransaction.js.map + + +/***/ }), +/* 1699 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "registerErrorInstrumentation": () => (/* binding */ registerErrorInstrumentation) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1700); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1615); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1695); + + + +/** + * Configures global error listeners + */ +function registerErrorInstrumentation() { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('error', errorCallback); + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('unhandledrejection', errorCallback); +} + +/** + * If an error or unhandled promise occurs, we mark the active transaction as failed + */ +function errorCallback() { + const activeTransaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.getActiveTransaction)(); + if (activeTransaction) { + const status = 'internal_error'; + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log(`[Tracing] Transaction: ${status} -> Global error occured`); + activeTransaction.setStatus(status); + } +} + + +//# sourceMappingURL=errors.js.map + + +/***/ }), +/* 1700 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "addInstrumentationHandler": () => (/* binding */ addInstrumentationHandler) +/* harmony export */ }); +/* harmony import */ var _is_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); +/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _object_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); +/* harmony import */ var _stacktrace_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1624); +/* harmony import */ var _supports_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1701); +/* harmony import */ var _worldwide_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1606); + + + + + + + +// eslint-disable-next-line deprecation/deprecation +const WINDOW = (0,_worldwide_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); + +/** + * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc. + * - Console API + * - Fetch API + * - XHR API + * - History API + * - DOM API (click/typing) + * - Error API + * - UnhandledRejection API + */ + +const handlers = {}; +const instrumented = {}; + +/** Instruments given API */ +function instrument(type) { + if (instrumented[type]) { + return; + } + + instrumented[type] = true; + + switch (type) { + case 'console': + instrumentConsole(); + break; + case 'dom': + instrumentDOM(); + break; + case 'xhr': + instrumentXHR(); + break; + case 'fetch': + instrumentFetch(); + break; + case 'history': + instrumentHistory(); + break; + case 'error': + instrumentError(); + break; + case 'unhandledrejection': + instrumentUnhandledRejection(); + break; + default: + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _logger_js__WEBPACK_IMPORTED_MODULE_1__.logger.warn('unknown instrumentation type:', type); + return; + } +} + +/** + * Add handler that will be called when given type of instrumentation triggers. + * Use at your own risk, this might break without changelog notice, only used internally. + * @hidden + */ +function addInstrumentationHandler(type, callback) { + handlers[type] = handlers[type] || []; + (handlers[type] ).push(callback); + instrument(type); +} + +/** JSDoc */ +function triggerHandlers(type, data) { + if (!type || !handlers[type]) { + return; + } + + for (const handler of handlers[type] || []) { + try { + handler(data); + } catch (e) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _logger_js__WEBPACK_IMPORTED_MODULE_1__.logger.error( + `Error while triggering instrumentation handler.\nType: ${type}\nName: ${(0,_stacktrace_js__WEBPACK_IMPORTED_MODULE_2__.getFunctionName)(handler)}\nError:`, + e, + ); + } + } +} + +/** JSDoc */ +function instrumentConsole() { + if (!('console' in WINDOW)) { + return; + } + + _logger_js__WEBPACK_IMPORTED_MODULE_1__.CONSOLE_LEVELS.forEach(function (level) { + if (!(level in WINDOW.console)) { + return; + } + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(WINDOW.console, level, function (originalConsoleMethod) { + return function (...args) { + triggerHandlers('console', { args, level }); + + // this fails for some browsers. :( + if (originalConsoleMethod) { + originalConsoleMethod.apply(WINDOW.console, args); + } + }; + }); + }); +} + +/** JSDoc */ +function instrumentFetch() { + if (!(0,_supports_js__WEBPACK_IMPORTED_MODULE_4__.supportsNativeFetch)()) { + return; + } + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(WINDOW, 'fetch', function (originalFetch) { + return function (...args) { + const handlerData = { + args, + fetchData: { + method: getFetchMethod(args), + url: getFetchUrl(args), + }, + startTimestamp: Date.now(), + }; + + triggerHandlers('fetch', { + ...handlerData, + }); + + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return originalFetch.apply(WINDOW, args).then( + (response) => { + triggerHandlers('fetch', { + ...handlerData, + endTimestamp: Date.now(), + response, + }); + return response; + }, + (error) => { + triggerHandlers('fetch', { + ...handlerData, + endTimestamp: Date.now(), + error, + }); + // NOTE: If you are a Sentry user, and you are seeing this stack frame, + // it means the sentry.javascript SDK caught an error invoking your application code. + // This is expected behavior and NOT indicative of a bug with sentry.javascript. + throw error; + }, + ); + }; + }); +} + +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/** Extract `method` from fetch call arguments */ +function getFetchMethod(fetchArgs = []) { + if ('Request' in WINDOW && (0,_is_js__WEBPACK_IMPORTED_MODULE_5__.isInstanceOf)(fetchArgs[0], Request) && fetchArgs[0].method) { + return String(fetchArgs[0].method).toUpperCase(); + } + if (fetchArgs[1] && fetchArgs[1].method) { + return String(fetchArgs[1].method).toUpperCase(); + } + return 'GET'; +} + +/** Extract `url` from fetch call arguments */ +function getFetchUrl(fetchArgs = []) { + if (typeof fetchArgs[0] === 'string') { + return fetchArgs[0]; + } + if ('Request' in WINDOW && (0,_is_js__WEBPACK_IMPORTED_MODULE_5__.isInstanceOf)(fetchArgs[0], Request)) { + return fetchArgs[0].url; + } + return String(fetchArgs[0]); +} +/* eslint-enable @typescript-eslint/no-unsafe-member-access */ + +/** JSDoc */ +function instrumentXHR() { + if (!('XMLHttpRequest' in WINDOW)) { + return; + } + + const xhrproto = XMLHttpRequest.prototype; + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(xhrproto, 'open', function (originalOpen) { + return function ( ...args) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const xhr = this; + const url = args[1]; + const xhrInfo = (xhr.__sentry_xhr__ = { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + method: (0,_is_js__WEBPACK_IMPORTED_MODULE_5__.isString)(args[0]) ? args[0].toUpperCase() : args[0], + url: args[1], + }); + + // if Sentry key appears in URL, don't capture it as a request + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if ((0,_is_js__WEBPACK_IMPORTED_MODULE_5__.isString)(url) && xhrInfo.method === 'POST' && url.match(/sentry_key/)) { + xhr.__sentry_own_request__ = true; + } + + const onreadystatechangeHandler = function () { + if (xhr.readyState === 4) { + try { + // touching statusCode in some platforms throws + // an exception + xhrInfo.status_code = xhr.status; + } catch (e) { + /* do nothing */ + } + + triggerHandlers('xhr', { + args, + endTimestamp: Date.now(), + startTimestamp: Date.now(), + xhr, + }); + } + }; + + if ('onreadystatechange' in xhr && typeof xhr.onreadystatechange === 'function') { + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(xhr, 'onreadystatechange', function (original) { + return function (...readyStateArgs) { + onreadystatechangeHandler(); + return original.apply(xhr, readyStateArgs); + }; + }); + } else { + xhr.addEventListener('readystatechange', onreadystatechangeHandler); + } + + return originalOpen.apply(xhr, args); + }; + }); + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(xhrproto, 'send', function (originalSend) { + return function ( ...args) { + if (this.__sentry_xhr__ && args[0] !== undefined) { + this.__sentry_xhr__.body = args[0]; + } + + triggerHandlers('xhr', { + args, + startTimestamp: Date.now(), + xhr: this, + }); + + return originalSend.apply(this, args); + }; + }); +} + +let lastHref; + +/** JSDoc */ +function instrumentHistory() { + if (!(0,_supports_js__WEBPACK_IMPORTED_MODULE_4__.supportsHistory)()) { + return; + } + + const oldOnPopState = WINDOW.onpopstate; + WINDOW.onpopstate = function ( ...args) { + const to = WINDOW.location.href; + // keep track of the current URL state, as we always receive only the updated state + const from = lastHref; + lastHref = to; + triggerHandlers('history', { + from, + to, + }); + if (oldOnPopState) { + // Apparently this can throw in Firefox when incorrectly implemented plugin is installed. + // https://github.com/getsentry/sentry-javascript/issues/3344 + // https://github.com/bugsnag/bugsnag-js/issues/469 + try { + return oldOnPopState.apply(this, args); + } catch (_oO) { + // no-empty + } + } + }; + + /** @hidden */ + function historyReplacementFunction(originalHistoryFunction) { + return function ( ...args) { + const url = args.length > 2 ? args[2] : undefined; + if (url) { + // coerce to string (this is what pushState does) + const from = lastHref; + const to = String(url); + // keep track of the current URL state, as we always receive only the updated state + lastHref = to; + triggerHandlers('history', { + from, + to, + }); + } + return originalHistoryFunction.apply(this, args); + }; + } + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(WINDOW.history, 'pushState', historyReplacementFunction); + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(WINDOW.history, 'replaceState', historyReplacementFunction); +} + +const debounceDuration = 1000; +let debounceTimerID; +let lastCapturedEvent; + +/** + * Decide whether the current event should finish the debounce of previously captured one. + * @param previous previously captured event + * @param current event to be captured + */ +function shouldShortcircuitPreviousDebounce(previous, current) { + // If there was no previous event, it should always be swapped for the new one. + if (!previous) { + return true; + } + + // If both events have different type, then user definitely performed two separate actions. e.g. click + keypress. + if (previous.type !== current.type) { + return true; + } + + try { + // If both events have the same type, it's still possible that actions were performed on different targets. + // e.g. 2 clicks on different buttons. + if (previous.target !== current.target) { + return true; + } + } catch (e) { + // just accessing `target` property can throw an exception in some rare circumstances + // see: https://github.com/getsentry/sentry-javascript/issues/838 + } + + // If both events have the same type _and_ same `target` (an element which triggered an event, _not necessarily_ + // to which an event listener was attached), we treat them as the same action, as we want to capture + // only one breadcrumb. e.g. multiple clicks on the same button, or typing inside a user input box. + return false; +} + +/** + * Decide whether an event should be captured. + * @param event event to be captured + */ +function shouldSkipDOMEvent(event) { + // We are only interested in filtering `keypress` events for now. + if (event.type !== 'keypress') { + return false; + } + + try { + const target = event.target ; + + if (!target || !target.tagName) { + return true; + } + + // Only consider keypress events on actual input elements. This will disregard keypresses targeting body + // e.g.tabbing through elements, hotkeys, etc. + if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) { + return false; + } + } catch (e) { + // just accessing `target` property can throw an exception in some rare circumstances + // see: https://github.com/getsentry/sentry-javascript/issues/838 + } + + return true; +} + +/** + * Wraps addEventListener to capture UI breadcrumbs + * @param handler function that will be triggered + * @param globalListener indicates whether event was captured by the global event listener + * @returns wrapped breadcrumb events handler + * @hidden + */ +function makeDOMEventHandler(handler, globalListener = false) { + return (event) => { + // It's possible this handler might trigger multiple times for the same + // event (e.g. event propagation through node ancestors). + // Ignore if we've already captured that event. + if (!event || lastCapturedEvent === event) { + return; + } + + // We always want to skip _some_ events. + if (shouldSkipDOMEvent(event)) { + return; + } + + const name = event.type === 'keypress' ? 'input' : event.type; + + // If there is no debounce timer, it means that we can safely capture the new event and store it for future comparisons. + if (debounceTimerID === undefined) { + handler({ + event: event, + name, + global: globalListener, + }); + lastCapturedEvent = event; + } + // If there is a debounce awaiting, see if the new event is different enough to treat it as a unique one. + // If that's the case, emit the previous event and store locally the newly-captured DOM event. + else if (shouldShortcircuitPreviousDebounce(lastCapturedEvent, event)) { + handler({ + event: event, + name, + global: globalListener, + }); + lastCapturedEvent = event; + } + + // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together. + clearTimeout(debounceTimerID); + debounceTimerID = WINDOW.setTimeout(() => { + debounceTimerID = undefined; + }, debounceDuration); + }; +} + +/** JSDoc */ +function instrumentDOM() { + if (!('document' in WINDOW)) { + return; + } + + // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom + // handlers. (Normally we have only one, which captures a breadcrumb for each click or keypress.) Do this before + // we instrument `addEventListener` so that we don't end up attaching this handler twice. + const triggerDOMHandler = triggerHandlers.bind(null, 'dom'); + const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true); + WINDOW.document.addEventListener('click', globalDOMEventHandler, false); + WINDOW.document.addEventListener('keypress', globalDOMEventHandler, false); + + // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled + // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That + // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler + // could potentially prevent the event from bubbling up to our global listeners. This way, our handler are still + // guaranteed to fire at least once.) + ['EventTarget', 'Node'].forEach((target) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + const proto = (WINDOW )[target] && (WINDOW )[target].prototype; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins + if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) { + return; + } + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)(proto, 'addEventListener', function (originalAddEventListener) { + return function ( + + type, + listener, + options, + ) { + if (type === 'click' || type == 'keypress') { + try { + const el = this ; + const handlers = (el.__sentry_instrumentation_handlers__ = el.__sentry_instrumentation_handlers__ || {}); + const handlerForType = (handlers[type] = handlers[type] || { refCount: 0 }); + + if (!handlerForType.handler) { + const handler = makeDOMEventHandler(triggerDOMHandler); + handlerForType.handler = handler; + originalAddEventListener.call(this, type, handler, options); + } + + handlerForType.refCount += 1; + } catch (e) { + // Accessing dom properties is always fragile. + // Also allows us to skip `addEventListenrs` calls with no proper `this` context. + } + } + + return originalAddEventListener.call(this, type, listener, options); + }; + }); + + (0,_object_js__WEBPACK_IMPORTED_MODULE_3__.fill)( + proto, + 'removeEventListener', + function (originalRemoveEventListener) { + return function ( + + type, + listener, + options, + ) { + if (type === 'click' || type == 'keypress') { + try { + const el = this ; + const handlers = el.__sentry_instrumentation_handlers__ || {}; + const handlerForType = handlers[type]; + + if (handlerForType) { + handlerForType.refCount -= 1; + // If there are no longer any custom handlers of the current type on this element, we can remove ours, too. + if (handlerForType.refCount <= 0) { + originalRemoveEventListener.call(this, type, handlerForType.handler, options); + handlerForType.handler = undefined; + delete handlers[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete + } + + // If there are no longer any custom handlers of any type on this element, cleanup everything. + if (Object.keys(handlers).length === 0) { + delete el.__sentry_instrumentation_handlers__; + } + } + } catch (e) { + // Accessing dom properties is always fragile. + // Also allows us to skip `addEventListenrs` calls with no proper `this` context. + } + } + + return originalRemoveEventListener.call(this, type, listener, options); + }; + }, + ); + }); +} + +let _oldOnErrorHandler = null; +/** JSDoc */ +function instrumentError() { + _oldOnErrorHandler = WINDOW.onerror; + + WINDOW.onerror = function (msg, url, line, column, error) { + triggerHandlers('error', { + column, + error, + line, + msg, + url, + }); + + if (_oldOnErrorHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnErrorHandler.apply(this, arguments); + } + + return false; + }; +} + +let _oldOnUnhandledRejectionHandler = null; +/** JSDoc */ +function instrumentUnhandledRejection() { + _oldOnUnhandledRejectionHandler = WINDOW.onunhandledrejection; + + WINDOW.onunhandledrejection = function (e) { + triggerHandlers('unhandledrejection', e); + + if (_oldOnUnhandledRejectionHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnUnhandledRejectionHandler.apply(this, arguments); + } + + return true; + }; +} + + +//# sourceMappingURL=instrument.js.map + + +/***/ }), +/* 1701 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isNativeFetch": () => (/* binding */ isNativeFetch), +/* harmony export */ "supportsDOMError": () => (/* binding */ supportsDOMError), +/* harmony export */ "supportsDOMException": () => (/* binding */ supportsDOMException), +/* harmony export */ "supportsErrorEvent": () => (/* binding */ supportsErrorEvent), +/* harmony export */ "supportsFetch": () => (/* binding */ supportsFetch), +/* harmony export */ "supportsHistory": () => (/* binding */ supportsHistory), +/* harmony export */ "supportsNativeFetch": () => (/* binding */ supportsNativeFetch), +/* harmony export */ "supportsReferrerPolicy": () => (/* binding */ supportsReferrerPolicy), +/* harmony export */ "supportsReportingObserver": () => (/* binding */ supportsReportingObserver) +/* harmony export */ }); +/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _worldwide_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1606); + + + +// eslint-disable-next-line deprecation/deprecation +const WINDOW = (0,_worldwide_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)(); + +/** + * Tells whether current environment supports ErrorEvent objects + * {@link supportsErrorEvent}. + * + * @returns Answer to the given question. + */ +function supportsErrorEvent() { + try { + new ErrorEvent(''); + return true; + } catch (e) { + return false; + } +} + +/** + * Tells whether current environment supports DOMError objects + * {@link supportsDOMError}. + * + * @returns Answer to the given question. + */ +function supportsDOMError() { + try { + // Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError': + // 1 argument required, but only 0 present. + // @ts-ignore It really needs 1 argument, not 0. + new DOMError(''); + return true; + } catch (e) { + return false; + } +} + +/** + * Tells whether current environment supports DOMException objects + * {@link supportsDOMException}. + * + * @returns Answer to the given question. + */ +function supportsDOMException() { + try { + new DOMException(''); + return true; + } catch (e) { + return false; + } +} + +/** + * Tells whether current environment supports Fetch API + * {@link supportsFetch}. + * + * @returns Answer to the given question. + */ +function supportsFetch() { + if (!('fetch' in WINDOW)) { + return false; + } + + try { + new Headers(); + new Request('http://www.example.com'); + new Response(); + return true; + } catch (e) { + return false; + } +} +/** + * isNativeFetch checks if the given function is a native implementation of fetch() + */ +// eslint-disable-next-line @typescript-eslint/ban-types +function isNativeFetch(func) { + return func && /^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(func.toString()); +} + +/** + * Tells whether current environment supports Fetch API natively + * {@link supportsNativeFetch}. + * + * @returns true if `window.fetch` is natively implemented, false otherwise + */ +function supportsNativeFetch() { + if (!supportsFetch()) { + return false; + } + + // Fast path to avoid DOM I/O + // eslint-disable-next-line @typescript-eslint/unbound-method + if (isNativeFetch(WINDOW.fetch)) { + return true; + } + + // window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension) + // so create a "pure" iframe to see if that has native fetch + let result = false; + const doc = WINDOW.document; + // eslint-disable-next-line deprecation/deprecation + if (doc && typeof (doc.createElement ) === 'function') { + try { + const sandbox = doc.createElement('iframe'); + sandbox.hidden = true; + doc.head.appendChild(sandbox); + if (sandbox.contentWindow && sandbox.contentWindow.fetch) { + // eslint-disable-next-line @typescript-eslint/unbound-method + result = isNativeFetch(sandbox.contentWindow.fetch); + } + doc.head.removeChild(sandbox); + } catch (err) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _logger_js__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err); + } + } + + return result; +} + +/** + * Tells whether current environment supports ReportingObserver API + * {@link supportsReportingObserver}. + * + * @returns Answer to the given question. + */ +function supportsReportingObserver() { + return 'ReportingObserver' in WINDOW; +} + +/** + * Tells whether current environment supports Referrer Policy API + * {@link supportsReferrerPolicy}. + * + * @returns Answer to the given question. + */ +function supportsReferrerPolicy() { + // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default' + // (see https://caniuse.com/#feat=referrer-policy), + // it doesn't. And it throws an exception instead of ignoring this parameter... + // REF: https://github.com/getsentry/raven-js/issues/1233 + + if (!supportsFetch()) { + return false; + } + + try { + new Request('_', { + referrerPolicy: 'origin' , + }); + return true; + } catch (e) { + return false; + } +} + +/** + * Tells whether current environment supports History API + * {@link supportsHistory}. + * + * @returns Answer to the given question. + */ +function supportsHistory() { + // NOTE: in Chrome App environment, touching history.pushState, *even inside + // a try/catch block*, will cause Chrome to output an error to console.error + // borrowed from: https://github.com/angular/angular.js/pull/13945/files + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const chrome = (WINDOW ).chrome; + const isChromePackagedApp = chrome && chrome.app && chrome.app.runtime; + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + const hasHistoryApi = 'history' in WINDOW && !!WINDOW.history.pushState && !!WINDOW.history.replaceState; + + return !isChromePackagedApp && hasHistoryApi; +} + + +//# sourceMappingURL=supports.js.map + + +/***/ }), +/* 1702 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Express": () => (/* reexport safe */ _node_express_js__WEBPACK_IMPORTED_MODULE_0__.Express), +/* harmony export */ "Postgres": () => (/* reexport safe */ _node_postgres_js__WEBPACK_IMPORTED_MODULE_1__.Postgres), +/* harmony export */ "Mysql": () => (/* reexport safe */ _node_mysql_js__WEBPACK_IMPORTED_MODULE_2__.Mysql), +/* harmony export */ "Mongo": () => (/* reexport safe */ _node_mongo_js__WEBPACK_IMPORTED_MODULE_3__.Mongo), +/* harmony export */ "Prisma": () => (/* reexport safe */ _node_prisma_js__WEBPACK_IMPORTED_MODULE_4__.Prisma), +/* harmony export */ "GraphQL": () => (/* reexport safe */ _node_graphql_js__WEBPACK_IMPORTED_MODULE_5__.GraphQL), +/* harmony export */ "Apollo": () => (/* reexport safe */ _node_apollo_js__WEBPACK_IMPORTED_MODULE_6__.Apollo), +/* harmony export */ "BrowserTracing": () => (/* reexport safe */ _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__.BrowserTracing) +/* harmony export */ }); +/* harmony import */ var _node_express_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1703); +/* harmony import */ var _node_postgres_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1705); +/* harmony import */ var _node_mysql_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1706); +/* harmony import */ var _node_mongo_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1707); +/* harmony import */ var _node_prisma_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1708); +/* harmony import */ var _node_graphql_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1709); +/* harmony import */ var _node_apollo_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1710); +/* harmony import */ var _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1711); + + + + + + + + + +//# sourceMappingURL=index.js.map + + +/***/ }), +/* 1703 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Express": () => (/* binding */ Express) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1669); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1670); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1704); + + + + +/** + * Express integration + * + * Provides an request and error handler for Express framework as well as tracing capabilities + */ +class Express { + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Express';} + + /** + * @inheritDoc + */ + __init() {this.name = Express.id;} + + /** + * Express App instance + */ + + /** + * @inheritDoc + */ + constructor(options = {}) {;Express.prototype.__init.call(this); + this._router = options.router || options.app; + this._methods = (Array.isArray(options.methods) ? options.methods : []).concat('use'); + } + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + if (!this._router) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error('ExpressIntegration is missing an Express instance'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.log('Express Integration is skipped because of instrumenter configuration.'); + return; + } + + instrumentMiddlewares(this._router, this._methods); + instrumentRouter(this._router ); + } +}Express.__initStatic(); + +/** + * Wraps original middleware function in a tracing call, which stores the info about the call as a span, + * and finishes it once the middleware is done invoking. + * + * Express middlewares have 3 various forms, thus we have to take care of all of them: + * // sync + * app.use(function (req, res) { ... }) + * // async + * app.use(function (req, res, next) { ... }) + * // error handler + * app.use(function (err, req, res, next) { ... }) + * + * They all internally delegate to the `router[method]` of the given application instance. + */ +// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any +function wrap(fn, method) { + const arity = fn.length; + + switch (arity) { + case 2: { + return function ( req, res) { + const transaction = res.__sentry_transaction; + if (transaction) { + const span = transaction.startChild({ + description: fn.name, + op: `middleware.express.${method}`, + }); + res.once('finish', () => { + span.finish(); + }); + } + return fn.call(this, req, res); + }; + } + case 3: { + return function ( + + req, + res, + next, + ) { + const transaction = res.__sentry_transaction; + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([transaction, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({ + description: fn.name, + op: `middleware.express.${method}`, + })]); + fn.call(this, req, res, function ( ...args) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _4 => _4.finish, 'call', _5 => _5()]); + next.call(this, ...args); + }); + }; + } + case 4: { + return function ( + + err, + req, + res, + next, + ) { + const transaction = res.__sentry_transaction; + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([transaction, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({ + description: fn.name, + op: `middleware.express.${method}`, + })]); + fn.call(this, err, req, res, function ( ...args) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + next.call(this, ...args); + }); + }; + } + default: { + throw new Error(`Express middleware takes 2-4 arguments. Got: ${arity}`); + } + } +} + +/** + * Takes all the function arguments passed to the original `app` or `router` method, eg. `app.use` or `router.use` + * and wraps every function, as well as array of functions with a call to our `wrap` method. + * We have to take care of the arrays as well as iterate over all of the arguments, + * as `app.use` can accept middlewares in few various forms. + * + * app.use([<path>], <fn>) + * app.use([<path>], <fn>, ...<fn>) + * app.use([<path>], ...<fn>[]) + */ +function wrapMiddlewareArgs(args, method) { + return args.map((arg) => { + if (typeof arg === 'function') { + return wrap(arg, method); + } + + if (Array.isArray(arg)) { + return arg.map((a) => { + if (typeof a === 'function') { + return wrap(a, method); + } + return a; + }); + } + + return arg; + }); +} + +/** + * Patches original router to utilize our tracing functionality + */ +function patchMiddleware(router, method) { + const originalCallback = router[method]; + + router[method] = function (...args) { + return originalCallback.call(this, ...wrapMiddlewareArgs(args, method)); + }; + + return router; +} + +/** + * Patches original router methods + */ +function instrumentMiddlewares(router, methods = []) { + methods.forEach((method) => patchMiddleware(router, method)); +} + +/** + * Patches the prototype of Express.Router to accumulate the resolved route + * if a layer instance's `match` function was called and it returned a successful match. + * + * @see https://github.com/expressjs/express/blob/master/lib/router/index.js + * + * @param appOrRouter the router instance which can either be an app (i.e. top-level) or a (nested) router. + */ +function instrumentRouter(appOrRouter) { + // This is how we can distinguish between app and routers + const isApp = 'settings' in appOrRouter; + + // In case the app's top-level router hasn't been initialized yet, we have to do it now + if (isApp && appOrRouter._router === undefined && appOrRouter.lazyrouter) { + appOrRouter.lazyrouter(); + } + + const router = isApp ? appOrRouter._router : appOrRouter; + + if (!router) { + /* + If we end up here, this means likely that this integration is used with Express 3 or Express 5. + For now, we don't support these versions (3 is very old and 5 is still in beta). To support Express 5, + we'd need to make more changes to the routing instrumentation because the router is no longer part of + the Express core package but maintained in its own package. The new router has different function + signatures and works slightly differently, demanding more changes than just taking the router from + `app.router` instead of `app._router`. + @see https://github.com/pillarjs/router + + TODO: Proper Express 5 support + */ + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.debug('Cannot instrument router for URL Parameterization (did not find a valid router).'); + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.debug('Routing instrumentation is currently only supported in Express 4.'); + return; + } + + const routerProto = Object.getPrototypeOf(router) ; + + const originalProcessParams = routerProto.process_params; + routerProto.process_params = function process_params( + layer, + called, + req, + res, + done, + ) { + // Base case: We're in the first part of the URL (thus we start with the root '/') + if (!req._reconstructedRoute) { + req._reconstructedRoute = ''; + } + + // If the layer's partial route has params, is a regex or an array, the route is stored in layer.route. + const { layerRoutePath, isRegex, isArray, numExtraSegments } = getLayerRoutePathInfo(layer); + + if (layerRoutePath || isRegex || isArray) { + req._hasParameters = true; + } + + // Otherwise, the hardcoded path (i.e. a partial route without params) is stored in layer.path + const partialRoute = layerRoutePath || layer.path || ''; + + // Normalize the partial route so that it doesn't contain leading or trailing slashes + // and exclude empty or '*' wildcard routes. + // The exclusion of '*' routes is our best effort to not "pollute" the transaction name + // with interim handlers (e.g. ones that check authentication or do other middleware stuff). + // We want to end up with the parameterized URL of the incoming request without any extraneous path segments. + const finalPartialRoute = partialRoute + .split('/') + .filter(segment => segment.length > 0 && (isRegex || isArray || !segment.includes('*'))) + .join('/'); + + // If we found a valid partial URL, we append it to the reconstructed route + if (finalPartialRoute && finalPartialRoute.length > 0) { + // If the partial route is from a regex route, we append a '/' to close the regex + req._reconstructedRoute += `/${finalPartialRoute}${isRegex ? '/' : ''}`; + } + + // Now we check if we are in the "last" part of the route. We determine this by comparing the + // number of URL segments from the original URL to that of our reconstructed parameterized URL. + // If we've reached our final destination, we update the transaction name. + const urlLength = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(req.originalUrl || '') + numExtraSegments; + const routeLength = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(req._reconstructedRoute); + + if (urlLength === routeLength) { + if (!req._hasParameters) { + if (req._reconstructedRoute !== req.originalUrl) { + req._reconstructedRoute = req.originalUrl; + } + } + + const transaction = res.__sentry_transaction; + if (transaction && transaction.metadata.source !== 'custom') { + // If the request URL is '/' or empty, the reconstructed route will be empty. + // Therefore, we fall back to setting the final route to '/' in this case. + const finalRoute = req._reconstructedRoute || '/'; + + transaction.setName(...(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.extractPathForTransaction)(req, { path: true, method: true, customRoute: finalRoute })); + } + } + + return originalProcessParams.call(this, layer, called, req, res, done); + }; +} + +/** + * Extracts and stringifies the layer's route which can either be a string with parameters (`users/:id`), + * a RegEx (`/test/`) or an array of strings and regexes (`['/path1', /\/path[2-5]/, /path/:id]`). Additionally + * returns extra information about the route, such as if the route is defined as regex or as an array. + * + * @param layer the layer to extract the stringified route from + * + * @returns an object containing the stringified route, a flag determining if the route was a regex + * and the number of extra segments to the matched path that are additionally in the route, + * if the route was an array (defaults to 0). + */ +function getLayerRoutePathInfo(layer) { + const lrp = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([layer, 'access', _10 => _10.route, 'optionalAccess', _11 => _11.path]); + + const isRegex = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isRegExp)(lrp); + const isArray = Array.isArray(lrp); + + if (!lrp) { + return { isRegex, isArray, numExtraSegments: 0 }; + } + + const numExtraSegments = isArray + ? Math.max(getNumberOfArrayUrlSegments(lrp ) - (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(layer.path || ''), 0) + : 0; + + const layerRoutePath = getLayerRoutePathString(isArray, lrp); + + return { layerRoutePath, isRegex, isArray, numExtraSegments }; +} + +/** + * Returns the number of URL segments in an array of routes + * + * Example: ['/api/test', /\/api\/post[0-9]/, '/users/:id/details`] -> 7 + */ +function getNumberOfArrayUrlSegments(routesArray) { + return routesArray.reduce((accNumSegments, currentRoute) => { + // array members can be a RegEx -> convert them toString + return accNumSegments + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(currentRoute.toString()); + }, 0); +} + +/** + * Extracts and returns the stringified version of the layers route path + * Handles route arrays (by joining the paths together) as well as RegExp and normal + * string values (in the latter case the toString conversion is technically unnecessary but + * it doesn't hurt us either). + */ +function getLayerRoutePathString(isArray, lrp) { + if (isArray) { + return (lrp ).map(r => r.toString()).join(','); + } + return lrp && lrp.toString(); +} + + +//# sourceMappingURL=express.js.map + + +/***/ }), +/* 1704 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "shouldDisableAutoInstrumentation": () => (/* binding */ shouldDisableAutoInstrumentation) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1625); + + +/** + * Check if Sentry auto-instrumentation should be disabled. + * + * @param getCurrentHub A method to fetch the current hub + * @returns boolean + */ +function shouldDisableAutoInstrumentation(getCurrentHub) { + const clientOptions = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__._optionalChain)([getCurrentHub, 'call', _ => _(), 'access', _2 => _2.getClient, 'call', _3 => _3(), 'optionalAccess', _4 => _4.getOptions, 'call', _5 => _5()]); + const instrumenter = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__._optionalChain)([clientOptions, 'optionalAccess', _6 => _6.instrumenter]) || 'sentry'; + + return instrumenter !== 'sentry'; +} + + +//# sourceMappingURL=node-utils.js.map + + +/***/ }), +/* 1705 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Postgres": () => (/* binding */ Postgres) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1607); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1612); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1704); + + + + +/** Tracing integration for node-postgres package */ +class Postgres { + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Postgres';} + + /** + * @inheritDoc + */ + __init() {this.name = Postgres.id;} + + constructor(options = {}) {;Postgres.prototype.__init.call(this); + this._usePgNative = !!options.usePgNative; + } + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)('pg'); + + if (!pkg) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Postgres Integration was unable to require `pg` package.'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Postgres Integration is skipped because of instrumenter configuration.'); + return; + } + + if (this._usePgNative && !(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([pkg, 'access', _2 => _2.native, 'optionalAccess', _3 => _3.Client])) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error("Postgres Integration was unable to access 'pg-native' bindings."); + return; + } + + const { Client } = this._usePgNative ? pkg.native : pkg; + + /** + * function (query, callback) => void + * function (query, params, callback) => void + * function (query) => Promise + * function (query, params) => Promise + * function (pg.Cursor) => pg.Cursor + */ + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.fill)(Client.prototype, 'query', function (orig) { + return function ( config, values, callback) { + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([scope, 'optionalAccess', _4 => _4.getSpan, 'call', _5 => _5()]); + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([parentSpan, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({ + description: typeof config === 'string' ? config : (config ).text, + op: 'db', + })]); + + if (typeof callback === 'function') { + return orig.call(this, config, values, function (err, result) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + callback(err, result); + }); + } + + if (typeof values === 'function') { + return orig.call(this, config, function (err, result) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _10 => _10.finish, 'call', _11 => _11()]); + values(err, result); + }); + } + + const rv = typeof values !== 'undefined' ? orig.call(this, config, values) : orig.call(this, config); + + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(rv)) { + return rv.then((res) => { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]); + return res; + }); + } + + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _14 => _14.finish, 'call', _15 => _15()]); + return rv; + }; + }); + } +}Postgres.__initStatic(); + + +//# sourceMappingURL=postgres.js.map + + +/***/ }), +/* 1706 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Mysql": () => (/* binding */ Mysql) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1607); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1704); + + + + +/** Tracing integration for node-mysql package */ +class Mysql {constructor() { Mysql.prototype.__init.call(this); } + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Mysql';} + + /** + * @inheritDoc + */ + __init() {this.name = Mysql.id;} + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)('mysql/lib/Connection.js'); + + if (!pkg) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Mysql Integration was unable to require `mysql` package.'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Mysql Integration is skipped because of instrumenter configuration.'); + return; + } + + // The original function will have one of these signatures: + // function (callback) => void + // function (options, callback) => void + // function (options, values, callback) => void + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg, 'createQuery', function (orig) { + return function ( options, values, callback) { + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]); + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({ + description: typeof options === 'string' ? options : (options ).sql, + op: 'db', + })]); + + if (typeof callback === 'function') { + return orig.call(this, options, values, function (err, result, fields) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]); + callback(err, result, fields); + }); + } + + if (typeof values === 'function') { + return orig.call(this, options, function (err, result, fields) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + values(err, result, fields); + }); + } + + return orig.call(this, options, values, callback); + }; + }); + } +}Mysql.__initStatic(); + + +//# sourceMappingURL=mysql.js.map + + +/***/ }), +/* 1707 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Mongo": () => (/* binding */ Mongo) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1607); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1704); + + + + +// This allows us to use the same array for both defaults options and the type itself. +// (note `as const` at the end to make it a union of string literal types (i.e. "a" | "b" | ... ) +// and not just a string[]) + +const OPERATIONS = [ + 'aggregate', // aggregate(pipeline, options, callback) + 'bulkWrite', // bulkWrite(operations, options, callback) + 'countDocuments', // countDocuments(query, options, callback) + 'createIndex', // createIndex(fieldOrSpec, options, callback) + 'createIndexes', // createIndexes(indexSpecs, options, callback) + 'deleteMany', // deleteMany(filter, options, callback) + 'deleteOne', // deleteOne(filter, options, callback) + 'distinct', // distinct(key, query, options, callback) + 'drop', // drop(options, callback) + 'dropIndex', // dropIndex(indexName, options, callback) + 'dropIndexes', // dropIndexes(options, callback) + 'estimatedDocumentCount', // estimatedDocumentCount(options, callback) + 'find', // find(query, options, callback) + 'findOne', // findOne(query, options, callback) + 'findOneAndDelete', // findOneAndDelete(filter, options, callback) + 'findOneAndReplace', // findOneAndReplace(filter, replacement, options, callback) + 'findOneAndUpdate', // findOneAndUpdate(filter, update, options, callback) + 'indexes', // indexes(options, callback) + 'indexExists', // indexExists(indexes, options, callback) + 'indexInformation', // indexInformation(options, callback) + 'initializeOrderedBulkOp', // initializeOrderedBulkOp(options, callback) + 'insertMany', // insertMany(docs, options, callback) + 'insertOne', // insertOne(doc, options, callback) + 'isCapped', // isCapped(options, callback) + 'mapReduce', // mapReduce(map, reduce, options, callback) + 'options', // options(options, callback) + 'parallelCollectionScan', // parallelCollectionScan(options, callback) + 'rename', // rename(newName, options, callback) + 'replaceOne', // replaceOne(filter, doc, options, callback) + 'stats', // stats(options, callback) + 'updateMany', // updateMany(filter, update, options, callback) + 'updateOne', // updateOne(filter, update, options, callback) +] ; + +// All of the operations above take `options` and `callback` as their final parameters, but some of them +// take additional parameters as well. For those operations, this is a map of +// { <operation name>: [<names of additional parameters>] }, as a way to know what to call the operation's +// positional arguments when we add them to the span's `data` object later +const OPERATION_SIGNATURES + + = { + // aggregate intentionally not included because `pipeline` arguments are too complex to serialize well + // see https://github.com/getsentry/sentry-javascript/pull/3102 + bulkWrite: ['operations'], + countDocuments: ['query'], + createIndex: ['fieldOrSpec'], + createIndexes: ['indexSpecs'], + deleteMany: ['filter'], + deleteOne: ['filter'], + distinct: ['key', 'query'], + dropIndex: ['indexName'], + find: ['query'], + findOne: ['query'], + findOneAndDelete: ['filter'], + findOneAndReplace: ['filter', 'replacement'], + findOneAndUpdate: ['filter', 'update'], + indexExists: ['indexes'], + insertMany: ['docs'], + insertOne: ['doc'], + mapReduce: ['map', 'reduce'], + rename: ['newName'], + replaceOne: ['filter', 'doc'], + updateMany: ['filter', 'update'], + updateOne: ['filter', 'update'], +}; + +/** Tracing integration for mongo package */ +class Mongo { + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Mongo';} + + /** + * @inheritDoc + */ + __init() {this.name = Mongo.id;} + + /** + * @inheritDoc + */ + constructor(options = {}) {;Mongo.prototype.__init.call(this); + this._operations = Array.isArray(options.operations) ? options.operations : (OPERATIONS ); + this._describeOperations = 'describeOperations' in options ? options.describeOperations : true; + this._useMongoose = !!options.useMongoose; + } + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + const moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; + const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule)(moduleName); + + if (!pkg) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error(`Mongo Integration was unable to require \`${moduleName}\` package.`); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Mongo Integration is skipped because of instrumenter configuration.'); + return; + } + + this._instrumentOperations(pkg.Collection, this._operations, getCurrentHub); + } + + /** + * Patches original collection methods + */ + _instrumentOperations(collection, operations, getCurrentHub) { + operations.forEach((operation) => this._patchOperation(collection, operation, getCurrentHub)); + } + + /** + * Patches original collection to utilize our tracing functionality + */ + _patchOperation(collection, operation, getCurrentHub) { + if (!(operation in collection.prototype)) return; + + const getSpanContext = this._getSpanContextFromOperationArguments.bind(this); + + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(collection.prototype, operation, function (orig) { + return function ( ...args) { + const lastArg = args[args.length - 1]; + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]); + + // Check if the operation was passed a callback. (mapReduce requires a different check, as + // its (non-callback) arguments can also be functions.) + if (typeof lastArg !== 'function' || (operation === 'mapReduce' && args.length === 2)) { + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5(getSpanContext(this, operation, args))]); + const maybePromise = orig.call(this, ...args) ; + + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(maybePromise)) { + return maybePromise.then((res) => { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]); + return res; + }); + } else { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + return maybePromise; + } + } + + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _10 => _10.startChild, 'call', _11 => _11(getSpanContext(this, operation, args.slice(0, -1)))]); + return orig.call(this, ...args.slice(0, -1), function (err, result) { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]); + lastArg(err, result); + }); + }; + }); + } + + /** + * Form a SpanContext based on the user input to a given operation. + */ + _getSpanContextFromOperationArguments( + collection, + operation, + args, + ) { + const data = { + collectionName: collection.collectionName, + dbName: collection.dbName, + namespace: collection.namespace, + }; + const spanContext = { + op: 'db', + description: operation, + data, + }; + + // If the operation takes no arguments besides `options` and `callback`, or if argument + // collection is disabled for this operation, just return early. + const signature = OPERATION_SIGNATURES[operation]; + const shouldDescribe = Array.isArray(this._describeOperations) + ? this._describeOperations.includes(operation) + : this._describeOperations; + + if (!signature || !shouldDescribe) { + return spanContext; + } + + try { + // Special case for `mapReduce`, as the only one accepting functions as arguments. + if (operation === 'mapReduce') { + const [map, reduce] = args ; + data[signature[0]] = typeof map === 'string' ? map : map.name || '<anonymous>'; + data[signature[1]] = typeof reduce === 'string' ? reduce : reduce.name || '<anonymous>'; + } else { + for (let i = 0; i < signature.length; i++) { + data[signature[i]] = JSON.stringify(args[i]); + } + } + } catch (_oO) { + // no-empty + } + + return spanContext; + } +}Mongo.__initStatic(); + + +//# sourceMappingURL=mongo.js.map + + +/***/ }), +/* 1708 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Prisma": () => (/* binding */ Prisma) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1704); + + + + +function isValidPrismaClient(possibleClient) { + return possibleClient && !!(possibleClient )['$use']; +} + +/** Tracing integration for @prisma/client package */ +class Prisma { + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Prisma';} + + /** + * @inheritDoc + */ + __init() {this.name = Prisma.id;} + + /** + * Prisma ORM Client Instance + */ + + /** + * @inheritDoc + */ + constructor(options = {}) {;Prisma.prototype.__init.call(this); + if (isValidPrismaClient(options.client)) { + this._client = options.client; + } else { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn( + `Unsupported Prisma client provided to PrismaIntegration. Provided client: ${JSON.stringify(options.client)}`, + ); + } + } + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + if (!this._client) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error('PrismaIntegration is missing a Prisma Client Instance'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.log('Prisma Integration is skipped because of instrumenter configuration.'); + return; + } + + this._client.$use((params, next) => { + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]); + + const action = params.action; + const model = params.model; + + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({ + description: model ? `${model} ${action}` : action, + op: 'db.sql.prisma', + })]); + + const rv = next(params); + + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isThenable)(rv)) { + return rv.then((res) => { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]); + return res; + }); + } + + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + return rv; + }); + } +}Prisma.__initStatic(); + + +//# sourceMappingURL=prisma.js.map + + +/***/ }), +/* 1709 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "GraphQL": () => (/* binding */ GraphQL) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1607); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1704); + + + + +/** Tracing integration for graphql package */ +class GraphQL {constructor() { GraphQL.prototype.__init.call(this); } + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'GraphQL';} + + /** + * @inheritDoc + */ + __init() {this.name = GraphQL.id;} + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule) + +('graphql/execution/execute.js'); + + if (!pkg) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('GraphQL Integration was unable to require graphql/execution package.'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('GraphQL Integration is skipped because of instrumenter configuration.'); + return; + } + + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg, 'execute', function (orig) { + return function ( ...args) { + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]); + + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({ + description: 'execute', + op: 'graphql.execute', + })]); + + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _6 => _6.setSpan, 'call', _7 => _7(span)]); + + const rv = orig.call(this, ...args); + + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(rv)) { + return rv.then((res) => { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _10 => _10.setSpan, 'call', _11 => _11(parentSpan)]); + + return res; + }); + } + + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]); + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _14 => _14.setSpan, 'call', _15 => _15(parentSpan)]); + return rv; + }; + }); + } +}GraphQL.__initStatic(); + + +//# sourceMappingURL=graphql.js.map + + +/***/ }), +/* 1710 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Apollo": () => (/* binding */ Apollo) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1607); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1612); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1609); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1611); +/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1704); + + + + +/** Tracing integration for Apollo */ +class Apollo {constructor() { Apollo.prototype.__init.call(this); } + /** + * @inheritDoc + */ + static __initStatic() {this.id = 'Apollo';} + + /** + * @inheritDoc + */ + __init() {this.name = Apollo.id;} + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.loadModule) + +('apollo-server-core'); + + if (!pkg) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Apollo Integration was unable to require apollo-server-core package.'); + return; + } + + if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_2__.shouldDisableAutoInstrumentation)(getCurrentHub)) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Apollo Integration is skipped because of instrumenter configuration.'); + return; + } + + /** + * Iterate over resolvers of the ApolloServer instance before schemas are constructed. + */ + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg.ApolloServerBase.prototype, 'constructSchema', function (orig) { + return function () { + if (!this.config.resolvers) { + if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) { + if (this.config.schema) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn( + 'Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.', + ); + } else if (this.config.modules) { + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn( + 'Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property.', + ); + } + + _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Skipping tracing as no resolvers found on the `ApolloServer` instance.'); + } + + return orig.call(this); + } + + const resolvers = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.arrayify)(this.config.resolvers); + + this.config.resolvers = resolvers.map(model => { + Object.keys(model).forEach(resolverGroupName => { + Object.keys(model[resolverGroupName]).forEach(resolverName => { + if (typeof model[resolverGroupName][resolverName] !== 'function') { + return; + } + + wrapResolver(model, resolverGroupName, resolverName, getCurrentHub); + }); + }); + + return model; + }); + + return orig.call(this); + }; + }); + } +}Apollo.__initStatic(); + +/** + * Wrap a single resolver which can be a parent of other resolvers and/or db operations. + */ +function wrapResolver( + model, + resolverGroupName, + resolverName, + getCurrentHub, +) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(model[resolverGroupName], resolverName, function (orig) { + return function ( ...args) { + const scope = getCurrentHub().getScope(); + const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]); + const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({ + description: `${resolverGroupName}.${resolverName}`, + op: 'graphql.resolve', + })]); + + const rv = orig.call(this, ...args); + + if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.isThenable)(rv)) { + return rv.then((res) => { + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]); + return res; + }); + } + + (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]); + + return rv; + }; + }); +} + + +//# sourceMappingURL=apollo.js.map + + +/***/ }), +/* 1711 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BROWSER_TRACING_INTEGRATION_ID": () => (/* binding */ BROWSER_TRACING_INTEGRATION_ID), +/* harmony export */ "BrowserTracing": () => (/* binding */ BrowserTracing), +/* harmony export */ "getMetaContent": () => (/* binding */ getMetaContent) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1625); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1679); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1657); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1613); +/* harmony import */ var _hubextensions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1694); +/* harmony import */ var _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1698); +/* harmony import */ var _backgroundtab_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1728); +/* harmony import */ var _metrics_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1715); +/* harmony import */ var _request_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1714); +/* harmony import */ var _router_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1712); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1713); + + + + + + + + + + + +const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing'; + +/** Options for Browser Tracing integration */ + +const DEFAULT_BROWSER_TRACING_OPTIONS = { + idleTimeout: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_IDLE_TIMEOUT, + finalTimeout: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_FINAL_TIMEOUT, + heartbeatInterval: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_HEARTBEAT_INTERVAL, + markBackgroundTransactions: true, + routingInstrumentation: _router_js__WEBPACK_IMPORTED_MODULE_1__.instrumentRoutingWithDefaults, + startTransactionOnLocationChange: true, + startTransactionOnPageLoad: true, + _experiments: { enableLongTask: true }, + ..._request_js__WEBPACK_IMPORTED_MODULE_2__.defaultRequestInstrumentationOptions, +}; + +/** + * The Browser Tracing integration automatically instruments browser pageload/navigation + * actions as transactions, and captures requests, metrics and errors as spans. + * + * The integration can be configured with a variety of options, and can be extended to use + * any routing library. This integration uses {@see IdleTransaction} to create transactions. + */ +class BrowserTracing { + // This class currently doesn't have a static `id` field like the other integration classes, because it prevented + // @sentry/tracing from being treeshaken. Tree shakers do not like static fields, because they behave like side effects. + // TODO: Come up with a better plan, than using static fields on integration classes, and use that plan on all + // integrations. + + /** Browser Tracing integration options */ + + /** + * @inheritDoc + */ + __init() {this.name = BROWSER_TRACING_INTEGRATION_ID;} + + constructor(_options) {;BrowserTracing.prototype.__init.call(this); + this.options = { + ...DEFAULT_BROWSER_TRACING_OPTIONS, + ..._options, + }; + + // TODO (v8): remove this block after tracingOrigins is removed + // Set tracePropagationTargets to tracingOrigins if specified by the user + // In case both are specified, tracePropagationTargets takes precedence + // eslint-disable-next-line deprecation/deprecation + if (_options && !_options.tracePropagationTargets && _options.tracingOrigins) { + // eslint-disable-next-line deprecation/deprecation + this.options.tracePropagationTargets = _options.tracingOrigins; + } + + const { _metricOptions } = this.options; + (0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.startTrackingWebVitals)(_metricOptions && _metricOptions._reportAllChanges); + if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([this, 'access', _2 => _2.options, 'access', _3 => _3._experiments, 'optionalAccess', _4 => _4.enableLongTask])) { + (0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.startTrackingLongTasks)(); + } + } + + /** + * @inheritDoc + */ + setupOnce(_, getCurrentHub) { + this._getCurrentHub = getCurrentHub; + + // eslint-disable-next-line @typescript-eslint/unbound-method + const { + routingInstrumentation: instrumentRouting, + startTransactionOnLocationChange, + startTransactionOnPageLoad, + markBackgroundTransactions, + traceFetch, + traceXHR, + tracePropagationTargets, + shouldCreateSpanForRequest, + } = this.options; + + instrumentRouting( + (context) => this._createRouteTransaction(context), + startTransactionOnPageLoad, + startTransactionOnLocationChange, + ); + + if (markBackgroundTransactions) { + (0,_backgroundtab_js__WEBPACK_IMPORTED_MODULE_5__.registerBackgroundTabDetection)(); + } + + (0,_request_js__WEBPACK_IMPORTED_MODULE_2__.instrumentOutgoingRequests)({ + traceFetch, + traceXHR, + tracePropagationTargets, + shouldCreateSpanForRequest, + }); + } + + /** Create routing idle transaction. */ + _createRouteTransaction(context) { + if (!this._getCurrentHub) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.warn(`[Tracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`); + return undefined; + } + + // eslint-disable-next-line @typescript-eslint/unbound-method + const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this.options; + + const isPageloadTransaction = context.op === 'pageload'; + + const sentryTraceMetaTagValue = isPageloadTransaction ? getMetaContent('sentry-trace') : null; + const baggageMetaTagValue = isPageloadTransaction ? getMetaContent('baggage') : null; + + const traceParentData = sentryTraceMetaTagValue ? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.extractTraceparentData)(sentryTraceMetaTagValue) : undefined; + const dynamicSamplingContext = baggageMetaTagValue + ? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.baggageHeaderToDynamicSamplingContext)(baggageMetaTagValue) + : undefined; + + const expandedContext = { + ...context, + ...traceParentData, + metadata: { + ...context.metadata, + dynamicSamplingContext: traceParentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, + }, + trimEnd: true, + }; + + const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext; + + // For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it + // from being sent to Sentry). + const finalContext = modifiedContext === undefined ? { ...expandedContext, sampled: false } : modifiedContext; + + // If `beforeNavigate` set a custom name, record that fact + finalContext.metadata = + finalContext.name !== expandedContext.name + ? { ...finalContext.metadata, source: 'custom' } + : finalContext.metadata; + + if (finalContext.sampled === false) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.log(`[Tracing] Will not send ${finalContext.op} transaction because of beforeNavigate.`); + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.log(`[Tracing] Starting ${finalContext.op} transaction on scope`); + + const hub = this._getCurrentHub(); + const { location } = _types_js__WEBPACK_IMPORTED_MODULE_9__.WINDOW; + + const idleTransaction = (0,_hubextensions_js__WEBPACK_IMPORTED_MODULE_10__.startIdleTransaction)( + hub, + finalContext, + idleTimeout, + finalTimeout, + true, + { location }, // for use in the tracesSampler + heartbeatInterval, + ); + idleTransaction.registerBeforeFinishCallback(transaction => { + (0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.addPerformanceEntries)(transaction); + transaction.setTag( + 'sentry_reportAllChanges', + Boolean(this.options._metricOptions && this.options._metricOptions._reportAllChanges), + ); + }); + + return idleTransaction ; + } +} + +/** Returns the value of a meta tag */ +function getMetaContent(metaName) { + // Can't specify generic to `getDomElement` because tracing can be used + // in a variety of environments, have to disable `no-unsafe-member-access` + // as a result. + const metaTag = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.getDomElement)(`meta[name=${metaName}]`); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return metaTag ? metaTag.getAttribute('content') : null; +} + + +//# sourceMappingURL=browsertracing.js.map + + +/***/ }), +/* 1712 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "instrumentRoutingWithDefaults": () => (/* binding */ instrumentRoutingWithDefaults) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1700); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); + + + +/** + * Default function implementing pageload and navigation transactions + */ +function instrumentRoutingWithDefaults( + customStartTransaction, + startTransactionOnPageLoad = true, + startTransactionOnLocationChange = true, +) { + if (!_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW || !_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not initialize routing instrumentation due to invalid location'); + return; + } + + let startingUrl = _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.href; + + let activeTransaction; + if (startTransactionOnPageLoad) { + activeTransaction = customStartTransaction({ + name: _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.pathname, + op: 'pageload', + metadata: { source: 'url' }, + }); + } + + if (startTransactionOnLocationChange) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)('history', ({ to, from }) => { + /** + * This early return is there to account for some cases where a navigation transaction starts right after + * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't + * create an uneccessary navigation transaction. + * + * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also + * only be caused in certain development environments where the usage of a hot module reloader is causing + * errors. + */ + if (from === undefined && startingUrl && startingUrl.indexOf(to) !== -1) { + startingUrl = undefined; + return; + } + + if (from !== to) { + startingUrl = undefined; + if (activeTransaction) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log(`[Tracing] Finishing current transaction with op: ${activeTransaction.op}`); + // If there's an open transaction on the scope, we need to finish it before creating an new one. + activeTransaction.finish(); + } + activeTransaction = customStartTransaction({ + name: _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.pathname, + op: 'navigation', + metadata: { source: 'url' }, + }); + } + }); + } +} + + +//# sourceMappingURL=router.js.map + + +/***/ }), +/* 1713 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "WINDOW": () => (/* binding */ WINDOW) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1606); + + +const WINDOW = _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.GLOBAL_OBJ ; + + +//# sourceMappingURL=types.js.map + + +/***/ }), +/* 1714 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_TRACE_PROPAGATION_TARGETS": () => (/* binding */ DEFAULT_TRACE_PROPAGATION_TARGETS), +/* harmony export */ "defaultRequestInstrumentationOptions": () => (/* binding */ defaultRequestInstrumentationOptions), +/* harmony export */ "fetchCallback": () => (/* binding */ fetchCallback), +/* harmony export */ "instrumentOutgoingRequests": () => (/* binding */ instrumentOutgoingRequests), +/* harmony export */ "shouldAttachHeaders": () => (/* binding */ shouldAttachHeaders), +/* harmony export */ "xhrCallback": () => (/* binding */ xhrCallback) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1700); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1610); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1657); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1611); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1695); + + + +const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\//]; + +/** Options for Request Instrumentation */ + +const defaultRequestInstrumentationOptions = { + traceFetch: true, + traceXHR: true, + // TODO (v8): Remove this property + tracingOrigins: DEFAULT_TRACE_PROPAGATION_TARGETS, + tracePropagationTargets: DEFAULT_TRACE_PROPAGATION_TARGETS, +}; + +/** Registers span creators for xhr and fetch requests */ +function instrumentOutgoingRequests(_options) { + // eslint-disable-next-line deprecation/deprecation + const { traceFetch, traceXHR, tracePropagationTargets, tracingOrigins, shouldCreateSpanForRequest } = { + traceFetch: defaultRequestInstrumentationOptions.traceFetch, + traceXHR: defaultRequestInstrumentationOptions.traceXHR, + ..._options, + }; + + const shouldCreateSpan = + typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_) => true; + + // TODO(v8) Remove tracingOrigins here + // The only reason we're passing it in here is because this instrumentOutgoingRequests function is publicly exported + // and we don't want to break the API. We can remove it in v8. + const shouldAttachHeadersWithTargets = (url) => + shouldAttachHeaders(url, tracePropagationTargets || tracingOrigins); + + const spans = {}; + + if (traceFetch) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('fetch', (handlerData) => { + fetchCallback(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans); + }); + } + + if (traceXHR) { + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('xhr', (handlerData) => { + xhrCallback(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans); + }); + } +} + +/** + * A function that determines whether to attach tracing headers to a request. + * This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders. + * We only export this fuction for testing purposes. + */ +function shouldAttachHeaders(url, tracePropagationTargets) { + return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.stringMatchesSomePattern)(url, tracePropagationTargets || DEFAULT_TRACE_PROPAGATION_TARGETS); +} + +/** + * Create and track fetch request spans + */ +function fetchCallback( + handlerData, + shouldCreateSpan, + shouldAttachHeaders, + spans, +) { + if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.hasTracingEnabled)() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) { + return; + } + + if (handlerData.endTimestamp) { + const spanId = handlerData.fetchData.__span; + if (!spanId) return; + + const span = spans[spanId]; + if (span) { + if (handlerData.response) { + // TODO (kmclb) remove this once types PR goes through + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + span.setHttpStatus(handlerData.response.status); + } else if (handlerData.error) { + span.setStatus('internal_error'); + } + span.finish(); + + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[spanId]; + } + return; + } + + const activeTransaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getActiveTransaction)(); + if (activeTransaction) { + const span = activeTransaction.startChild({ + data: { + ...handlerData.fetchData, + type: 'fetch', + }, + description: `${handlerData.fetchData.method} ${handlerData.fetchData.url}`, + op: 'http.client', + }); + + handlerData.fetchData.__span = span.spanId; + spans[span.spanId] = span; + + const request = handlerData.args[0]; + + // In case the user hasn't set the second argument of a fetch call we default it to `{}`. + handlerData.args[1] = handlerData.args[1] || {}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const options = handlerData.args[1]; + + if (shouldAttachHeaders(handlerData.fetchData.url)) { + options.headers = addTracingHeadersToFetchRequest( + request, + activeTransaction.getDynamicSamplingContext(), + span, + options, + ); + + activeTransaction.metadata.propagations += 1; + } + } +} + +function addTracingHeadersToFetchRequest( + request, + dynamicSamplingContext, + span, + options + +, +) { + const sentryBaggageHeader = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dynamicSamplingContextToSentryBaggageHeader)(dynamicSamplingContext); + const sentryTraceHeader = span.toTraceparent(); + + const headers = + typeof Request !== 'undefined' && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(request, Request) ? (request ).headers : options.headers; + + if (!headers) { + return { 'sentry-trace': sentryTraceHeader, baggage: sentryBaggageHeader }; + } else if (typeof Headers !== 'undefined' && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(headers, Headers)) { + const newHeaders = new Headers(headers ); + + newHeaders.append('sentry-trace', sentryTraceHeader); + + if (sentryBaggageHeader) { + // If the same header is appended miultiple times the browser will merge the values into a single request header. + // Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header. + newHeaders.append(_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.BAGGAGE_HEADER_NAME, sentryBaggageHeader); + } + + return newHeaders ; + } else if (Array.isArray(headers)) { + const newHeaders = [...headers, ['sentry-trace', sentryTraceHeader]]; + + if (sentryBaggageHeader) { + // If there are multiple entries with the same key, the browser will merge the values into a single request header. + // Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header. + newHeaders.push([_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.BAGGAGE_HEADER_NAME, sentryBaggageHeader]); + } + + return newHeaders; + } else { + const existingBaggageHeader = 'baggage' in headers ? headers.baggage : undefined; + const newBaggageHeaders = []; + + if (Array.isArray(existingBaggageHeader)) { + newBaggageHeaders.push(...existingBaggageHeader); + } else if (existingBaggageHeader) { + newBaggageHeaders.push(existingBaggageHeader); + } + + if (sentryBaggageHeader) { + newBaggageHeaders.push(sentryBaggageHeader); + } + + return { + ...(headers ), + 'sentry-trace': sentryTraceHeader, + baggage: newBaggageHeaders.length > 0 ? newBaggageHeaders.join(',') : undefined, + }; + } +} + +/** + * Create and track xhr request spans + */ +function xhrCallback( + handlerData, + shouldCreateSpan, + shouldAttachHeaders, + spans, +) { + if ( + !(0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.hasTracingEnabled)() || + (handlerData.xhr && handlerData.xhr.__sentry_own_request__) || + !(handlerData.xhr && handlerData.xhr.__sentry_xhr__ && shouldCreateSpan(handlerData.xhr.__sentry_xhr__.url)) + ) { + return; + } + + const xhr = handlerData.xhr.__sentry_xhr__; + + // check first if the request has finished and is tracked by an existing span which should now end + if (handlerData.endTimestamp) { + const spanId = handlerData.xhr.__sentry_xhr_span_id__; + if (!spanId) return; + + const span = spans[spanId]; + if (span) { + span.setHttpStatus(xhr.status_code); + span.finish(); + + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[spanId]; + } + return; + } + + // if not, create a new span to track it + const activeTransaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getActiveTransaction)(); + if (activeTransaction) { + const span = activeTransaction.startChild({ + data: { + ...xhr.data, + type: 'xhr', + method: xhr.method, + url: xhr.url, + }, + description: `${xhr.method} ${xhr.url}`, + op: 'http.client', + }); + + handlerData.xhr.__sentry_xhr_span_id__ = span.spanId; + spans[handlerData.xhr.__sentry_xhr_span_id__] = span; + + if (handlerData.xhr.setRequestHeader && shouldAttachHeaders(handlerData.xhr.__sentry_xhr__.url)) { + try { + handlerData.xhr.setRequestHeader('sentry-trace', span.toTraceparent()); + + const dynamicSamplingContext = activeTransaction.getDynamicSamplingContext(); + const sentryBaggageHeader = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dynamicSamplingContextToSentryBaggageHeader)(dynamicSamplingContext); + + if (sentryBaggageHeader) { + // From MDN: "If this method is called several times with the same header, the values are merged into one single request header." + // We can therefore simply set a baggage header without checking what was there before + // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader + handlerData.xhr.setRequestHeader(_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.BAGGAGE_HEADER_NAME, sentryBaggageHeader); + } + + activeTransaction.metadata.propagations += 1; + } catch (_) { + // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED. + } + } + } +} + + +//# sourceMappingURL=request.js.map + + +/***/ }), +/* 1715 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_addMeasureSpans": () => (/* binding */ _addMeasureSpans), +/* harmony export */ "_addResourceSpans": () => (/* binding */ _addResourceSpans), +/* harmony export */ "addPerformanceEntries": () => (/* binding */ addPerformanceEntries), +/* harmony export */ "startTrackingLongTasks": () => (/* binding */ startTrackingLongTasks), +/* harmony export */ "startTrackingWebVitals": () => (/* binding */ startTrackingWebVitals) +/* harmony export */ }); +/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1650); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1605); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1615); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1613); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1695); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); +/* harmony import */ var _web_vitals_getCLS_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1717); +/* harmony import */ var _web_vitals_getFID_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1726); +/* harmony import */ var _web_vitals_getLCP_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1724); +/* harmony import */ var _web_vitals_lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1725); +/* harmony import */ var _web_vitals_lib_observe_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1716); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1727); + + + + + + + + + + + +function getBrowserPerformanceAPI() { + return _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW && _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.addEventListener && _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance; +} + +let _performanceCursor = 0; + +let _measurements = {}; +let _lcpEntry; +let _clsEntry; + +/** + * Start tracking web vitals + */ +function startTrackingWebVitals(reportAllChanges = false) { + const performance = getBrowserPerformanceAPI(); + if (performance && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.browserPerformanceTimeOrigin) { + if (performance.mark) { + _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance.mark('sentry-tracing-init'); + } + _trackCLS(); + _trackLCP(reportAllChanges); + _trackFID(); + } +} + +/** + * Start tracking long tasks. + */ +function startTrackingLongTasks() { + const entryHandler = (entries) => { + for (const entry of entries) { + const transaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getActiveTransaction)() ; + if (!transaction) { + return; + } + const startTime = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)((_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.browserPerformanceTimeOrigin ) + entry.startTime); + const duration = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.duration); + + transaction.startChild({ + description: 'Main UI thread blocked', + op: 'ui.long-task', + startTimestamp: startTime, + endTimestamp: startTime + duration, + }); + } + }; + + (0,_web_vitals_lib_observe_js__WEBPACK_IMPORTED_MODULE_3__.observe)('longtask', entryHandler); +} + +/** Starts tracking the Cumulative Layout Shift on the current page. */ +function _trackCLS() { + // See: + // https://web.dev/evolving-cls/ + // https://web.dev/cls-web-tooling/ + (0,_web_vitals_getCLS_js__WEBPACK_IMPORTED_MODULE_4__.onCLS)(metric => { + const entry = metric.entries.pop(); + if (!entry) { + return; + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding CLS'); + _measurements['cls'] = { value: metric.value, unit: '' }; + _clsEntry = entry ; + }); +} + +/** Starts tracking the Largest Contentful Paint on the current page. */ +function _trackLCP(reportAllChanges) { + (0,_web_vitals_getLCP_js__WEBPACK_IMPORTED_MODULE_6__.onLCP)( + metric => { + const entry = metric.entries.pop(); + if (!entry) { + return; + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding LCP'); + _measurements['lcp'] = { value: metric.value, unit: 'millisecond' }; + _lcpEntry = entry ; + }, + { reportAllChanges }, + ); +} + +/** Starts tracking the First Input Delay on the current page. */ +function _trackFID() { + (0,_web_vitals_getFID_js__WEBPACK_IMPORTED_MODULE_7__.onFID)(metric => { + const entry = metric.entries.pop(); + if (!entry) { + return; + } + + const timeOrigin = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.browserPerformanceTimeOrigin ); + const startTime = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.startTime); + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding FID'); + _measurements['fid'] = { value: metric.value, unit: 'millisecond' }; + _measurements['mark.fid'] = { value: timeOrigin + startTime, unit: 'second' }; + }); +} + +/** Add performance related spans to a transaction */ +function addPerformanceEntries(transaction) { + const performance = getBrowserPerformanceAPI(); + if (!performance || !_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance.getEntries || !_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.browserPerformanceTimeOrigin) { + // Gatekeeper if performance API not available + return; + } + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Tracing] Adding & adjusting spans using Performance API'); + const timeOrigin = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.browserPerformanceTimeOrigin); + + const performanceEntries = performance.getEntries(); + + let responseStartTimestamp; + let requestStartTimestamp; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + performanceEntries.slice(_performanceCursor).forEach((entry) => { + const startTime = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.startTime); + const duration = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.duration); + + if (transaction.op === 'navigation' && timeOrigin + startTime < transaction.startTimestamp) { + return; + } + + switch (entry.entryType) { + case 'navigation': { + _addNavigationSpans(transaction, entry, timeOrigin); + responseStartTimestamp = timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.responseStart); + requestStartTimestamp = timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.requestStart); + break; + } + case 'mark': + case 'paint': + case 'measure': { + _addMeasureSpans(transaction, entry, startTime, duration, timeOrigin); + + // capture web vitals + const firstHidden = (0,_web_vitals_lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_8__.getVisibilityWatcher)(); + // Only report if the page wasn't hidden prior to the web vital. + const shouldRecord = entry.startTime < firstHidden.firstHiddenTime; + + if (entry.name === 'first-paint' && shouldRecord) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding FP'); + _measurements['fp'] = { value: entry.startTime, unit: 'millisecond' }; + } + if (entry.name === 'first-contentful-paint' && shouldRecord) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding FCP'); + _measurements['fcp'] = { value: entry.startTime, unit: 'millisecond' }; + } + break; + } + case 'resource': { + const resourceName = (entry.name ).replace(_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.origin, ''); + _addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin); + break; + } + default: + // Ignore other entry types. + } + }); + + _performanceCursor = Math.max(performanceEntries.length - 1, 0); + + _trackNavigator(transaction); + + // Measurements are only available for pageload transactions + if (transaction.op === 'pageload') { + // Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the + // start of the response in milliseconds + if (typeof responseStartTimestamp === 'number') { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding TTFB'); + _measurements['ttfb'] = { + value: (responseStartTimestamp - transaction.startTimestamp) * 1000, + unit: 'millisecond', + }; + + if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) { + // Capture the time spent making the request and receiving the first byte of the response. + // This is the time between the start of the request and the start of the response in milliseconds. + _measurements['ttfb.requestTime'] = { + value: (responseStartTimestamp - requestStartTimestamp) * 1000, + unit: 'millisecond', + }; + } + } + + ['fcp', 'fp', 'lcp'].forEach(name => { + if (!_measurements[name] || timeOrigin >= transaction.startTimestamp) { + return; + } + // The web vitals, fcp, fp, lcp, and ttfb, all measure relative to timeOrigin. + // Unfortunately, timeOrigin is not captured within the transaction span data, so these web vitals will need + // to be adjusted to be relative to transaction.startTimestamp. + const oldValue = _measurements[name].value; + const measurementTimestamp = timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(oldValue); + + // normalizedValue should be in milliseconds + const normalizedValue = Math.abs((measurementTimestamp - transaction.startTimestamp) * 1000); + const delta = normalizedValue - oldValue; + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log(`[Measurements] Normalized ${name} from ${oldValue} to ${normalizedValue} (${delta})`); + _measurements[name].value = normalizedValue; + }); + + const fidMark = _measurements['mark.fid']; + if (fidMark && _measurements['fid']) { + // create span for FID + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + description: 'first input delay', + endTimestamp: fidMark.value + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(_measurements['fid'].value), + op: 'ui.action', + startTimestamp: fidMark.value, + }); + + // Delete mark.fid as we don't want it to be part of final payload + delete _measurements['mark.fid']; + } + + // If FCP is not recorded we should not record the cls value + // according to the new definition of CLS. + if (!('fcp' in _measurements)) { + delete _measurements.cls; + } + + Object.keys(_measurements).forEach(measurementName => { + transaction.setMeasurement( + measurementName, + _measurements[measurementName].value, + _measurements[measurementName].unit, + ); + }); + + _tagMetricInfo(transaction); + } + + _lcpEntry = undefined; + _clsEntry = undefined; + _measurements = {}; +} + +/** Create measure related spans */ +function _addMeasureSpans( + transaction, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + entry, + startTime, + duration, + timeOrigin, +) { + const measureStartTimestamp = timeOrigin + startTime; + const measureEndTimestamp = measureStartTimestamp + duration; + + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + description: entry.name , + endTimestamp: measureEndTimestamp, + op: entry.entryType , + startTimestamp: measureStartTimestamp, + }); + + return measureStartTimestamp; +} + +/** Instrument navigation entries */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function _addNavigationSpans(transaction, entry, timeOrigin) { + ['unloadEvent', 'redirect', 'domContentLoadedEvent', 'loadEvent', 'connect'].forEach(event => { + _addPerformanceNavigationTiming(transaction, entry, event, timeOrigin); + }); + _addPerformanceNavigationTiming(transaction, entry, 'secureConnection', timeOrigin, 'TLS/SSL', 'connectEnd'); + _addPerformanceNavigationTiming(transaction, entry, 'fetch', timeOrigin, 'cache', 'domainLookupStart'); + _addPerformanceNavigationTiming(transaction, entry, 'domainLookup', timeOrigin, 'DNS'); + _addRequest(transaction, entry, timeOrigin); +} + +/** Create performance navigation related spans */ +function _addPerformanceNavigationTiming( + transaction, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + entry, + event, + timeOrigin, + description, + eventEnd, +) { + const end = eventEnd ? (entry[eventEnd] ) : (entry[`${event}End`] ); + const start = entry[`${event}Start`] ; + if (!start || !end) { + return; + } + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + op: 'browser', + description: (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_10__._nullishCoalesce)(description, () => ( event)), + startTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(start), + endTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(end), + }); +} + +/** Create request and response related spans */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function _addRequest(transaction, entry, timeOrigin) { + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + op: 'browser', + description: 'request', + startTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.requestStart ), + endTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.responseEnd ), + }); + + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + op: 'browser', + description: 'response', + startTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.responseStart ), + endTimestamp: timeOrigin + (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.msToSec)(entry.responseEnd ), + }); +} + +/** Create resource-related spans */ +function _addResourceSpans( + transaction, + entry, + resourceName, + startTime, + duration, + timeOrigin, +) { + // we already instrument based on fetch and xhr, so we don't need to + // duplicate spans here. + if (entry.initiatorType === 'xmlhttprequest' || entry.initiatorType === 'fetch') { + return; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const data = {}; + if ('transferSize' in entry) { + data['Transfer Size'] = entry.transferSize; + } + if ('encodedBodySize' in entry) { + data['Encoded Body Size'] = entry.encodedBodySize; + } + if ('decodedBodySize' in entry) { + data['Decoded Body Size'] = entry.decodedBodySize; + } + + const startTimestamp = timeOrigin + startTime; + const endTimestamp = startTimestamp + duration; + + (0,_utils_js__WEBPACK_IMPORTED_MODULE_9__._startChild)(transaction, { + description: resourceName, + endTimestamp, + op: entry.initiatorType ? `resource.${entry.initiatorType}` : 'resource.other', + startTimestamp, + data, + }); +} + +/** + * Capture the information of the user agent. + */ +function _trackNavigator(transaction) { + const navigator = _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.navigator ; + if (!navigator) { + return; + } + + // track network connectivity + const connection = navigator.connection; + if (connection) { + if (connection.effectiveType) { + transaction.setTag('effectiveConnectionType', connection.effectiveType); + } + + if (connection.type) { + transaction.setTag('connectionType', connection.type); + } + + if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_9__.isMeasurementValue)(connection.rtt)) { + _measurements['connection.rtt'] = { value: connection.rtt, unit: 'millisecond' }; + } + } + + if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_9__.isMeasurementValue)(navigator.deviceMemory)) { + transaction.setTag('deviceMemory', `${navigator.deviceMemory} GB`); + } + + if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_9__.isMeasurementValue)(navigator.hardwareConcurrency)) { + transaction.setTag('hardwareConcurrency', String(navigator.hardwareConcurrency)); + } +} + +/** Add LCP / CLS data to transaction to allow debugging */ +function _tagMetricInfo(transaction) { + if (_lcpEntry) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding LCP Data'); + + // Capture Properties of the LCP element that contributes to the LCP. + + if (_lcpEntry.element) { + transaction.setTag('lcp.element', (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.htmlTreeAsString)(_lcpEntry.element)); + } + + if (_lcpEntry.id) { + transaction.setTag('lcp.id', _lcpEntry.id); + } + + if (_lcpEntry.url) { + // Trim URL to the first 200 characters. + transaction.setTag('lcp.url', _lcpEntry.url.trim().slice(0, 200)); + } + + transaction.setTag('lcp.size', _lcpEntry.size); + } + + // See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift + if (_clsEntry && _clsEntry.sources) { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.logger.log('[Measurements] Adding CLS Data'); + _clsEntry.sources.forEach((source, index) => + transaction.setTag(`cls.source.${index + 1}`, (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_11__.htmlTreeAsString)(source.node)), + ); + } +} + + +//# sourceMappingURL=index.js.map + + +/***/ }), +/* 1716 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "observe": () => (/* binding */ observe) +/* harmony export */ }); +/** + * Takes a performance entry type and a callback function, and creates a + * `PerformanceObserver` instance that will observe the specified entry type + * with buffering enabled and call the callback _for each entry_. + * + * This function also feature-detects entry support and wraps the logic in a + * try/catch to avoid errors in unsupporting browsers. + */ +const observe = ( + type, + callback, + opts, +) => { + try { + if (PerformanceObserver.supportedEntryTypes.includes(type)) { + const po = new PerformanceObserver(list => { + callback(list.getEntries() ); + }); + po.observe( + Object.assign( + { + type, + buffered: true, + }, + opts || {}, + ) , + ); + return po; + } + } catch (e) { + // Do nothing. + } + return; +}; + + +//# sourceMappingURL=observe.js.map + + +/***/ }), +/* 1717 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "onCLS": () => (/* binding */ onCLS) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1722); +/* harmony import */ var _lib_initMetric_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1718); +/* harmony import */ var _lib_observe_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1716); +/* harmony import */ var _lib_onHidden_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1723); + + + + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Calculates the [CLS](https://web.dev/cls/) value for the current page and + * calls the `callback` function once the value is ready to be reported, along + * with all `layout-shift` performance entries that were used in the metric + * value calculation. The reported value is a `double` (corresponding to a + * [layout shift score](https://web.dev/cls/#layout-shift-score)). + * + * If the `reportAllChanges` configuration option is set to `true`, the + * `callback` function will be called as soon as the value is initially + * determined as well as any time the value changes throughout the page + * lifespan. + * + * _**Important:** CLS should be continually monitored for changes throughout + * the entire lifespan of a page—including if the user returns to the page after + * it's been hidden/backgrounded. However, since browsers often [will not fire + * additional callbacks once the user has backgrounded a + * page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden), + * `callback` is always called when the page's visibility state changes to + * hidden. As a result, the `callback` function might be called multiple times + * during the same page load._ + */ +const onCLS = (onReport, opts = {}) => { + const metric = (0,_lib_initMetric_js__WEBPACK_IMPORTED_MODULE_0__.initMetric)('CLS', 0); + let report; + + let sessionValue = 0; + let sessionEntries = []; + + // const handleEntries = (entries: Metric['entries']) => { + const handleEntries = (entries) => { + entries.forEach(entry => { + // Only count layout shifts without recent user input. + if (!entry.hadRecentInput) { + const firstSessionEntry = sessionEntries[0]; + const lastSessionEntry = sessionEntries[sessionEntries.length - 1]; + + // If the entry occurred less than 1 second after the previous entry and + // less than 5 seconds after the first entry in the session, include the + // entry in the current session. Otherwise, start a new session. + if ( + sessionValue && + sessionEntries.length !== 0 && + entry.startTime - lastSessionEntry.startTime < 1000 && + entry.startTime - firstSessionEntry.startTime < 5000 + ) { + sessionValue += entry.value; + sessionEntries.push(entry); + } else { + sessionValue = entry.value; + sessionEntries = [entry]; + } + + // If the current session value is larger than the current CLS value, + // update CLS and the entries contributing to it. + if (sessionValue > metric.value) { + metric.value = sessionValue; + metric.entries = sessionEntries; + if (report) { + report(); + } + } + } + }); + }; + + const po = (0,_lib_observe_js__WEBPACK_IMPORTED_MODULE_1__.observe)('layout-shift', handleEntries); + if (po) { + report = (0,_lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_2__.bindReporter)(onReport, metric, opts.reportAllChanges); + + (0,_lib_onHidden_js__WEBPACK_IMPORTED_MODULE_3__.onHidden)(() => { + handleEntries(po.takeRecords() ); + report(true); + }); + } +}; + + +//# sourceMappingURL=getCLS.js.map + + +/***/ }), +/* 1718 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "initMetric": () => (/* binding */ initMetric) +/* harmony export */ }); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1713); +/* harmony import */ var _generateUniqueID_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1721); +/* harmony import */ var _getActivationStart_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1720); +/* harmony import */ var _getNavigationEntry_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1719); + + + + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const initMetric = (name, value) => { + const navEntry = (0,_getNavigationEntry_js__WEBPACK_IMPORTED_MODULE_0__.getNavigationEntry)(); + let navigationType = 'navigate'; + + if (navEntry) { + if (_types_js__WEBPACK_IMPORTED_MODULE_1__.WINDOW.document.prerendering || (0,_getActivationStart_js__WEBPACK_IMPORTED_MODULE_2__.getActivationStart)() > 0) { + navigationType = 'prerender'; + } else { + navigationType = navEntry.type.replace(/_/g, '-') ; + } + } + + return { + name, + value: typeof value === 'undefined' ? -1 : value, + rating: 'good', // Will be updated if the value changes. + delta: 0, + entries: [], + id: (0,_generateUniqueID_js__WEBPACK_IMPORTED_MODULE_3__.generateUniqueID)(), + navigationType, + }; +}; + + +//# sourceMappingURL=initMetric.js.map + + +/***/ }), +/* 1719 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getNavigationEntry": () => (/* binding */ getNavigationEntry) +/* harmony export */ }); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); + + +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const getNavigationEntryFromPerformanceTiming = () => { + // eslint-disable-next-line deprecation/deprecation + const timing = _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance.timing; + // eslint-disable-next-line deprecation/deprecation + const type = _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance.navigation.type; + + const navigationEntry = { + entryType: 'navigation', + startTime: 0, + type: type == 2 ? 'back_forward' : type === 1 ? 'reload' : 'navigate', + }; + + for (const key in timing) { + if (key !== 'navigationStart' && key !== 'toJSON') { + navigationEntry[key] = Math.max((timing[key ] ) - timing.navigationStart, 0); + } + } + return navigationEntry ; +}; + +const getNavigationEntry = () => { + if (_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.__WEB_VITALS_POLYFILL__) { + return ( + _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance && + ((performance.getEntriesByType && performance.getEntriesByType('navigation')[0]) || + getNavigationEntryFromPerformanceTiming()) + ); + } else { + return _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0]; + } +}; + + +//# sourceMappingURL=getNavigationEntry.js.map + + +/***/ }), +/* 1720 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getActivationStart": () => (/* binding */ getActivationStart) +/* harmony export */ }); +/* harmony import */ var _getNavigationEntry_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1719); + + +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const getActivationStart = () => { + const navEntry = (0,_getNavigationEntry_js__WEBPACK_IMPORTED_MODULE_0__.getNavigationEntry)(); + return (navEntry && navEntry.activationStart) || 0; +}; + + +//# sourceMappingURL=getActivationStart.js.map + + +/***/ }), +/* 1721 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "generateUniqueID": () => (/* binding */ generateUniqueID) +/* harmony export */ }); +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Performantly generate a unique, 30-char string by combining a version + * number, the current timestamp with a 13-digit number integer. + * @return {string} + */ +const generateUniqueID = () => { + return `v3-${Date.now()}-${Math.floor(Math.random() * (9e12 - 1)) + 1e12}`; +}; + + +//# sourceMappingURL=generateUniqueID.js.map + + +/***/ }), +/* 1722 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "bindReporter": () => (/* binding */ bindReporter) +/* harmony export */ }); +const bindReporter = ( + callback, + metric, + reportAllChanges, +) => { + let prevValue; + let delta; + return (forceReport) => { + if (metric.value >= 0) { + if (forceReport || reportAllChanges) { + delta = metric.value - (prevValue || 0); + + // Report the metric if there's a non-zero delta or if no previous + // value exists (which can happen in the case of the document becoming + // hidden when the metric value is 0). + // See: https://github.com/GoogleChrome/web-vitals/issues/14 + if (delta || prevValue === undefined) { + prevValue = metric.value; + metric.delta = delta; + callback(metric); + } + } + } + }; +}; + + +//# sourceMappingURL=bindReporter.js.map + + +/***/ }), +/* 1723 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "onHidden": () => (/* binding */ onHidden) +/* harmony export */ }); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const onHidden = (cb, once) => { + const onHiddenOrPageHide = (event) => { + if (event.type === 'pagehide' || _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document.visibilityState === 'hidden') { + cb(event); + if (once) { + removeEventListener('visibilitychange', onHiddenOrPageHide, true); + removeEventListener('pagehide', onHiddenOrPageHide, true); + } + } + }; + addEventListener('visibilitychange', onHiddenOrPageHide, true); + // Some browsers have buggy implementations of visibilitychange, + // so we use pagehide in addition, just to be safe. + addEventListener('pagehide', onHiddenOrPageHide, true); +}; + + +//# sourceMappingURL=onHidden.js.map + + +/***/ }), +/* 1724 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "onLCP": () => (/* binding */ onLCP) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1722); +/* harmony import */ var _lib_getActivationStart_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1720); +/* harmony import */ var _lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1725); +/* harmony import */ var _lib_initMetric_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1718); +/* harmony import */ var _lib_observe_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1716); +/* harmony import */ var _lib_onHidden_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1723); + + + + + + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const reportedMetricIDs = {}; + +/** + * Calculates the [LCP](https://web.dev/lcp/) value for the current page and + * calls the `callback` function once the value is ready (along with the + * relevant `largest-contentful-paint` performance entry used to determine the + * value). The reported value is a `DOMHighResTimeStamp`. + * + * If the `reportAllChanges` configuration option is set to `true`, the + * `callback` function will be called any time a new `largest-contentful-paint` + * performance entry is dispatched, or once the final value of the metric has + * been determined. + */ +const onLCP = (onReport, opts = {}) => { + const visibilityWatcher = (0,_lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_0__.getVisibilityWatcher)(); + const metric = (0,_lib_initMetric_js__WEBPACK_IMPORTED_MODULE_1__.initMetric)('LCP'); + let report; + + const handleEntries = (entries) => { + const lastEntry = entries[entries.length - 1] ; + if (lastEntry) { + // The startTime attribute returns the value of the renderTime if it is + // not 0, and the value of the loadTime otherwise. The activationStart + // reference is used because LCP should be relative to page activation + // rather than navigation start if the page was prerendered. + const value = Math.max(lastEntry.startTime - (0,_lib_getActivationStart_js__WEBPACK_IMPORTED_MODULE_2__.getActivationStart)(), 0); + + // Only report if the page wasn't hidden prior to LCP. + if (value < visibilityWatcher.firstHiddenTime) { + metric.value = value; + metric.entries = [lastEntry]; + report(); + } + } + }; + + const po = (0,_lib_observe_js__WEBPACK_IMPORTED_MODULE_3__.observe)('largest-contentful-paint', handleEntries); + + if (po) { + report = (0,_lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_4__.bindReporter)(onReport, metric, opts.reportAllChanges); + + const stopListening = () => { + if (!reportedMetricIDs[metric.id]) { + handleEntries(po.takeRecords() ); + po.disconnect(); + reportedMetricIDs[metric.id] = true; + report(true); + } + }; + + // Stop listening after input. Note: while scrolling is an input that + // stop LCP observation, it's unreliable since it can be programmatically + // generated. See: https://github.com/GoogleChrome/web-vitals/issues/75 + ['keydown', 'click'].forEach(type => { + addEventListener(type, stopListening, { once: true, capture: true }); + }); + + (0,_lib_onHidden_js__WEBPACK_IMPORTED_MODULE_5__.onHidden)(stopListening, true); + } +}; + + +//# sourceMappingURL=getLCP.js.map + + +/***/ }), +/* 1725 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getVisibilityWatcher": () => (/* binding */ getVisibilityWatcher) +/* harmony export */ }); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); +/* harmony import */ var _onHidden_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1723); + + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let firstHiddenTime = -1; + +const initHiddenTime = () => { + // If the document is hidden and not prerendering, assume it was always + // hidden and the page was loaded in the background. + return _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document.visibilityState === 'hidden' && !_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document.prerendering ? 0 : Infinity; +}; + +const trackChanges = () => { + // Update the time if/when the document becomes hidden. + (0,_onHidden_js__WEBPACK_IMPORTED_MODULE_1__.onHidden)(({ timeStamp }) => { + firstHiddenTime = timeStamp; + }, true); +}; + +const getVisibilityWatcher = ( + +) => { + if (firstHiddenTime < 0) { + // If the document is hidden when this code runs, assume it was hidden + // since navigation start. This isn't a perfect heuristic, but it's the + // best we can do until an API is available to support querying past + // visibilityState. + firstHiddenTime = initHiddenTime(); + trackChanges(); + } + return { + get firstHiddenTime() { + return firstHiddenTime; + }, + }; +}; + + +//# sourceMappingURL=getVisibilityWatcher.js.map + + +/***/ }), +/* 1726 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "onFID": () => (/* binding */ onFID) +/* harmony export */ }); +/* harmony import */ var _lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1722); +/* harmony import */ var _lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1725); +/* harmony import */ var _lib_initMetric_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1718); +/* harmony import */ var _lib_observe_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1716); +/* harmony import */ var _lib_onHidden_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1723); + + + + + + +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Calculates the [FID](https://web.dev/fid/) value for the current page and + * calls the `callback` function once the value is ready, along with the + * relevant `first-input` performance entry used to determine the value. The + * reported value is a `DOMHighResTimeStamp`. + * + * _**Important:** since FID is only reported after the user interacts with the + * page, it's possible that it will not be reported for some page loads._ + */ +const onFID = (onReport, opts = {}) => { + const visibilityWatcher = (0,_lib_getVisibilityWatcher_js__WEBPACK_IMPORTED_MODULE_0__.getVisibilityWatcher)(); + const metric = (0,_lib_initMetric_js__WEBPACK_IMPORTED_MODULE_1__.initMetric)('FID'); + // eslint-disable-next-line prefer-const + let report; + + const handleEntry = (entry) => { + // Only report if the page wasn't hidden prior to the first input. + if (entry.startTime < visibilityWatcher.firstHiddenTime) { + metric.value = entry.processingStart - entry.startTime; + metric.entries.push(entry); + report(true); + } + }; + + const handleEntries = (entries) => { + (entries ).forEach(handleEntry); + }; + + const po = (0,_lib_observe_js__WEBPACK_IMPORTED_MODULE_2__.observe)('first-input', handleEntries); + report = (0,_lib_bindReporter_js__WEBPACK_IMPORTED_MODULE_3__.bindReporter)(onReport, metric, opts.reportAllChanges); + + if (po) { + (0,_lib_onHidden_js__WEBPACK_IMPORTED_MODULE_4__.onHidden)(() => { + handleEntries(po.takeRecords() ); + po.disconnect(); + }, true); + } +}; + + +//# sourceMappingURL=getFID.js.map + + +/***/ }), +/* 1727 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_startChild": () => (/* binding */ _startChild), +/* harmony export */ "isMeasurementValue": () => (/* binding */ isMeasurementValue) +/* harmony export */ }); +/** + * Checks if a given value is a valid measurement value. + */ +function isMeasurementValue(value) { + return typeof value === 'number' && isFinite(value); +} + +/** + * Helper function to start child on transactions. This function will make sure that the transaction will + * use the start timestamp of the created child span if it is earlier than the transactions actual + * start timestamp. + */ +function _startChild(transaction, { startTimestamp, ...ctx }) { + if (startTimestamp && transaction.startTimestamp > startTimestamp) { + transaction.startTimestamp = startTimestamp; + } + + return transaction.startChild({ + startTimestamp, + ...ctx, + }); +} + + +//# sourceMappingURL=utils.js.map + + +/***/ }), +/* 1728 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "registerBackgroundTabDetection": () => (/* binding */ registerBackgroundTabDetection) +/* harmony export */ }); +/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1615); +/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1695); +/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1713); + + + + +/** + * Add a listener that cancels and finishes a transaction when the global + * document is hidden. + */ +function registerBackgroundTabDetection() { + if (_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW && _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document) { + _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document.addEventListener('visibilitychange', () => { + const activeTransaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.getActiveTransaction)() ; + if (_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.document.hidden && activeTransaction) { + const statusType = 'cancelled'; + + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.log( + `[Tracing] Transaction: ${statusType} -> since tab moved to the background, op: ${activeTransaction.op}`, + ); + // We should not set status if it is already set, this prevent important statuses like + // error or data loss from being overwritten on transaction. + if (!activeTransaction.status) { + activeTransaction.setStatus(statusType); + } + activeTransaction.setTag('visibilitychange', 'document.hidden'); + activeTransaction.finish(); + } + }); + } else { + (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && + _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn('[Tracing] Could not set up background tab detection due to lack of global document'); + } +} + + +//# sourceMappingURL=backgroundtab.js.map + + +/***/ }), +/* 1729 */ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SpanStatus": () => (/* binding */ SpanStatus) +/* harmony export */ }); +/** The status of an Span. + * + * @deprecated Use string literals - if you require type casting, cast to SpanStatusType type + */ +// eslint-disable-next-line import/export +var SpanStatus; (function (SpanStatus) { + /** The operation completed successfully. */ + const Ok = 'ok'; SpanStatus["Ok"] = Ok; + /** Deadline expired before operation could complete. */ + const DeadlineExceeded = 'deadline_exceeded'; SpanStatus["DeadlineExceeded"] = DeadlineExceeded; + /** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */ + const Unauthenticated = 'unauthenticated'; SpanStatus["Unauthenticated"] = Unauthenticated; + /** 403 Forbidden */ + const PermissionDenied = 'permission_denied'; SpanStatus["PermissionDenied"] = PermissionDenied; + /** 404 Not Found. Some requested entity (file or directory) was not found. */ + const NotFound = 'not_found'; SpanStatus["NotFound"] = NotFound; + /** 429 Too Many Requests */ + const ResourceExhausted = 'resource_exhausted'; SpanStatus["ResourceExhausted"] = ResourceExhausted; + /** Client specified an invalid argument. 4xx. */ + const InvalidArgument = 'invalid_argument'; SpanStatus["InvalidArgument"] = InvalidArgument; + /** 501 Not Implemented */ + const Unimplemented = 'unimplemented'; SpanStatus["Unimplemented"] = Unimplemented; + /** 503 Service Unavailable */ + const Unavailable = 'unavailable'; SpanStatus["Unavailable"] = Unavailable; + /** Other/generic 5xx. */ + const InternalError = 'internal_error'; SpanStatus["InternalError"] = InternalError; + /** Unknown. Any non-standard HTTP status code. */ + const UnknownError = 'unknown_error'; SpanStatus["UnknownError"] = UnknownError; + /** The operation was cancelled (typically by the user). */ + const Cancelled = 'cancelled'; SpanStatus["Cancelled"] = Cancelled; + /** Already exists (409) */ + const AlreadyExists = 'already_exists'; SpanStatus["AlreadyExists"] = AlreadyExists; + /** Operation was rejected because the system is not in a state required for the operation's */ + const FailedPrecondition = 'failed_precondition'; SpanStatus["FailedPrecondition"] = FailedPrecondition; + /** The operation was aborted, typically due to a concurrency issue. */ + const Aborted = 'aborted'; SpanStatus["Aborted"] = Aborted; + /** Operation was attempted past the valid range. */ + const OutOfRange = 'out_of_range'; SpanStatus["OutOfRange"] = OutOfRange; + /** Unrecoverable data loss or corruption */ + const DataLoss = 'data_loss'; SpanStatus["DataLoss"] = DataLoss; +})(SpanStatus || (SpanStatus = {})); + + +//# sourceMappingURL=spanstatus.js.map + + +/***/ }), +/* 1730 */ /***/ ((module) => { "use strict"; diff --git a/onDeleteAccount.js b/onDeleteAccount.js index db1538b04842567959e32534986c81e336ef331e..dc01f8e966cbec9cea31058f16f69d3c76a84e82 100644 --- a/onDeleteAccount.js +++ b/onDeleteAccount.js @@ -240960,7 +240960,44 @@ module.exports = { isLocal, isDev } /***/ }), /* 1693 */, -/* 1694 */ +/* 1694 */, +/* 1695 */, +/* 1696 */, +/* 1697 */, +/* 1698 */, +/* 1699 */, +/* 1700 */, +/* 1701 */, +/* 1702 */, +/* 1703 */, +/* 1704 */, +/* 1705 */, +/* 1706 */, +/* 1707 */, +/* 1708 */, +/* 1709 */, +/* 1710 */, +/* 1711 */, +/* 1712 */, +/* 1713 */, +/* 1714 */, +/* 1715 */, +/* 1716 */, +/* 1717 */, +/* 1718 */, +/* 1719 */, +/* 1720 */, +/* 1721 */, +/* 1722 */, +/* 1723 */, +/* 1724 */, +/* 1725 */, +/* 1726 */, +/* 1727 */, +/* 1728 */, +/* 1729 */, +/* 1730 */, +/* 1731 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { // @ts-check @@ -240969,7 +241006,7 @@ const { getAccountRev, getAccountSecret, getAccountId, -} = __webpack_require__(1695) +} = __webpack_require__(1732) const { getBoConsent, deleteBoConsent } = __webpack_require__(1563) const { terminateContract } = __webpack_require__(1684) const { getAccountForDelete } = __webpack_require__(1691) @@ -241064,7 +241101,7 @@ module.exports = { onDeleteAccount } /***/ }), -/* 1695 */ +/* 1732 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { log } = __webpack_require__(1) @@ -241219,7 +241256,7 @@ module.exports = { getAccountId, getAccountRev, getAccountSecret } /******/ // module cache are used so entry inlining is disabled /******/ // startup /******/ // Load entry module and return exports -/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 1694); +/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 1731); /******/ /******/ })() ; \ No newline at end of file