Files
doneit-web/.angular/cache/14.2.12/babel-webpack/fa7311d4ee974312c46492eeab09e54d.json
T

1 line
31 KiB
JSON
Raw Normal View History

2023-06-30 09:54:21 +01:00
{"ast":null,"code":"import { _optionalChain } from '@sentry/utils/esm/buildPolyfills';\nimport { logger, getNumberOfUrlSegments, extractPathForTransaction, isRegExp } from '@sentry/utils';\n\n/**\n * Express integration\n *\n * Provides an request and error handler for Express framework as well as tracing capabilities\n */\nclass Express {\n /**\n * @inheritDoc\n */\n static __initStatic() {\n this.id = 'Express';\n }\n\n /**\n * @inheritDoc\n */\n __init() {\n this.name = Express.id;\n }\n\n /**\n * Express App instance\n */\n\n /**\n * @inheritDoc\n */\n constructor(options = {}) {\n ;\n Express.prototype.__init.call(this);\n this._router = options.router || options.app;\n this._methods = (Array.isArray(options.methods) ? options.methods : []).concat('use');\n }\n\n /**\n * @inheritDoc\n */\n setupOnce() {\n if (!this._router) {\n (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('ExpressIntegration is missing an Express instance');\n return;\n }\n instrumentMiddlewares(this._router, this._methods);\n instrumentRouter(this._router);\n }\n}\nExpress.__initStatic();\n\n/**\n * Wraps original middleware function in a tracing call, which stores the info about the call as a span,\n * and finishes it once the middleware is done invoking.\n *\n * Express middlewares have 3 various forms, thus we have to take care of all of them:\n * // sync\n * app.use(function (req, res) { ... })\n * // async\n * app.use(function (req, res, next) { ... })\n * // error handler\n * app.use(function (err, req, res, next) { ... })\n *\n * They all internally delegate to the `router[method]` of the given application instance.\n */\nfunction wrap(fn, method) {\n var arity = fn.length;\n switch (arity) {\n case 2:\n {\n return function (req, res) {\n var transaction = res.__sentry_transaction;\n if (transaction) {\n var span = transaction.startChild({\n description: fn.name,\n op: `express.middleware.${method}`\n });\n res.once('finish', () => {\n span.finish();\n });\n }\n return fn.call(this, req, res);\n };\n }\n case 3:\n {\n return function (req, res, next) {\n var transaction = res.__sentry_transaction;\n var span = _optionalChain([transaction, 'optionalAccess', _ => _.startChild, 'call', _2 => _2({\n description: fn.name,\n op: `express.middleware.${method}`\n })]);\n fn.call(this, req, res, function (...args) {\n _optionalChain([span, 'optionalAccess', _3 => _3.finish, 'call', _4 => _4()]);\n next.call(this, ...args);\n });\n };\n }\n case 4:\n {\n return function (err, req, res, next) {\n var transaction = res.__sentry_transaction;\n var span = _optionalChain([transaction, 'optionalAccess', _5 => _5.startChild, 'call', _6 => _6({\n description: fn.name,\n op: `express.middleware.${method}`\n })]);\n fn.call(this, err, req, res, function (...args) {\n _optionalChain([span, 'optionalAccess', _7 => _7.finish, 'call', _8 => _8()]);\n next.call(this, ...args);\n });\n };\n }\n default:\n {\n throw new Error(`Express middleware takes 2-4 arguments. Got: ${arity}`);\n }\n }\n}\n\n/**\n * Takes all the function arguments passed to the original `app` or `router` method, eg. `app.use` or `router.use`\n * and wraps every function, as well as array of functions with a call to our `wrap` method.\n * We have to take care of the arrays as well as iterate over all of the arguments,\n * as `app.use` can accept middlewares in few various forms.\n *\n * app.use([<path>], <fn>)\n * app.use([<path>], <fn>, ...<fn>)\n * app.use([<path>], ...<fn>[])\n */\nfunction wrapMiddlewareArgs(args, method) {\n return args.map(arg => {\n if (typeof arg === 'function') {\n