rittenhop-dev/versions/5.94.2/node_modules/@sentry/node/cjs/trpc.js.map

1 line
10 KiB
Plaintext
Raw Normal View History

2024-09-23 19:40:12 -04:00
{"version":3,"file":"trpc.js","sources":["../../src/trpc.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, captureException, getClient, getCurrentScope } from '@sentry/core';\nimport { isThenable, normalize } from '@sentry/utils';\n\ninterface SentryTrpcMiddlewareOptions {\n /** Whether to include procedure inputs in reported events. Defaults to `false`. */\n attachRpcInput?: boolean;\n}\n\ninterface TrpcMiddlewareArguments<T> {\n path: string;\n type: string;\n next: () => T;\n rawInput: unknown;\n}\n\n/**\n * Sentry tRPC middleware that names the handling transaction after the called procedure.\n *\n * Use the Sentry tRPC middleware in combination with the Sentry server integration,\n * e.g. Express Request Handlers or Next.js SDK.\n */\nexport function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {\n return function <T>({ path, type, next, rawInput }: TrpcMiddlewareArguments<T>): T {\n const clientOptions = getClient()?.getOptions();\n // eslint-disable-next-line deprecation/deprecation\n const sentryTransaction = getCurrentScope().getTransaction();\n\n if (sentryTransaction) {\n sentryTransaction.updateName(`trpc/${path}`);\n sentryTransaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n sentryTransaction.op = 'rpc.server';\n\n const trpcContext: Record<string, unknown> = {\n procedure_type: type,\n };\n\n if (options.attachRpcInput !== undefined ? options.attachRpcInput : clientOptions?.sendDefaultPii) {\n trpcContext.input = normalize(rawInput);\n }\n\n // TODO: Can we rewrite this to an attribute? Or set this on the scope?\n // eslint-disable-next-line deprecation/deprecation\n sentryTransaction.setContext('trpc', trpcContext);\n }\n\n function captureIfError(nextResult: { ok: false; error?: Error } | { ok: true }): void {\n if (!nextResult.ok) {\n captureException(nextResult.error, { mechanism: { handled: false, data: { function: 'trpcMiddleware' } } });\n }\n }\n\n let maybePromiseResult;\n try {\n maybePromiseResult = next();\n } catch (e) {\n captureException(e, { mechanism: { handled: false, data: { function: 'trpcMiddleware' } } });\n throw e;\n }\n\n if (isThenable(maybePromiseResult)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Promise.resolve(maybePromiseResult).then(\n nextResult => {\n captureIfError(nextResult as any);\n },\n e => {\n captureException(e, { mechanism: { handled: false, data: { function: 'trpcMiddleware' } } });\n },\n );\n } else {\n captureIfError(maybePromiseResult as any);\n }\n\n // We return the original promise just to be safe.\n return maybePromiseResult;\n };\n}\n"],"names":["getClient","getCurrentScope","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","normalize","captureException","isThenable"],"mappings":";;;;;;;;;AAeA,CAAA,CAAA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CACA;CACA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAA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