Rocky_Mountain_Vending/.pnpm-store/v10/files/29/a2448845fee3c4091472d7a246b29bc03a87062d25b91a83ce2c53a25ed0cd71c657cacd9270d2fd66c21d23fb023c0e57c57f9830f7bc146b22a158a75430
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

1 line
No EOL
10 KiB
Text

{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type { Span } from '@opentelemetry/api';\nimport type { ExpressRequestInfo } from '@opentelemetry/instrumentation-express';\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n captureException,\n debug,\n defineIntegration,\n getDefaultIsolationScope,\n getIsolationScope,\n httpRequestToRequestData,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n} from '@sentry/core';\nimport { addOriginToSpan, ensureIsWrapped, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { ExpressInstrumentationV5 } from './express-v5/instrumentation';\n\nconst INTEGRATION_NAME = 'Express';\nconst INTEGRATION_NAME_V5 = 'Express-V5';\n\nfunction requestHook(span: Span): void {\n addOriginToSpan(span, 'auto.http.otel.express');\n\n const attributes = spanToJSON(span).data;\n // this is one of: middleware, request_handler, router\n const type = attributes['express.type'];\n\n if (type) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);\n }\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['express.name'];\n if (typeof name === 'string') {\n span.updateName(name);\n }\n}\n\nfunction spanNameHook(info: ExpressRequestInfo<unknown>, defaultName: string): string {\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && debug.warn('Isolation scope is still default isolation scope - skipping setting transactionName');\n return defaultName;\n }\n if (info.layerType === 'request_handler') {\n // type cast b/c Otel unfortunately types info.request as any :(\n const req = info.request as { method?: string };\n const method = req.method ? req.method.toUpperCase() : 'GET';\n getIsolationScope().setTransactionName(`${method} ${info.route}`);\n }\n return defaultName;\n}\n\nexport const instrumentExpress = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new ExpressInstrumentation({\n requestHook: span => requestHook(span),\n spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),\n }),\n);\n\nexport const instrumentExpressV5 = generateInstrumentOnce(\n INTEGRATION_NAME_V5,\n () =>\n new ExpressInstrumentationV5({\n requestHook: span => requestHook(span),\n spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),\n }),\n);\n\nconst _expressIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentExpress();\n instrumentExpressV5();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).\n *\n * If you also want to capture errors, you need to call `setupExpressErrorHandler(app)` after you set up your Express server.\n *\n * For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.expressIntegration()],\n * })\n * ```\n */\nexport const expressIntegration = defineIntegration(_expressIntegration);\n\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\ntype ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;\n\ntype ExpressErrorMiddleware = (\n error: MiddlewareError,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n) => void;\n\ninterface ExpressHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: MiddlewareError): boolean;\n}\n\n/**\n * An Express-compatible error handler.\n */\nexport function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n request: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n const normalizedRequest = httpRequestToRequestData(request);\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n // When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too\n getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });\n\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });\n (res as { sentry?: string }).sentry = eventId;\n }\n\n next(error);\n };\n}\n\nfunction expressRequestHandler(): ExpressMiddleware {\n return function sentryRequestMiddleware(\n request: http.IncomingMessage,\n _res: http.ServerResponse,\n next: () => void,\n ): void {\n const normalizedRequest = httpRequestToRequestData(request);\n // Ensure we use the express-enhanced request here, instead of the plain HTTP one\n getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });\n\n next();\n };\n}\n\n/**\n * Add an Express error handler to capture errors to Sentry.\n *\n * The error handler must be before any other middleware and after all controllers.\n *\n * @param app The Express instances\n * @param options {ExpressHandlerOptions} Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const express = require(\"express\");\n *\n * const app = express();\n *\n * // Add your routes, etc.\n *\n * // Add this after all routes,\n * // but before any and other error-handling middlewares are defined\n * Sentry.setupExpressErrorHandler(app);\n *\n * app.listen(3000);\n * ```\n */\nexport function setupExpressErrorHandler(\n app: { use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown },\n options?: ExpressHandlerOptions,\n): void {\n app.use(expressRequestHandler());\n app.use(expressErrorHandler(options));\n ensureIsWrapped(app.use, 'express');\n}\n\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || 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"],"names":[],"mappings":";;;;;;AAmBA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,mBAAA,GAAsB,YAAY;;AAExC,SAAS,WAAW,CAAC,IAAI,EAAc;AACvC,EAAE,eAAe,CAAC,IAAI,EAAE,wBAAwB,CAAC;;AAEjD,EAAE,MAAM,aAAa,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AAC1C;AACA,EAAE,MAAM,IAAA,GAAO,UAAU,CAAC,cAAc,CAAC;;AAEzC,EAAE,IAAI,IAAI,EAAE;AACZ,IAAI,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE,CAAC,EAAA,IAAA,CAAA,QAAA,CAAA,CAAA;AACA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA,IAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA;AACA;AACA;;AAEA,SAAA,YAAA,CAAA,IAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,iBAAA,EAAA,KAAA,wBAAA,EAAA,EAAA;AACA,IAAA,WAAA,IAAA,KAAA,CAAA,IAAA,CAAA,qFAAA,CAAA;AACA,IAAA,OAAA,WAAA;AACA;AACA,EAAA,IAAA,IAAA,CAAA,SAAA,KAAA,iBAAA,EAAA;AACA;AACA,IAAA,MAAA,GAAA,GAAA,IAAA,CAAA,OAAA;AACA,IAAA,MAAA,MAAA,GAAA,GAAA,CAAA,MAAA,GAAA,GAAA,CAAA,MAAA,CAAA,WAAA,EAAA,GAAA,KAAA;AACA,IAAA,iBAAA,EAAA,CAAA,kBAAA,CAAA,CAAA,EAAA,MAAA,CAAA,CAAA,EAAA,IAA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