{"version":3,"file":"databaseConfig.js","sources":["../../../src/vite/databaseConfig.ts"],"sourcesContent":["import { addServerPlugin, createResolver } from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport type { NitroConfig } from 'nitropack/types';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { addServerTemplate } from '../vendor/server-template';\n\n/**\n * Sets up the database instrumentation.\n */\nexport function addDatabaseInstrumentation(\n nitro: NitroConfig,\n isLegacyNitro: boolean,\n moduleOptions?: SentryNuxtModuleOptions,\n): void {\n if (!nitro.experimental?.database) {\n // We cannot use DEBUG_BUILD here because it is a runtime flag, so it is not available for build time scripts\n // So we have to pass in the module options to the build time script\n moduleOptions?.debug &&\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',\n );\n });\n\n return;\n }\n\n /**\n * This is a different option than the one in `experimental.database`, this configures multiple database instances.\n * keys represent database names to be passed to `useDatabase(name?)`.\n * We also use the config to populate database span attributes.\n * https://nitro.build/guide/database#configuration\n */\n const databaseConfig = nitro.database || { default: {} };\n\n // Create a virtual module to pass this data to runtime\n addServerTemplate({\n filename: '#sentry/database-config.mjs',\n getContents: () => {\n return `export const databaseConfig = ${JSON.stringify(databaseConfig)};`;\n },\n });\n\n if (isLegacyNitro) {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database-legacy.server'));\n } else {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database.server'));\n }\n}\n"],"names":["consoleSandbox","addServerTemplate","addServerPlugin","createResolver"],"mappings":";;;;;;;AASO,SAAS,0BAAA,CACd,KAAA,EACA,aAAA,EACA,aAAA,EACM;AACN,EAAA,IAAI,CAAC,KAAA,CAAM,YAAA,EAAc,QAAA,EAAU;AAGjC,IAAA,aAAA,EAAe,KAAA,IACbA,oBAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,GAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAEH,IAAA;AAAA,EACF;AAQA,EAAA,MAAM,iBAAiB,KAAA,CAAM,QAAA,IAAY,EAAE,OAAA,EAAS,EAAC,EAAE;AAGvD,EAAAC,gCAAA,CAAkB;AAAA,IAChB,QAAA,EAAU,6BAAA;AAAA,IACV,aAAa,MAAM;AACjB,MAAA,OAAO,CAAA,8BAAA,EAAiC,IAAA,CAAK,SAAA,CAAU,cAAc,CAAC,CAAA,CAAA,CAAA;AAAA,IACxE;AAAA,GACD,CAAA;AAED,EAAA,IAAI,aAAA,EAAe;AACjB,IAAAC,mBAAA,CAAgBC,mBAAe,wQAAe,CAAA,CAAE,OAAA,CAAQ,0CAA0C,CAAC,CAAA;AAAA,EACrG,CAAA,MAAO;AACL,IAAAD,mBAAA,CAAgBC,mBAAe,wQAAe,CAAA,CAAE,OAAA,CAAQ,mCAAmC,CAAC,CAAA;AAAA,EAC9F;AACF;;;;"}