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gBAAgB,CAAC,KAAK,CAAC,CAAC;gBACxC,sEAAsE;gBACrE,GAAW,CAAC,MAAM,GAAG,OAAO,CAAC;gBAC9B,IAAI,CAAC,KAAK,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,OAAO;SACR;QAED,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { captureException, getCurrentHub, startTransaction, withScope } from '@sentry/core';\nimport { extractTraceparentData, Span } from '@sentry/tracing';\nimport { Event, ExtractedNodeRequestData, RequestSessionStatus, Transaction } from '@sentry/types';\nimport { isPlainObject, isString, logger, normalize, stripUrlQueryAndFragment } from '@sentry/utils';\nimport * as cookie from 'cookie';\nimport * as domain from 'domain';\nimport * as http from 'http';\nimport * as os from 'os';\nimport * as url from 'url';\n\nimport { NodeClient } from './client';\nimport { flush, isAutoSessionTrackingEnabled } from './sdk';\n\nexport interface ExpressRequest {\n baseUrl?: string;\n connection?: {\n remoteAddress?: string;\n };\n ip?: string;\n method?: string;\n originalUrl?: string;\n route?: {\n path: string;\n stack: [\n {\n name: string;\n },\n ];\n };\n query?: {\n // It can be: undefined | string | string[] | ParsedQs | ParsedQs[] (from `qs` package), but we dont want to pull it.\n [key: string]: unknown;\n };\n url?: string;\n user?: {\n [key: string]: any;\n };\n}\n\n/**\n * Express-compatible tracing handler.\n * @see Exposed as `Handlers.tracingHandler`\n */\nexport function tracingHandler(): (\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error?: any) => void,\n) => void {\n return function sentryTracingMiddleware(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error?: any) => void,\n ): void {\n // If there is a trace header set, we extract the data from it (parentSpanId, traceId, and sampling decision)\n let traceparentData;\n if (req.headers && isString(req.headers['sentry-trace'])) {\n traceparentData = extractTraceparentData(req.headers['sentry-trace'] as string);\n }\n\n const transaction = startTransaction(\n {\n name: extractExpressTransactionName(req, { path: true, method: true }),\n op: 'http.server',\n ...traceparentData,\n },\n // extra context passed to the tracesSampler\n { request: extractRequestData(req) },\n );\n\n // We put the transaction on the scope so users can attach children to it\n getCurrentHub().configureScope(scope => {\n scope.setSpan(transaction);\n });\n\n // We also set __sentry_transaction on the response so people can grab the transaction there to add\n // spans to it later.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n (res as any).__sentry_transaction = transaction;\n\n res.once('finish', () => {\n // Push `transaction.finish` to the next event loop so open spans have a chance to finish before the transaction\n // closes\n setImmediate(() => {\n addExpressReqToTransaction(transaction, req);\n transaction.setHttpStatus(res.statusCode);\n transaction.finish();\n });\n });\n\n next();\n };\n}\n\n/**\n * Set parameterized as transaction name e.g.: `GET /users/:id`\n * Also adds more context data on the transaction from the request\n */\nfunction addExpressReqToTransaction(transaction: Transaction | undefined, req: ExpressRequest): void {\n if (!transaction) return;\n transaction.name = extractExpressTransactionName(req, { path: true, method: true });\n transaction.setData('url', req.originalUrl);\n transaction.setData('baseUrl', req.baseUrl);\n transaction.setData('query', req.query);\n}\n\n/**\n * Extracts complete generalized path from the request object and uses it to construct transaction name.\n *\n * eg. GET /mountpoint/user/:id\n *\n * @param req The ExpressRequest object\n * @param options What to include in the transaction name (method, path, or both)\n *\n * @returns The fully constructed transaction name\n */\nfunction extractExpressTransactionName(\n req: ExpressRequest,\n options: { path?: boolean; method?: boolean } = {},\n): string {\n const method = req.method?.toUpperCase();\n\n let path = '';\n if (req.route) {\n path = `${req.baseUrl || ''}${req.route.path}`;\n } else if (req.originalUrl || req.url) {\n path = stripUrlQueryAndFragment(req.originalUrl || req.url || '');\n }\n\n let info = '';\n if (options.method && method) {\n info += method;\n }\n if (options.method && options.path) {\n info += ` `;\n }\n if (options.path && path) {\n info += path;\n }\n\n return info;\n}\n\ntype TransactionNamingScheme = 'path' | 'methodPath' | 'handler';\n\n/** JSDoc */\nfunction extractTransaction(req: ExpressRequest, type: boolean | TransactionNamingScheme): string {\n switch (type) {\n case 'path': {\n return extractExpressTransactionName(req, { path: true });\n }\n case 'handler': {\n return req.route?.stack[0].name || '<anonymous>';\n }\n case 'methodPath':\n default: {\n return extractExpressTransactionName(req, { path: true, method: true });\n }\n }\n}\n\n/** Default user keys that'll be used to extract data from the request */\nconst DEFAULT_USER_KEYS = ['id', 'username', 'email'];\n\n/** JSDoc */\nfunction extractUserData(\n user: {\n [key: string]: any;\n },\n keys: boolean | string[],\n): { [key: string]: any } {\n const extractedUser: { [key: string]: any } = {};\n const attributes = Array.isArray(keys) ? keys : DEFAULT_USER_KEYS;\n\n attributes.forEach(key => {\n if (user && key in user) {\n extractedUser[key] = user[key];\n }\n });\n\n return extractedUser;\n}\n\n/** Default request keys that'll be used to extract data from the request */\nconst DEFAULT_REQUEST_KEYS = ['cookies', 'data', 'headers', 'method', 'query_string', 'url'];\n\n/**\n * Normalizes data from the request object, accounting for framework differences.\n *\n * @param req The request object from which to extract data\n * @param keys An optional array of keys to include in the normalized data. Defaults to DEFAULT_REQUEST_KEYS if not\n * provided.\n * @returns An object containing normalized request data\n */\nexport function extractRequestData(\n req: { [key: string]: any },\n keys: string[] = DEFAULT_REQUEST_KEYS,\n): ExtractedNodeRequestData {\n const requestData: { [key: string]: any } = {};\n\n // headers:\n // node, express, nextjs: req.headers\n // koa: req.header\n const headers = (req.headers || req.header || {}) as {\n host?: string;\n cookie?: string;\n };\n // method:\n // node, express, koa, nextjs: req.method\n const method = req.method;\n // host:\n // express: req.hostname in > 4 and req.host in < 4\n // koa: req.host\n // node, nextjs: req.headers.host\n const host = req.hostname || req.host || headers.host || '<no host>';\n // protocol:\n // node, nextjs: <n/a>\n // express, koa: req.protocol\n const protocol =\n req.protocol === 'https' || req.secure || ((req.socket || {}) as { encrypted?: boolean }).encrypted\n ? 'https'\n : 'http';\n // url (including path and query string):\n // node, express: req.originalUrl\n // koa, nextjs: req.url\n const originalUrl = (req.originalUrl || req.url || '') as string;\n // absolute url\n const absoluteUrl = `${protocol}://${host}${originalUrl}`;\n\n keys.forEach(key => {\n switch (key) {\n case 'headers':\n requestData.headers = headers;\n break;\n case 'method':\n requestData.method = method;\n break;\n case 'url':\n requestData.url = absoluteUrl;\n break;\n case 'cookies':\n // cookies:\n // node, express, koa: req.headers.cookie\n // vercel, sails.js, express (w/ cookie middleware), nextjs: req.cookies\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n requestData.cookies = req.cookies || cookie.parse(headers.cookie || '');\n break;\n case 'query_string':\n // query string:\n // node: req.url (raw)\n // express, koa, nextjs: req.query\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n requestData.query_string = req.query || url.parse(originalUrl || '', false).query;\n break;\n case 'data':\n if (method === 'GET' || method === 'HEAD') {\n break;\n }\n // body data:\n // express, koa, nextjs: req.body\n //\n // when using node by itself, you have to read the incoming stream(see\n // https://nodejs.dev/learn/get-http-request-body-data-using-nodejs); if a user is doing that, we can't know\n // where they're going to store the final result, so they'll have to capture this data themselves\n if (req.body !== undefined) {\n requestData.data = isString(req.body) ? req.body : JSON.stringify(normalize(req.body));\n }\n break;\n default:\n if ({}.hasOwnProperty.call(req, key)) {\n requestData[key] = (req as { [key: string]: any })[key];\n }\n }\n });\n\n return requestData;\n}\n\n/**\n * Options deciding what parts of the request to use when enhancing an event\n */\nexport interface ParseRequestOptions {\n ip?: boolean;\n request?: boolean | string[];\n serverName?: boolean;\n transaction?: boolean | TransactionNamingScheme;\n user?: boolean | string[];\n version?: boolean;\n}\n\n/**\n * Enriches passed event with request data.\n *\n * @param event Will be mutated and enriched with req data\n * @param req Request object\n * @param options object containing flags to enable functionality\n * @hidden\n */\nexport function parseRequest(event: Event, req: ExpressRequest, options?: ParseRequestOptions): Event {\n // eslint-disable-next-line no-param-reassign\n options = {\n ip: false,\n request: true,\n serverName: true,\n transaction: true,\n user: true,\n version: true,\n ...options,\n };\n\n if (options.version) {\n event.contexts = {\n ...event.contexts,\n runtime: {\n name: 'node',\n version: global.process.version,\n },\n };\n }\n\n if (options.request) {\n // if the option value is `true`, use the default set of keys by not passing anything to `extractRequestData()`\n const extractedRequestData = Array.isArray(options.request)\n ? extractRequestData(req, options.request)\n : extractRequestData(req);\n event.request = {\n ...event.request,\n ...extractedRequestData,\n };\n }\n\n if (options.serverName && !event.server_name) {\n event.server_name = global.process.env.SENTRY_NAME || os.hostname();\n }\n\n if (options.user) {\n const extractedUser = req.user && isPlainObject(req.user) ? extractUserData(req.user, options.user) : {};\n\n if (Object.keys(extractedUser)) {\n event.user = {\n ...event.user,\n ...extractedUser,\n };\n }\n }\n\n // client ip:\n // node, nextjs: req.connection.remoteAddress\n // express, koa: req.ip\n if (options.ip) {\n const ip = req.ip || (req.connection && req.connection.remoteAddress);\n if (ip) {\n event.user = {\n ...event.user,\n ip_address: ip,\n };\n }\n }\n\n if (options.transaction && !event.transaction) {\n // TODO do we even need this anymore?\n // TODO make this work for nextjs\n event.transaction = extractTransaction(req, options.transaction);\n }\n\n return event;\n}\n\nexport type RequestHandlerOptions = ParseRequestOptions & {\n flushTimeout?: number;\n};\n\n/**\n * Express compatible request handler.\n * @see Exposed as `Handlers.requestHandler`\n */\nexport function requestHandler(\n options?: RequestHandlerOptions,\n): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void {\n const currentHub = getCurrentHub();\n const client = currentHub.getClient<NodeClient>();\n // Initialise an instance of SessionFlusher on the client when `autoSessionTracking` is enabled and the\n // `requestHandler` middleware is used indicating that we are running in SessionAggregates mode\n if (client && isAutoSessionTrackingEnabled(client)) {\n client.initSessionFlusher();\n\n // If Scope contains a Single mode Session, it is removed in favor of using Session Aggregates mode\n const scope = currentHub.getScope();\n if (scope && scope.getSession()) {\n scope.setSession();\n }\n }\n return function sentryRequestMiddleware(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error?: any) => void,\n ): void {\n if (options && options.flushTimeout && options.flushTimeout > 0) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const _end = res.end;\n res.end = function(chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): void {\n void flush(options.flushTimeout)\n .then(() => {\n _end.call(this, chunk, encoding, cb);\n })\n .then(null, e => {\n logger.error(e);\n });\n };\n }\n const local = domain.create();\n local.add(req);\n local.add(res);\n local.on('error', next);\n\n local.run(() => {\n const currentHub = getCurrentHub();\n\n currentHub.configureScope(scope => {\n scope.addEventProcessor((event: Event) => parseRequest(event, req, options));\n const client = currentHub.getClient<NodeClient>();\n if (isAutoSessionTrackingEnabled(client)) {\n const scope = currentHub.getScope();\n if (scope) {\n // Set `status` of `RequestSession` to Ok, at the beginning of the request\n scope.setRequestSession({ status: RequestSessionStatus.Ok });\n }\n }\n });\n\n res.once('finish', () => {\n const client = currentHub.getClient<NodeClient>();\n if (isAutoSessionTrackingEnabled(client)) {\n setImmediate(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (client && (client as any)._captureRequestSession) {\n // Calling _captureRequestSession to capture request session at the end of the request by incrementing\n // the correct SessionAggregates bucket i.e. crashed, errored or exited\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n (client as any)._captureRequestSession();\n }\n });\n }\n });\n next();\n });\n };\n}\n\n/** JSDoc */\ninterface MiddlewareError extends Error {\n status?: number | string;\n statusCode?: number | string;\n status_code?: number | string;\n output?: {\n statusCode?: number | string;\n };\n}\n\n/** JSDoc */\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || (error.output && error.output.statusCode);\n return statusCode ? parseInt(statusCode as string, 10) : 500;\n}\n\n/** Returns true if response code is internal server error */\nfunction defaultShouldHandleError(error: MiddlewareError): boolean {\n const status = getStatusCodeFromResponse(error);\n return status >= 500;\n}\n\n/**\n * Express compatible error handler.\n * @see Exposed as `Handlers.errorHandler`\n */\nexport function errorHandler(options?: {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(error: MiddlewareError): boolean;\n}): (\n error: MiddlewareError,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n) => void {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n _req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const shouldHandleError = (options && options.shouldHandleError) || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n withScope(_scope => {\n // For some reason we need to set the transaction on the scope again\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const transaction = (res as any).__sentry_transaction as Span;\n if (transaction && _scope.getSpan() === undefined) {\n _scope.setSpan(transaction);\n }\n\n const client = getCurrentHub().getClient<NodeClient>();\n if (client && isAutoSessionTrackingEnabled(client)) {\n // Check if the `SessionFlusher` is instantiated on the client to go into this branch that marks the\n // `requestSession.status` as `Crashed`, and this check is necessary because the `SessionFlusher` is only\n // instantiated when the the`requestHandler` middleware is initialised, which indicates that we should be\n // running in SessionAggregates mode\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isSessionAggregatesMode = (client as any)._sessionFlusher !== undefined;\n if (isSessionAggregatesMode) {\n const requestSession = _scope.getRequestSession();\n // If an error bubbles to the `errorHandler`, then this is an unhandled error, and should be reported as a\n // Crashed session. The `_requestSession.status` is checked to ensure that this error is happening within\n // the bounds of a request, and if so the status is updated\n if (requestSession && requestSession.status !== undefined)\n requestSession.status = RequestSessionStatus.Crashed;\n }\n }\n\n const eventId = captureException(error);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n (res as any).sentry = eventId;\n next(error);\n });\n\n return;\n }\n\n next(error);\n };\n}\n"]}
\No newline at end of file