Skip to content
Snippets Groups Projects
onDeleteAccount.js 8.09 MiB
Newer Older
  • Learn to ignore specific revisions
  •       const httpsModule = __webpack_require__(81);
          (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.fill)(httpsModule, 'get', wrappedHandlerMaker);
          (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.fill)(httpsModule, 'request', wrappedHandlerMaker);
        }
      }
    }Http.__initStatic();
    
    // for ease of reading below
    
    /**
     * Function which creates a function which creates wrapped versions of internal `request` and `get` calls within `http`
     * and `https` modules. (NB: Not a typo - this is a creator^2!)
     *
     * @param breadcrumbsEnabled Whether or not to record outgoing requests as breadcrumbs
     * @param tracingEnabled Whether or not to record outgoing requests as tracing spans
     *
     * @returns A function which accepts the exiting handler and returns a wrapped handler
     */
    function _createWrappedRequestMethodFactory(
      breadcrumbsEnabled,
      tracingOptions,
    ) {
      // We're caching results so we don't have to recompute regexp every time we create a request.
      const createSpanUrlMap = {};
      const headersUrlMap = {};
    
      const shouldCreateSpan = (url) => {
        if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([tracingOptions, 'optionalAccess', _6 => _6.shouldCreateSpanForRequest]) === undefined) {
          return true;
        }
    
        if (createSpanUrlMap[url]) {
          return createSpanUrlMap[url];
        }
    
        createSpanUrlMap[url] = tracingOptions.shouldCreateSpanForRequest(url);
    
        return createSpanUrlMap[url];
      };
    
      const shouldAttachTraceData = (url) => {
        if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([tracingOptions, 'optionalAccess', _7 => _7.tracePropagationTargets]) === undefined) {
          return true;
        }
    
        if (headersUrlMap[url]) {
          return headersUrlMap[url];
        }
    
        headersUrlMap[url] = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.stringMatchesSomePattern)(url, tracingOptions.tracePropagationTargets);
    
        return headersUrlMap[url];
      };
    
      return function wrappedRequestMethodFactory(originalRequestMethod) {
        return function wrappedMethod( ...args) {
          // eslint-disable-next-line @typescript-eslint/no-this-alias
          const httpModule = this;
    
          const requestArgs = (0,_utils_http_js__WEBPACK_IMPORTED_MODULE_0__.normalizeRequestArgs)(this, args);
          const requestOptions = requestArgs[0];
          const requestUrl = (0,_utils_http_js__WEBPACK_IMPORTED_MODULE_0__.extractUrl)(requestOptions);
    
          // we don't want to record requests to Sentry as either breadcrumbs or spans, so just use the original method
          if ((0,_utils_http_js__WEBPACK_IMPORTED_MODULE_0__.isSentryRequest)(requestUrl)) {
            return originalRequestMethod.apply(httpModule, requestArgs);
          }
    
          let requestSpan;
          let parentSpan;
    
          const scope = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_6__.getCurrentHub)().getScope();
    
          if (scope && tracingOptions && shouldCreateSpan(requestUrl)) {
            parentSpan = scope.getSpan();
    
            if (parentSpan) {
              requestSpan = parentSpan.startChild({
                description: `${requestOptions.method || 'GET'} ${requestUrl}`,
                op: 'http.client',
              });
    
              if (shouldAttachTraceData(requestUrl)) {
                const sentryTraceHeader = requestSpan.toTraceparent();
                (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
                  _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(
                    `[Tracing] Adding sentry-trace header ${sentryTraceHeader} to outgoing request to "${requestUrl}": `,
                  );
    
                requestOptions.headers = {
                  ...requestOptions.headers,
                  'sentry-trace': sentryTraceHeader,
                };
    
                if (parentSpan.transaction) {
                  const dynamicSamplingContext = parentSpan.transaction.getDynamicSamplingContext();
                  const sentryBaggageHeader = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.dynamicSamplingContextToSentryBaggageHeader)(dynamicSamplingContext);
    
                  let newBaggageHeaderField;
                  if (!requestOptions.headers || !requestOptions.headers.baggage) {
                    newBaggageHeaderField = sentryBaggageHeader;
                  } else if (!sentryBaggageHeader) {
                    newBaggageHeaderField = requestOptions.headers.baggage;
                  } else if (Array.isArray(requestOptions.headers.baggage)) {
                    newBaggageHeaderField = [...requestOptions.headers.baggage, sentryBaggageHeader];
                  } else {
                    // Type-cast explanation:
                    // Technically this the following could be of type `(number | string)[]` but for the sake of simplicity
                    // we say this is undefined behaviour, since it would not be baggage spec conform if the user did this.
                    newBaggageHeaderField = [requestOptions.headers.baggage, sentryBaggageHeader] ;
                  }
    
                  requestOptions.headers = {
                    ...requestOptions.headers,
                    // Setting a hader to `undefined` will crash in node so we only set the baggage header when it's defined
                    ...(newBaggageHeaderField && { baggage: newBaggageHeaderField }),
                  };
                }
              } else {
                (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
                  _sentry_utils__WEBPACK_IMPORTED_MODULE_3__.logger.log(
                    `[Tracing] Not adding sentry-trace header to outgoing request (${requestUrl}) due to mismatching tracePropagationTargets option.`,
                  );
              }
    
              const transaction = parentSpan.transaction;
              if (transaction) {
                transaction.metadata.propagations++;
              }
            }
          }
    
          // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
          return originalRequestMethod
            .apply(httpModule, requestArgs)
            .once('response', function ( res) {
              // eslint-disable-next-line @typescript-eslint/no-this-alias
              const req = this;
              if (breadcrumbsEnabled) {
                addRequestBreadcrumb('response', requestUrl, req, res);
              }
              if (requestSpan) {
                if (res.statusCode) {
                  requestSpan.setHttpStatus(res.statusCode);
                }
                requestSpan.description = (0,_utils_http_js__WEBPACK_IMPORTED_MODULE_0__.cleanSpanDescription)(requestSpan.description, requestOptions, req);
                requestSpan.finish();
              }
            })
            .once('error', function () {
              // eslint-disable-next-line @typescript-eslint/no-this-alias
              const req = this;
    
              if (breadcrumbsEnabled) {
                addRequestBreadcrumb('error', requestUrl, req);
              }
              if (requestSpan) {
                requestSpan.setHttpStatus(500);
                requestSpan.description = (0,_utils_http_js__WEBPACK_IMPORTED_MODULE_0__.cleanSpanDescription)(requestSpan.description, requestOptions, req);
                requestSpan.finish();
              }
            });
        };
      };
    }
    
    /**
     * Captures Breadcrumb based on provided request/response pair
     */
    function addRequestBreadcrumb(event, url, req, res) {
      if (!(0,_sentry_core__WEBPACK_IMPORTED_MODULE_6__.getCurrentHub)().getIntegration(Http)) {
        return;
      }
    
      (0,_sentry_core__WEBPACK_IMPORTED_MODULE_6__.getCurrentHub)().addBreadcrumb(
        {
          category: 'http',
          data: {
            method: req.method,
            status_code: res && res.statusCode,
            url,
          },
          type: 'http',
        },
        {
          event,
          request: req,
          response: res,
        },
      );
    }
    
    
    //# sourceMappingURL=http.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "cleanSpanDescription": () => (/* binding */ cleanSpanDescription),
    /* harmony export */   "extractUrl": () => (/* binding */ extractUrl),
    /* harmony export */   "isSentryRequest": () => (/* binding */ isSentryRequest),
    /* harmony export */   "normalizeRequestArgs": () => (/* binding */ normalizeRequestArgs),
    /* harmony export */   "urlToOptions": () => (/* binding */ urlToOptions)
    /* harmony export */ });
    
    /* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1663);
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1640);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1647);
    
    /* harmony import */ var url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(63);
    /* harmony import */ var url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(url__WEBPACK_IMPORTED_MODULE_0__);
    
    
    
    
    
    const NODE_VERSION = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.parseSemver)(process.versions.node);
    
    /**
     * Checks whether given url points to Sentry server
     * @param url url to verify
     */
    function isSentryRequest(url) {
      const dsn = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([_sentry_core__WEBPACK_IMPORTED_MODULE_3__.getCurrentHub, 'call', _ => _(), 'access', _2 => _2.getClient, 'call', _3 => _3(), 'optionalAccess', _4 => _4.getDsn, 'call', _5 => _5()]);
      return dsn ? url.includes(dsn.host) : false;
    }
    
    /**
     * Assemble a URL to be used for breadcrumbs and spans.
     *
     * @param requestOptions RequestOptions object containing the component parts for a URL
     * @returns Fully-formed URL
     */
    function extractUrl(requestOptions) {
      const protocol = requestOptions.protocol || '';
      const hostname = requestOptions.hostname || requestOptions.host || '';
      // Don't log standard :80 (http) and :443 (https) ports to reduce the noise
      const port =
        !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 ? '' : `:${requestOptions.port}`;
      const path = requestOptions.path ? requestOptions.path : '/';
    
      return `${protocol}//${hostname}${port}${path}`;
    }
    
    /**
     * Handle various edge cases in the span description (for spans representing http(s) requests).
     *
     * @param description current `description` property of the span representing the request
     * @param requestOptions Configuration data for the request
     * @param Request Request object
     *
     * @returns The cleaned description
     */
    function cleanSpanDescription(
      description,
      requestOptions,
      request,
    ) {
      // nothing to clean
      if (!description) {
        return description;
      }
    
      // eslint-disable-next-line prefer-const
      let [method, requestUrl] = description.split(' ');
    
      // superagent sticks the protocol in a weird place (we check for host because if both host *and* protocol are missing,
      // we're likely dealing with an internal route and this doesn't apply)
      if (requestOptions.host && !requestOptions.protocol) {
        // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
        requestOptions.protocol = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([(request ), 'optionalAccess', _6 => _6.agent, 'optionalAccess', _7 => _7.protocol]); // worst comes to worst, this is undefined and nothing changes
        requestUrl = extractUrl(requestOptions);
      }
    
      // internal routes can end up starting with a triple slash rather than a single one
      if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([requestUrl, 'optionalAccess', _8 => _8.startsWith, 'call', _9 => _9('///')])) {
        requestUrl = requestUrl.slice(2);
      }
    
      return `${method} ${requestUrl}`;
    }
    
    // the node types are missing a few properties which node's `urlToOptions` function spits out
    
    /**
     * Convert a URL object into a RequestOptions object.
     *
     * Copied from Node's internals (where it's used in http(s).request() and http(s).get()), modified only to use the
     * RequestOptions type above.
     *
     * See https://github.com/nodejs/node/blob/master/lib/internal/url.js.
     */
    function urlToOptions(url) {
      const options = {
        protocol: url.protocol,
        hostname:
          typeof url.hostname === 'string' && url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname,
        hash: url.hash,
        search: url.search,
        pathname: url.pathname,
        path: `${url.pathname || ''}${url.search || ''}`,
        href: url.href,
      };
      if (url.port !== '') {
        options.port = Number(url.port);
      }
      if (url.username || url.password) {
        options.auth = `${url.username}:${url.password}`;
      }
      return options;
    }
    
    /**
     * Normalize inputs to `http(s).request()` and `http(s).get()`.
     *
     * Legal inputs to `http(s).request()` and `http(s).get()` can take one of ten forms:
     *     [ RequestOptions | string | URL ],
     *     [ RequestOptions | string | URL, RequestCallback ],
     *     [ string | URL, RequestOptions ], and
     *     [ string | URL, RequestOptions, RequestCallback ].
     *
     * This standardizes to one of two forms: [ RequestOptions ] and [ RequestOptions, RequestCallback ]. A similar thing is
     * done as the first step of `http(s).request()` and `http(s).get()`; this just does it early so that we can interact
     * with the args in a standard way.
     *
     * @param requestArgs The inputs to `http(s).request()` or `http(s).get()`, as an array.
     *
     * @returns Equivalent args of the form [ RequestOptions ] or [ RequestOptions, RequestCallback ].
     */
    function normalizeRequestArgs(
      httpModule,
      requestArgs,
    ) {
      let callback, requestOptions;
    
      // pop off the callback, if there is one
      if (typeof requestArgs[requestArgs.length - 1] === 'function') {
        callback = requestArgs.pop() ;
      }
    
      // create a RequestOptions object of whatever's at index 0
      if (typeof requestArgs[0] === 'string') {
        requestOptions = urlToOptions(new url__WEBPACK_IMPORTED_MODULE_0__.URL(requestArgs[0]));
      } else if (requestArgs[0] instanceof url__WEBPACK_IMPORTED_MODULE_0__.URL) {
        requestOptions = urlToOptions(requestArgs[0]);
      } else {
        requestOptions = requestArgs[0];
      }
    
      // if the options were given separately from the URL, fold them in
      if (requestArgs.length === 2) {
        requestOptions = { ...requestOptions, ...requestArgs[1] };
      }
    
      // Figure out the protocol if it's currently missing
      if (requestOptions.protocol === undefined) {
        // Worst case we end up populating protocol with undefined, which it already is
        /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
    
        // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
        // Because of that, we cannot rely on `httpModule` to provide us with valid protocol,
        // as it will always return `http`, even when using `https` module.
        //
        // See test/integrations/http.test.ts for more details on Node <=v8 protocol issue.
        if (NODE_VERSION.major && NODE_VERSION.major > 8) {
          requestOptions.protocol =
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([httpModule, 'optionalAccess', _10 => _10.globalAgent]) ), 'optionalAccess', _11 => _11.protocol]) ||
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([(requestOptions.agent ), 'optionalAccess', _12 => _12.protocol]) ||
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([(requestOptions._defaultAgent ), 'optionalAccess', _13 => _13.protocol]);
        } else {
          requestOptions.protocol =
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([(requestOptions.agent ), 'optionalAccess', _14 => _14.protocol]) ||
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([(requestOptions._defaultAgent ), 'optionalAccess', _15 => _15.protocol]) ||
            (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([httpModule, 'optionalAccess', _16 => _16.globalAgent]) ), 'optionalAccess', _17 => _17.protocol]);
        }
        /* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
      }
    
      // return args in standardized form
      if (callback) {
        return [requestOptions, callback];
      } else {
        return [requestOptions];
      }
    }
    
    
    //# sourceMappingURL=http.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "BAGGAGE_HEADER_NAME": () => (/* binding */ BAGGAGE_HEADER_NAME),
    /* harmony export */   "MAX_BAGGAGE_STRING_LENGTH": () => (/* binding */ MAX_BAGGAGE_STRING_LENGTH),
    /* harmony export */   "SENTRY_BAGGAGE_KEY_PREFIX": () => (/* binding */ SENTRY_BAGGAGE_KEY_PREFIX),
    /* harmony export */   "SENTRY_BAGGAGE_KEY_PREFIX_REGEX": () => (/* binding */ SENTRY_BAGGAGE_KEY_PREFIX_REGEX),
    /* harmony export */   "baggageHeaderToDynamicSamplingContext": () => (/* binding */ baggageHeaderToDynamicSamplingContext),
    /* harmony export */   "dynamicSamplingContextToSentryBaggageHeader": () => (/* binding */ dynamicSamplingContextToSentryBaggageHeader)
    /* harmony export */ });
    
    /* harmony import */ var _is_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1649);
    /* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1653);
    
    
    
    
    const BAGGAGE_HEADER_NAME = 'baggage';
    
    const SENTRY_BAGGAGE_KEY_PREFIX = 'sentry-';
    
    const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;
    
    /**
     * Max length of a serialized baggage string
     *
     * https://www.w3.org/TR/baggage/#limits
     */
    const MAX_BAGGAGE_STRING_LENGTH = 8192;
    
    /**
     * Takes a baggage header and turns it into Dynamic Sampling Context, by extracting all the "sentry-" prefixed values
     * from it.
     *
     * @param baggageHeader A very bread definition of a baggage header as it might appear in various frameworks.
     * @returns The Dynamic Sampling Context that was found on `baggageHeader`, if there was any, `undefined` otherwise.
     */
    function baggageHeaderToDynamicSamplingContext(
      // Very liberal definition of what any incoming header might look like
      baggageHeader,
    ) {
      if (!(0,_is_js__WEBPACK_IMPORTED_MODULE_0__.isString)(baggageHeader) && !Array.isArray(baggageHeader)) {
        return undefined;
      }
    
      // Intermediary object to store baggage key value pairs of incoming baggage headers on.
      // It is later used to read Sentry-DSC-values from.
      let baggageObject = {};
    
      if (Array.isArray(baggageHeader)) {
        // Combine all baggage headers into one object containing the baggage values so we can later read the Sentry-DSC-values from it
        baggageObject = baggageHeader.reduce((acc, curr) => {
          const currBaggageObject = baggageHeaderToObject(curr);
          return {
            ...acc,
            ...currBaggageObject,
          };
        }, {});
      } else {
        // Return undefined if baggage header is an empty string (technically an empty baggage header is not spec conform but
        // this is how we choose to handle it)
        if (!baggageHeader) {
          return undefined;
        }
    
        baggageObject = baggageHeaderToObject(baggageHeader);
      }
    
      // Read all "sentry-" prefixed values out of the baggage object and put it onto a dynamic sampling context object.
      const dynamicSamplingContext = Object.entries(baggageObject).reduce((acc, [key, value]) => {
        if (key.match(SENTRY_BAGGAGE_KEY_PREFIX_REGEX)) {
          const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);
          acc[nonPrefixedKey] = value;
        }
        return acc;
      }, {});
    
      // Only return a dynamic sampling context object if there are keys in it.
      // A keyless object means there were no sentry values on the header, which means that there is no DSC.
      if (Object.keys(dynamicSamplingContext).length > 0) {
        return dynamicSamplingContext ;
      } else {
        return undefined;
      }
    }
    
    /**
     * Turns a Dynamic Sampling Object into a baggage header by prefixing all the keys on the object with "sentry-".
     *
     * @param dynamicSamplingContext The Dynamic Sampling Context to turn into a header. For convenience and compatibility
     * with the `getDynamicSamplingContext` method on the Transaction class ,this argument can also be `undefined`. If it is
     * `undefined` the function will return `undefined`.
     * @returns a baggage header, created from `dynamicSamplingContext`, or `undefined` either if `dynamicSamplingContext`
     * was `undefined`, or if `dynamicSamplingContext` didn't contain any values.
     */
    function dynamicSamplingContextToSentryBaggageHeader(
      // this also takes undefined for convenience and bundle size in other places
      dynamicSamplingContext,
    ) {
      // Prefix all DSC keys with "sentry-" and put them into a new object
      const sentryPrefixedDSC = Object.entries(dynamicSamplingContext).reduce(
        (acc, [dscKey, dscValue]) => {
          if (dscValue) {
            acc[`${SENTRY_BAGGAGE_KEY_PREFIX}${dscKey}`] = dscValue;
          }
          return acc;
        },
        {},
      );
    
      return objectToBaggageHeader(sentryPrefixedDSC);
    }
    
    /**
     * Will parse a baggage header, which is a simple key-value map, into a flat object.
     *
     * @param baggageHeader The baggage header to parse.
     * @returns a flat object containing all the key-value pairs from `baggageHeader`.
     */
    function baggageHeaderToObject(baggageHeader) {
      return baggageHeader
        .split(',')
        .map(baggageEntry => baggageEntry.split('=').map(keyOrValue => decodeURIComponent(keyOrValue.trim())))
        .reduce((acc, [key, value]) => {
          acc[key] = value;
          return acc;
        }, {});
    }
    
    /**
     * Turns a flat object (key-value pairs) into a baggage header, which is also just key-value pairs.
     *
     * @param object The object to turn into a baggage header.
     * @returns a baggage header string, or `undefined` if the object didn't have any values, since an empty baggage header
     * is not spec compliant.
     */
    function objectToBaggageHeader(object) {
      if (Object.keys(object).length === 0) {
        // An empty baggage header is not spec compliant: We return undefined.
        return undefined;
      }
    
      return Object.entries(object).reduce((baggageHeader, [objectKey, objectValue], currentIndex) => {
        const baggageEntry = `${encodeURIComponent(objectKey)}=${encodeURIComponent(objectValue)}`;
        const newBaggageHeader = currentIndex === 0 ? baggageEntry : `${baggageHeader},${baggageEntry}`;
        if (newBaggageHeader.length > MAX_BAGGAGE_STRING_LENGTH) {
          (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
            _logger_js__WEBPACK_IMPORTED_MODULE_1__.logger.warn(
              `Not adding key: ${objectKey} with val: ${objectValue} to baggage header due to exceeding baggage size limits.`,
            );
          return baggageHeader;
        } else {
          return newBaggageHeader;
        }
      }, '');
    }
    
    
    //# sourceMappingURL=baggage.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "OnUncaughtException": () => (/* binding */ OnUncaughtException)
    /* harmony export */ });
    
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1640);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1653);
    /* harmony import */ var _utils_errorhandling_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1697);
    
    
    
    
    
    /** Global Exception handler */
    class OnUncaughtException  {
      /**
       * @inheritDoc
       */
       static __initStatic() {this.id = 'OnUncaughtException';}
    
      /**
       * @inheritDoc
       */
       __init() {this.name = OnUncaughtException.id;}
    
      /**
       * @inheritDoc
       */
        __init2() {this.handler = this._makeErrorHandler();}
    
      // CAREFUL: Please think twice before updating the way _options looks because the Next.js SDK depends on it in `index.server.ts`
    
      /**
       * @inheritDoc
       */
       constructor(options = {}) {;OnUncaughtException.prototype.__init.call(this);OnUncaughtException.prototype.__init2.call(this);
        this._options = {
          exitEvenIfOtherHandlersAreRegistered: true,
          ...options,
        };
      }
    
      /**
       * @inheritDoc
       */
       setupOnce() {
        global.process.on('uncaughtException', this.handler);
      }
    
      /**
       * @hidden
       */
       _makeErrorHandler() {
        const timeout = 2000;
        let caughtFirstError = false;
        let caughtSecondError = false;
        let calledFatalError = false;
        let firstError;
    
        return (error) => {
          let onFatalError = _utils_errorhandling_js__WEBPACK_IMPORTED_MODULE_0__.logAndExitProcess;
          const client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)().getClient();
    
          if (this._options.onFatalError) {
            // eslint-disable-next-line @typescript-eslint/unbound-method
            onFatalError = this._options.onFatalError;
          } else if (client && client.getOptions().onFatalError) {
            // eslint-disable-next-line @typescript-eslint/unbound-method
            onFatalError = client.getOptions().onFatalError ;
          }
    
          // Attaching a listener to `uncaughtException` will prevent the node process from exiting. We generally do not
          // want to alter this behaviour so we check for other listeners that users may have attached themselves and adjust
          // exit behaviour of the SDK accordingly:
          // - If other listeners are attached, do not exit.
          // - If the only listener attached is ours, exit.
          const userProvidedListenersCount = global.process
            .listeners('uncaughtException')
            .reduce((acc, listener) => {
              if (
                listener.name === 'domainUncaughtExceptionClear' || // as soon as we're using domains this listener is attached by node itself
                listener === this.handler // filter the handler we registered ourselves)
              ) {
                return acc;
              } else {
                return acc + 1;
              }
            }, 0);
    
          const processWouldExit = userProvidedListenersCount === 0;
          const shouldApplyFatalHandlingLogic = this._options.exitEvenIfOtherHandlersAreRegistered || processWouldExit;
    
          if (!caughtFirstError) {
            const hub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)();
    
            // this is the first uncaught error and the ultimate reason for shutting down
            // we want to do absolutely everything possible to ensure it gets captured
            // also we want to make sure we don't go recursion crazy if more errors happen after this one
            firstError = error;
            caughtFirstError = true;
    
            if (hub.getIntegration(OnUncaughtException)) {
              hub.withScope((scope) => {
                scope.setLevel('fatal');
                hub.captureException(error, {
                  originalException: error,
                  data: { mechanism: { handled: false, type: 'onuncaughtexception' } },
                });
                if (!calledFatalError && shouldApplyFatalHandlingLogic) {
                  calledFatalError = true;
                  onFatalError(error);
                }
              });
            } else {
              if (!calledFatalError && shouldApplyFatalHandlingLogic) {
                calledFatalError = true;
                onFatalError(error);
              }
            }
          } else {
            if (shouldApplyFatalHandlingLogic) {
              if (calledFatalError) {
                // we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
                (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
                  _sentry_utils__WEBPACK_IMPORTED_MODULE_2__.logger.warn(
                    'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown',
                  );
                (0,_utils_errorhandling_js__WEBPACK_IMPORTED_MODULE_0__.logAndExitProcess)(error);
              } else if (!caughtSecondError) {
                // two cases for how we can hit this branch:
                //   - capturing of first error blew up and we just caught the exception from that
                //     - quit trying to capture, proceed with shutdown
                //   - a second independent error happened while waiting for first error to capture
                //     - want to avoid causing premature shutdown before first error capture finishes
                // it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
                // so let's instead just delay a bit before we proceed with our action here
                // in case 1, we just wait a bit unnecessarily but ultimately do the same thing
                // in case 2, the delay hopefully made us wait long enough for the capture to finish
                // two potential nonideal outcomes:
                //   nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
                //   nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
                // note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
                //   we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
                caughtSecondError = true;
                setTimeout(() => {
                  if (!calledFatalError) {
                    // it was probably case 1, let's treat err as the sendErr and call onFatalError
                    calledFatalError = true;
                    onFatalError(firstError, error);
                  } else {
                    // it was probably case 2, our first error finished capturing while we waited, cool, do nothing
                  }
                }, timeout); // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
              }
            }
          }
        };
      }
    } OnUncaughtException.__initStatic();
    
    
    //# sourceMappingURL=onuncaughtexception.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "logAndExitProcess": () => (/* binding */ logAndExitProcess)
    /* harmony export */ });
    
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1640);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1653);
    
    
    
    
    const DEFAULT_SHUTDOWN_TIMEOUT = 2000;
    
    /**
     * @hidden
     */
    function logAndExitProcess(error) {
      // eslint-disable-next-line no-console
      console.error(error && error.stack ? error.stack : error);
    
      const client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_0__.getCurrentHub)().getClient();
    
      if (client === undefined) {
        (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('No NodeClient was defined, we are exiting the process now.');
        global.process.exit(1);
      }
    
      const options = client.getOptions();
      const timeout =
        (options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||
        DEFAULT_SHUTDOWN_TIMEOUT;
      client.close(timeout).then(
        (result) => {
          if (!result) {
            (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
          }
          global.process.exit(1);
        },
        error => {
          (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
        },
      );
    }
    
    
    //# sourceMappingURL=errorhandling.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "OnUnhandledRejection": () => (/* binding */ OnUnhandledRejection)
    /* harmony export */ });
    
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1640);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1653);
    /* harmony import */ var _utils_errorhandling_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1697);
    
    
    
    
    
    /** Global Promise Rejection handler */
    class OnUnhandledRejection  {
      /**
       * @inheritDoc
       */
       static __initStatic() {this.id = 'OnUnhandledRejection';}
    
      /**
       * @inheritDoc
       */
       __init() {this.name = OnUnhandledRejection.id;}
    
      /**
       * @inheritDoc
       */
       constructor(
          _options
    
     = { mode: 'warn' },
      ) {;this._options = _options;OnUnhandledRejection.prototype.__init.call(this);}
    
      /**
       * @inheritDoc
       */
       setupOnce() {
        global.process.on('unhandledRejection', this.sendUnhandledPromise.bind(this));
      }
    
      /**
       * Send an exception with reason
       * @param reason string
       * @param promise promise
       */
      // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
       sendUnhandledPromise(reason, promise) {
        const hub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)();
        if (hub.getIntegration(OnUnhandledRejection)) {
          hub.withScope((scope) => {
            scope.setExtra('unhandledPromiseRejection', true);
            hub.captureException(reason, {
              originalException: promise,
              data: { mechanism: { handled: false, type: 'onunhandledrejection' } },
            });
          });
        }
        this._handleRejection(reason);
      }
    
      /**
       * Handler for `mode` option
       */
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
       _handleRejection(reason) {
        // https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240
        const rejectionWarning =
          'This error originated either by ' +
          'throwing inside of an async function without a catch block, ' +
          'or by rejecting a promise which was not handled with .catch().' +
          ' The promise rejected with the reason:';
    
        /* eslint-disable no-console */
        if (this._options.mode === 'warn') {
          (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.consoleSandbox)(() => {
            console.warn(rejectionWarning);
            // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
            console.error(reason && reason.stack ? reason.stack : reason);
          });
        } else if (this._options.mode === 'strict') {
          (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.consoleSandbox)(() => {
            console.warn(rejectionWarning);
          });
          (0,_utils_errorhandling_js__WEBPACK_IMPORTED_MODULE_0__.logAndExitProcess)(reason);
        }
        /* eslint-enable no-console */
      }
    } OnUnhandledRejection.__initStatic();
    
    
    //# sourceMappingURL=onunhandledrejection.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
    
    "use strict";
    __webpack_require__.r(__webpack_exports__);
    /* harmony export */ __webpack_require__.d(__webpack_exports__, {
    /* harmony export */   "LinkedErrors": () => (/* binding */ LinkedErrors)
    /* harmony export */ });
    
    /* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1663);
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1641);
    /* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1640);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1649);
    /* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1652);
    /* harmony import */ var _eventbuilder_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1666);
    /* harmony import */ var _contextlines_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1700);
    
    
    
    
    
    
    
    const DEFAULT_KEY = 'cause';
    const DEFAULT_LIMIT = 5;
    
    /** Adds SDK info to an event. */
    class LinkedErrors  {
      /**
       * @inheritDoc
       */
       static __initStatic() {this.id = 'LinkedErrors';}
    
      /**
       * @inheritDoc
       */
        __init() {this.name = LinkedErrors.id;}
    
      /**
       * @inheritDoc
       */
    
      /**
       * @inheritDoc
       */
    
      /**
       * @inheritDoc
       */
       constructor(options = {}) {;LinkedErrors.prototype.__init.call(this);
        this._key = options.key || DEFAULT_KEY;
        this._limit = options.limit || DEFAULT_LIMIT;
      }
    
      /**
       * @inheritDoc
       */
       setupOnce() {
        (0,_sentry_core__WEBPACK_IMPORTED_MODULE_2__.addGlobalEventProcessor)(async (event, hint) => {
          const hub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_3__.getCurrentHub)();
          const self = hub.getIntegration(LinkedErrors);
          const client = hub.getClient();
          if (client && self && self._handler && typeof self._handler === 'function') {
            await self._handler(client.getOptions().stackParser, event, hint);
          }
          return event;
        });
      }
    
      /**
       * @inheritDoc
       */
       _handler(stackParser, event, hint) {
        if (!event.exception || !event.exception.values || !(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(hint.originalException, Error)) {
          return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.resolvedSyncPromise)(event);
        }
    
        return new _sentry_utils__WEBPACK_IMPORTED_MODULE_5__.SyncPromise(resolve => {
          void this._walkErrorTree(stackParser, hint.originalException , this._key)
            .then((linkedErrors) => {
              if (event && event.exception && event.exception.values) {
                event.exception.values = [...linkedErrors, ...event.exception.values];
              }
              resolve(event);
            })
            .then(null, () => {
              resolve(event);
            });
        });
      }
    
      /**
       * @inheritDoc
       */
       async _walkErrorTree(
        stackParser,
        error,
        key,
        stack = [],
      ) {
        if (!(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(error[key], Error) || stack.length + 1 >= this._limit) {
          return Promise.resolve(stack);
        }
    
        const exception = (0,_eventbuilder_js__WEBPACK_IMPORTED_MODULE_0__.exceptionFromError)(stackParser, error[key]);
    
        // If the ContextLines integration is enabled, we add source code context to linked errors
        // because we can't guarantee the order that integrations are run.
        const contextLines = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_3__.getCurrentHub)().getIntegration(_contextlines_js__WEBPACK_IMPORTED_MODULE_1__.ContextLines);
        if (contextLines && (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_6__._optionalChain)([exception, 'access', _ => _.stacktrace, 'optionalAccess', _2 => _2.frames])) {
          await contextLines.addSourceContextToFrames(exception.stacktrace.frames);
        }
    
        return new Promise((resolve, reject) => {
          void this._walkErrorTree(stackParser, error[key], key, [exception, ...stack])
            .then(resolve)
            .then(null, () => {
              reject();
            });
        });
      }
    }LinkedErrors.__initStatic();
    
    
    //# sourceMappingURL=linkederrors.js.map
    
    
    /***/ }),
    
    /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {