{"version":3,"file":"index.js","sources":["../../../src/prisma/index.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { setGlobalTracingHelper } from './global';\nimport { ActiveTracingHelper } from './tracing-helper';\n\nconst INTEGRATION_NAME = 'Prisma' as const;\n\nexport interface PrismaInstrumentationConfig {\n /**\n * Span types that should not be traced. Matched against the full span name (e.g. `prisma:client:operation`),\n * either exactly (string) or by pattern (RegExp).\n */\n ignoreSpanTypes?: (string | RegExp)[];\n}\n\nexport interface PrismaOptions {\n /**\n * @deprecated This is no longer used, v5 works out of the box.\n */\n prismaInstrumentation?: unknown;\n /**\n * Configuration for the Prisma tracing helper.\n */\n instrumentationConfig?: PrismaInstrumentationConfig;\n}\n\n/**\n * Sets up the global Prisma tracing helper that Prisma looks up on `globalThis` to emit tracing data.\n *\n * Prisma reads `globalThis.PRISMA_INSTRUMENTATION` (and its versioned variant) to find a \"TracingHelper\"\n * which it uses internally to create spans, so it can produce tracing data without depending on\n * OpenTelemetry. The helper we install here mints spans through Sentry's span APIs. A single helper\n * serves both Prisma v5 (which calls `createEngineSpan`) and v6/v7 (which call `dispatchEngineSpans`),\n * so it doesn't blow up on version mismatches.\n */\nexport function instrumentPrisma(options?: PrismaOptions): void {\n setGlobalTracingHelper(\n new ActiveTracingHelper({\n ignoreSpanTypes: options?.instrumentationConfig?.ignoreSpanTypes ?? [],\n }),\n );\n}\n\nconst _prismaIntegration = ((options?: PrismaOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library.\n * For more information, see the [`prismaIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).\n *\n * NOTE: This integration works out of the box with Prisma v6, and v7.\n * On Prisma versions prior to v6, add `previewFeatures = [\"tracing\"]` to the client generator block of your Prisma schema:\n *\n * ```\n * generator client {\n * provider = \"prisma-client-js\"\n * previewFeatures = [\"tracing\"]\n * }\n * ```\n */\nexport const prismaIntegration = defineIntegration(_prismaIntegration);\n"],"names":[],"mappings":";;;;AAKA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAmB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AA8BlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+B;AAC9D,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACE,CAAA,CAAA,CAAA,CAAI,mBAAA,CAAoB;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACtB,eAAA,CAAA,CAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,eAAA,CAAA,CAAA,CAAA,CAAmB,CAAA;AAAC,CAAA,CAAA,CAAA,CAAA,CACtE;AAAA,CAAA,CAAA,CACH;AACF;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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