@sentry/nuxt 10.74.0 → 10.75.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,7 +59,7 @@ const module$1 = kit.defineNuxtModule({
59
59
  });
60
60
  }
61
61
  const serverConfigFile = await utils.findDefaultSdkInitFile("server", nuxt, moduleOptions);
62
- const isNitroV3 = await utils.getNitroMajorVersion() >= 3;
62
+ const isNitroV3 = await utils.getNitroMajorVersion(nuxt.options.rootDir) >= 3;
63
63
  const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
64
64
  const isMinNuxtV4 = nuxtMajor >= 4;
65
65
  if (serverConfigFile) {
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild } from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport { addOTelCommonJSImportAlias, findDefaultSdkInitFile, getNitroMajorVersion } from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion()) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n if (serverConfigFile) {\n if (moduleOptions._experimental?.useDiagnosticsChannelInjection) {\n setupOrchestrion(nuxt);\n }\n\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n }\n\n if (serverConfigFile?.includes('.server.config')) {\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt dev\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","consoleSandbox","addServerConfigToBuild","addSentryTopImport","addDynamicImportEntryFileWrapper"],"mappings":";;;;;;;;;;;;AAuBA,iBAAeA,oBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb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AAA,EAAoB;AAC/D,UAAAE,kCAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAAC,gDAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAAH,mBAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild } from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport { addOTelCommonJSImportAlias, findDefaultSdkInitFile, getNitroMajorVersion } from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion(nuxt.options.rootDir)) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n if (serverConfigFile) {\n if (moduleOptions._experimental?.useDiagnosticsChannelInjection) {\n setupOrchestrion(nuxt);\n }\n\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n }\n\n if (serverConfigFile?.includes('.server.config')) {\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt dev\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","consoleSandbox","addServerConfigToBuild","addSentryTopImport","addDynamicImportEntryFileWrapper"],"mappings":";;;;;;;;;;;;AAuBA,iBAAeA,oBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA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I,aAAA,CAAc,2BAA2B,kBAAA,EAAoB;AAC/D,UAAAE,kCAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAAC,gDAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAAH,mBAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
@@ -6,17 +6,23 @@ const path = require('path');
6
6
  const node_url = require('node:url');
7
7
  const kit = require('@nuxt/kit');
8
8
 
9
- async function getNitroMajorVersion() {
9
+ async function getNitroMajorVersion(rootDir) {
10
10
  try {
11
11
  const { getPackageInfo } = await import('local-pkg');
12
- const info = await getPackageInfo("nitro");
13
- if (info?.version) {
14
- const major = parseInt(info.version.split(".")[0] ?? "2", 10);
15
- return isNaN(major) ? 2 : major;
12
+ const fromPackage = (dir) => ({ paths: [path.join(dir, "package.json")] });
13
+ let provider = await getPackageInfo("nuxt", fromPackage(rootDir));
14
+ if (provider?.packageJson.dependencies?.["@nuxt/nitro-server"]) {
15
+ provider = await getPackageInfo("@nuxt/nitro-server", fromPackage(provider.rootPath)) ?? provider;
16
16
  }
17
+ if (!provider?.packageJson.dependencies?.nitro) {
18
+ return 2;
19
+ }
20
+ const info = await getPackageInfo("nitro", fromPackage(provider.rootPath));
21
+ const major = parseInt(info?.version?.split(".")[0] ?? "", 10);
22
+ return isNaN(major) ? 3 : major;
17
23
  } catch {
24
+ return 2;
18
25
  }
19
- return 2;
20
26
  }
21
27
  async function findDefaultSdkInitFile(type, nuxt, options) {
22
28
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'node:url';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the installed nitro package.\n * Returns 2 as the default if nitro is not found or the version cannot be determined.\n */\nexport async function getNitroMajorVersion(): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n const info = await getPackageInfo('nitro');\n if (info?.version) {\n const major = parseInt(info.version.split('.')[0] ?? '2', 10);\n return isNaN(major) ? 2 : major;\n }\n } catch {\n // If local-pkg is unavailable or nitro is not found, default to v2\n }\n return 2;\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n * The sentry.server.config file is prioritized over the instrument.server file.\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths: string[] = [];\n\n if (type === 'server') {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n relativePaths.push(path.join('public', `instrument.${type}.${ext}`));\n }\n } else {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n }\n }\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * Only exported for testing.\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":["resolvePath","consoleSandbox","fileURLToPath"],"mappings":";;;;;;;;AAYA,eAAsB,oBAAA,GAAwC;AAC5D,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AACnD,IAAA,MAAM,IAAA,GAAO,MAAM,cAAA,CAAe,OAAO,CAAA;AACzC,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,IAAK,GAAA,EAAK,EAAE,CAAA;AAC5D,MAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,CAAA,GAAI,KAAA;AAAA,IAC5B;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,CAAA;AACT;AAMA,eAAsB,sBAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EAC6B;AAC7B,EAAA,MAAM,yBAAyB,CAAC,IAAA,EAAM,MAAM,KAAA,EAAO,KAAA,EAAO,OAAO,KAAK,CAAA;AACtE,EAAA,MAAM,gBAA0B,EAAC;AAEjC,EAAA,IAAI,SAAS,QAAA,EAAU;AACrB,IAAA,KAAA,MAAW,OAAO,sBAAA,EAAwB;AACxC,MAAA,aAAA,CAAc,IAAA,CAAK,CAAA,OAAA,EAAU,IAAI,CAAA,QAAA,EAAW,GAAG,CAAA,CAAE,CAAA;AACjD,MAAA,aAAA,CAAc,IAAA,CAAK,KAAK,IAAA,CAAK,QAAA,EAAU,cAAc,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAC,CAAA;AAAA,IACrE;AAAA,EACF,CAAA,MAAO;AACL,IAAA,KAAA,MAAW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EACT;AACF;AAYO,SAAS,0BAAA,CAA2B,IAAA,EAAY,SAAA,GAAY,KAAA,EAAa;AAC9E,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACxB;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,EAAG;AACnD,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,GAAI,6CAAA;AAAA,EACnD;AACF;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'node:url';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the Nitro package used by the app's Nuxt installation.\n * Returns 2 as the default if the version cannot be determined.\n *\n * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is\n * unreliable: module resolution walks up the directory tree, so in a monorepo an\n * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.\n * Instead, follow the dependency chain Nuxt itself imports Nitro through:\n * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.\n */\nexport async function getNitroMajorVersion(rootDir: string): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n\n // `paths` entries must point at a file: for a bare directory, resolution starts at the\n // directory's parent and skips the directory's own `node_modules`, so a hoisted copy higher\n // up the tree (e.g. a monorepo root) wins over the app's actual dependency.\n const fromPackage = (dir: string): { paths: string[] } => ({ paths: [path.join(dir, 'package.json')] });\n\n // The package that declares the Nitro dependency: `nuxt` itself, or `@nuxt/nitro-server` (Nuxt >= 3.21) when nuxt delegates to it\n let provider = await getPackageInfo('nuxt', fromPackage(rootDir));\n if (provider?.packageJson.dependencies?.['@nuxt/nitro-server']) {\n provider = (await getPackageInfo('@nuxt/nitro-server', fromPackage(provider.rootPath))) ?? provider;\n }\n\n if (!provider?.packageJson.dependencies?.nitro) {\n return 2;\n }\n\n const info = await getPackageInfo('nitro', fromPackage(provider.rootPath));\n const major = parseInt(info?.version?.split('.')[0] ?? '', 10);\n // The provider imports `nitro` (not `nitropack`), so it is at least v3 even if the version is unreadable\n return isNaN(major) ? 3 : major;\n } catch {\n // If local-pkg is unavailable or resolution fails, default to v2\n return 2;\n }\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n * The sentry.server.config file is prioritized over the instrument.server file.\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths: string[] = [];\n\n if (type === 'server') {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n relativePaths.push(path.join('public', `instrument.${type}.${ext}`));\n }\n } else {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n }\n }\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * Only exported for testing.\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":["resolvePath","consoleSandbox","fileURLToPath"],"mappings":";;;;;;;;AAkBA,eAAsB,qBAAqB,OAAA,EAAkC;AAC3E,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AAKnD,IAAA,MAAM,WAAA,GAAc,CAAC,GAAA,MAAsC,EAAE,KAAA,EAAO,CAAC,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,EAAE,CAAA;AAGrG,IAAA,IAAI,WAAW,MAAM,cAAA,CAAe,MAAA,EAAQ,WAAA,CAAY,OAAO,CAAC,CAAA;AAChE,IAAA,IAAI,QAAA,EAAU,WAAA,CAAY,YAAA,GAAe,oBAAoB,CAAA,EAAG;AAC9D,MAAA,QAAA,GAAY,MAAM,cAAA,CAAe,oBAAA,EAAsB,YAAY,QAAA,CAAS,QAAQ,CAAC,CAAA,IAAM,QAAA;AAAA,IAC7F;AAEA,IAAA,IAAI,CAAC,QAAA,EAAU,WAAA,CAAY,YAAA,EAAc,KAAA,EAAO;AAC9C,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,MAAM,OAAO,MAAM,cAAA,CAAe,SAAS,WAAA,CAAY,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzE,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,IAAK,EAAA,EAAI,EAAE,CAAA;AAE7D,IAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,CAAA,GAAI,KAAA;AAAA,EAC5B,CAAA,CAAA,MAAQ;AAEN,IAAA,OAAO,CAAA;AAAA,EACT;AACF;AAMA,eAAsB,sBAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EAC6B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A,OAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAA,EAAY,KAAA,EAAM;AAAA,EAC3C;AACA,EAAA,IAAI,MAAA,KAAW,SAAA,IAAa,MAAA,KAAW,UAAA,EAAY;AACjD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAWC,uBAAc,MAAM,CAAA;AACrC,IAAA,IAAI,CAAC,QAAA,IAAY,QAAA,KAAa,GAAA,IAAO,aAAa,IAAA,EAAM;AACtD,MAAA,OAAO,KAAA,CAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,IAAA,EAAK;AAAA,EAC5C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAYO,SAAS,0BAAA,CAA2B,IAAA,EAAY,SAAA,GAAY,KAAA,EAAa;AAC9E,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACxB;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,EAAG;AACnD,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,GAAI,6CAAA;AAAA,EACnD;AACF;;;;;;;;;;;;;;;;"}
@@ -58,7 +58,7 @@ const module$1 = defineNuxtModule({
58
58
  });
59
59
  }
60
60
  const serverConfigFile = await findDefaultSdkInitFile("server", nuxt, moduleOptions);
61
- const isNitroV3 = await getNitroMajorVersion() >= 3;
61
+ const isNitroV3 = await getNitroMajorVersion(nuxt.options.rootDir) >= 3;
62
62
  const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
63
63
  const isMinNuxtV4 = nuxtMajor >= 4;
64
64
  if (serverConfigFile) {
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild } from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport { addOTelCommonJSImportAlias, findDefaultSdkInitFile, getNitroMajorVersion } from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion()) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n if (serverConfigFile) {\n if (moduleOptions._experimental?.useDiagnosticsChannelInjection) {\n setupOrchestrion(nuxt);\n }\n\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n }\n\n if (serverConfigFile?.includes('.server.config')) {\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt dev\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,MAAM,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM;AACpC,IAAA,IAAI,kBAAA,EAAoB,YAAY,KAAA,EAAO;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,GAAG,kBAAA;AAAA,MACH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA,MAC3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,iBAAA,GAAoB,cAAA,CAAe,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACxD,IAAA,MAAM,gBAAA,GAAmB,cAAA,CAAe,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAE7D,IAAA,MAAM,gBAAA,GAAmB,MAAM,sBAAA,CAAuB,QAAA,EAA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,CAAK,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,OAAA,EAAS,gBAAgB,CAAC,CAAA,CAAA;AAEtG,YAAA,cAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN,oBAAoB,gBAAgB,CAAA,sSAAA;AAAA,eACtC;AAEA,cAAA,IAAI,KAAA,CAAM,QAAQ,GAAA,EAAK;AAErB,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,oHAAoH,wBAAwB,CAAA,mJAAA;AAAA,iBAC9I;AAAA,cACF,CAAA,MAAO;AAEL,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,CAAA,sGAAA,EAAyG,wBAAwB,CAAA,mEAAA,EAAsE,wBAAwB,CAAA,gBAAA;AAAA,iBACjO;AAAA,cACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,kBAAA,EAAoB;AAC/D,UAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAA,cAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild } from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport { addOTelCommonJSImportAlias, findDefaultSdkInitFile, getNitroMajorVersion } from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion(nuxt.options.rootDir)) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n if (serverConfigFile) {\n if (moduleOptions._experimental?.useDiagnosticsChannelInjection) {\n setupOrchestrion(nuxt);\n }\n\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n }\n\n if (serverConfigFile?.includes('.server.config')) {\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt dev\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,MAAM,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM;AACpC,IAAA,IAAI,kBAAA,EAAoB,YAAY,KAAA,EAAO;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,GAAG,kBAAA;AAAA,MACH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA,MAC3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,iBAAA,GAAoB,cAAA,CAAe,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACxD,IAAA,MAAM,gBAAA,GAAmB,cAAA,CAAe,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAE7D,IAAA,MAAM,gBAAA,GAAmB,MAAM,sBAAA,CAAuB,QAAA,EAAU,MAAM,aAAa,CAAA;AAEnF,IAAA,IAAI,gBAAA,EAAkB;AAEpB,MAAA,iBAAA,CAAkB;AAAA,QAChB,IAAA,EAAM,QAAA;AAAA,QACN,QAAA,EAAU,0BAAA;AAAA,QACV,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA,QAIP,aAAa,MAAM;AAAA;;AAAA;AAAA;AAAA;AAAA,4BAAA,EAMG,gBAAA,CAAiB,OAAA,CAAQ,CAA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AErB,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,oHAAoH,wBAAwB,CAAA,mJAAA;AAAA,iBAC9I;AAAA,cACF,CAAA,MAAO;AAEL,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,CAAA,sGAAA,EAAyG,wBAAwB,CAAA,mEAAA,EAAsE,wBAAwB,CAAA,gBAAA;AAAA,iBACjO;AAAA,cACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,kBAAA,EAAoB;AAC/D,UAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAA,cAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.74.0"}
1
+ {"type":"module","version":"10.75.1"}
@@ -4,17 +4,23 @@ import * as path from 'path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { resolvePath } from '@nuxt/kit';
6
6
 
7
- async function getNitroMajorVersion() {
7
+ async function getNitroMajorVersion(rootDir) {
8
8
  try {
9
9
  const { getPackageInfo } = await import('local-pkg');
10
- const info = await getPackageInfo("nitro");
11
- if (info?.version) {
12
- const major = parseInt(info.version.split(".")[0] ?? "2", 10);
13
- return isNaN(major) ? 2 : major;
10
+ const fromPackage = (dir) => ({ paths: [path.join(dir, "package.json")] });
11
+ let provider = await getPackageInfo("nuxt", fromPackage(rootDir));
12
+ if (provider?.packageJson.dependencies?.["@nuxt/nitro-server"]) {
13
+ provider = await getPackageInfo("@nuxt/nitro-server", fromPackage(provider.rootPath)) ?? provider;
14
14
  }
15
+ if (!provider?.packageJson.dependencies?.nitro) {
16
+ return 2;
17
+ }
18
+ const info = await getPackageInfo("nitro", fromPackage(provider.rootPath));
19
+ const major = parseInt(info?.version?.split(".")[0] ?? "", 10);
20
+ return isNaN(major) ? 3 : major;
15
21
  } catch {
22
+ return 2;
16
23
  }
17
- return 2;
18
24
  }
19
25
  async function findDefaultSdkInitFile(type, nuxt, options) {
20
26
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'node:url';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the installed nitro package.\n * Returns 2 as the default if nitro is not found or the version cannot be determined.\n */\nexport async function getNitroMajorVersion(): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n const info = await getPackageInfo('nitro');\n if (info?.version) {\n const major = parseInt(info.version.split('.')[0] ?? '2', 10);\n return isNaN(major) ? 2 : major;\n }\n } catch {\n // If local-pkg is unavailable or nitro is not found, default to v2\n }\n return 2;\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n * The sentry.server.config file is prioritized over the instrument.server file.\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths: string[] = [];\n\n if (type === 'server') {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n relativePaths.push(path.join('public', `instrument.${type}.${ext}`));\n }\n } else {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n }\n }\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * Only exported for testing.\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":[],"mappings":";;;;;;AAYA,eAAsB,oBAAA,GAAwC;AAC5D,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AACnD,IAAA,MAAM,IAAA,GAAO,MAAM,cAAA,CAAe,OAAO,CAAA;AACzC,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,IAAK,GAAA,EAAK,EAAE,CAAA;AAC5D,MAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,CAAA,GAAI,KAAA;AAAA,IAC5B;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,CAAA;AACT;AAMA,eAAsB,sBAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EAC6B;AAC7B,EAAA,MAAM,yBAAyB,CAAC,IAAA,EAAM,MAAM,KAAA,EAAO,KAAA,EAAO,OAAO,KAAK,CAAA;AACtE,EAAA,MAAM,gBAA0B,EAAC;AAEjC,EA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;AACjD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,cAAc,MAAM,CAAA;AACrC,IAAA,IAAI,CAAC,QAAA,IAAY,QAAA,KAAa,GAAA,IAAO,aAAa,IAAA,EAAM;AACtD,MAAA,OAAO,KAAA,CAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,IAAA,EAAK;AAAA,EAC5C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAYO,SAAS,0BAAA,CAA2B,IAAA,EAAY,SAAA,GAAY,KAAA,EAAa;AAC9E,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACxB;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,EAAG;AACnD,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,GAAI,6CAAA;AAAA,EACnD;AACF;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'node:url';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the Nitro package used by the app's Nuxt installation.\n * Returns 2 as the default if the version cannot be determined.\n *\n * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is\n * unreliable: module resolution walks up the directory tree, so in a monorepo an\n * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.\n * Instead, follow the dependency chain Nuxt itself imports Nitro through:\n * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.\n */\nexport async function getNitroMajorVersion(rootDir: string): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n\n // `paths` entries must point at a file: for a bare directory, resolution starts at the\n // directory's parent and skips the directory's own `node_modules`, so a hoisted copy higher\n // up the tree (e.g. a monorepo root) wins over the app's actual dependency.\n const fromPackage = (dir: string): { paths: string[] } => ({ paths: [path.join(dir, 'package.json')] });\n\n // The package that declares the Nitro dependency: `nuxt` itself, or `@nuxt/nitro-server` (Nuxt >= 3.21) when nuxt delegates to it\n let provider = await getPackageInfo('nuxt', fromPackage(rootDir));\n if (provider?.packageJson.dependencies?.['@nuxt/nitro-server']) {\n provider = (await getPackageInfo('@nuxt/nitro-server', fromPackage(provider.rootPath))) ?? provider;\n }\n\n if (!provider?.packageJson.dependencies?.nitro) {\n return 2;\n }\n\n const info = await getPackageInfo('nitro', fromPackage(provider.rootPath));\n const major = parseInt(info?.version?.split('.')[0] ?? '', 10);\n // The provider imports `nitro` (not `nitropack`), so it is at least v3 even if the version is unreadable\n return isNaN(major) ? 3 : major;\n } catch {\n // If local-pkg is unavailable or resolution fails, default to v2\n return 2;\n }\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n * The sentry.server.config file is prioritized over the instrument.server file.\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths: string[] = [];\n\n if (type === 'server') {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n relativePaths.push(path.join('public', `instrument.${type}.${ext}`));\n }\n } else {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n }\n }\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * Only exported for testing.\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":[],"mappings":";;;;;;AAkBA,eAAsB,qBAAqB,OAAA,EAAkC;AAC3E,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AAKnD,IAAA,MAAM,WAAA,GAAc,CAAC,GAAA,MAAsC,EAAE,KAAA,EAAO,CAAC,IAAA,CAAK,IAAA,CAAK,GAAA,EAAK,cAAc,CAAC,CAAA,EAAE,CAAA;AAGrG,IAAA,IAAI,WAAW,MAAM,cAAA,CAAe,MAAA,EAAQ,WAAA,CAAY,OAAO,CAAC,CAAA;AAChE,IAAA,IAAI,QAAA,EAAU,WAAA,CAAY,YAAA,GAAe,oBAAoB,CAAA,EAAG;AAC9D,MAAA,QAAA,GAAY,MAAM,cAAA,CAAe,oBAAA,EAAsB,YAAY,QAAA,CAAS,QAAQ,CAAC,CAAA,IAAM,QAAA;AAAA,IAC7F;AAEA,IAAA,IAAI,CAAC,QAAA,EAAU,WAAA,CAAY,YAAA,EAAc,KAAA,EAAO;AAC9C,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,MAAM,OAAO,MAAM,cAAA,CAAe,SAAS,WAAA,CAAY,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzE,IAAA,MAAM,KAAA,GAAQ,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AA,GAAI,6CAAA;AAAA,EACnD;AACF;;;;"}
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.7.0"
6
6
  },
7
- "version": "10.74.0"
7
+ "version": "10.75.1"
8
8
  }
@@ -11,17 +11,23 @@ import { sentryRollupPlugin } from '@sentry/rollup-plugin';
11
11
  import { sentryVitePlugin } from '@sentry/vite-plugin';
12
12
  import { createSentryBuildPluginManager } from '@sentry/bundler-plugin-core';
13
13
 
14
- async function getNitroMajorVersion() {
14
+ async function getNitroMajorVersion(rootDir) {
15
15
  try {
16
16
  const { getPackageInfo } = await import('local-pkg');
17
- const info = await getPackageInfo("nitro");
18
- if (info?.version) {
19
- const major = parseInt(info.version.split(".")[0] ?? "2", 10);
20
- return isNaN(major) ? 2 : major;
17
+ const fromPackage = (dir) => ({ paths: [path.join(dir, "package.json")] });
18
+ let provider = await getPackageInfo("nuxt", fromPackage(rootDir));
19
+ if (provider?.packageJson.dependencies?.["@nuxt/nitro-server"]) {
20
+ provider = await getPackageInfo("@nuxt/nitro-server", fromPackage(provider.rootPath)) ?? provider;
21
21
  }
22
+ if (!provider?.packageJson.dependencies?.nitro) {
23
+ return 2;
24
+ }
25
+ const info = await getPackageInfo("nitro", fromPackage(provider.rootPath));
26
+ const major = parseInt(info?.version?.split(".")[0] ?? "", 10);
27
+ return isNaN(major) ? 3 : major;
22
28
  } catch {
29
+ return 2;
23
30
  }
24
- return 2;
25
31
  }
26
32
  async function findDefaultSdkInitFile(type, nuxt, options) {
27
33
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
@@ -788,7 +794,7 @@ var module$1 = defineNuxtModule({
788
794
  });
789
795
  }
790
796
  const serverConfigFile = await findDefaultSdkInitFile("server", nuxt, moduleOptions);
791
- const isNitroV3 = await getNitroMajorVersion() >= 3;
797
+ const isNitroV3 = await getNitroMajorVersion(nuxt.options.rootDir) >= 3;
792
798
  const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
793
799
  const isMinNuxtV4 = nuxtMajor >= 4;
794
800
  if (serverConfigFile) {
@@ -1,10 +1,16 @@
1
1
  import type { Nuxt } from '@nuxt/schema';
2
2
  import type { SentryNuxtModuleOptions } from '../common/types';
3
3
  /**
4
- * Gets the major version of the installed nitro package.
5
- * Returns 2 as the default if nitro is not found or the version cannot be determined.
4
+ * Gets the major version of the Nitro package used by the app's Nuxt installation.
5
+ * Returns 2 as the default if the version cannot be determined.
6
+ *
7
+ * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is
8
+ * unreliable: module resolution walks up the directory tree, so in a monorepo an
9
+ * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.
10
+ * Instead, follow the dependency chain Nuxt itself imports Nitro through:
11
+ * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.
6
12
  */
7
- export declare function getNitroMajorVersion(): Promise<number>;
13
+ export declare function getNitroMajorVersion(rootDir: string): Promise<number>;
8
14
  /**
9
15
  * Find the default SDK init file for the given type (client or server).
10
16
  * The sentry.server.config file is prioritized over the instrument.server file.
@@ -1,10 +1,16 @@
1
1
  import type { Nuxt } from '@nuxt/schema';
2
2
  import type { SentryNuxtModuleOptions } from '../common/types';
3
3
  /**
4
- * Gets the major version of the installed nitro package.
5
- * Returns 2 as the default if nitro is not found or the version cannot be determined.
4
+ * Gets the major version of the Nitro package used by the app's Nuxt installation.
5
+ * Returns 2 as the default if the version cannot be determined.
6
+ *
7
+ * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is
8
+ * unreliable: module resolution walks up the directory tree, so in a monorepo an
9
+ * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.
10
+ * Instead, follow the dependency chain Nuxt itself imports Nitro through:
11
+ * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.
6
12
  */
7
- export declare function getNitroMajorVersion(): Promise<number>;
13
+ export declare function getNitroMajorVersion(rootDir: string): Promise<number>;
8
14
  /**
9
15
  * Find the default SDK init file for the given type (client or server).
10
16
  * The sentry.server.config file is prioritized over the instrument.server file.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/vite/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG/D;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAY5D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,IAAI,CAAC,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqC7B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlF;AAED,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAClE,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAC3E,eAAO,MAAM,2BAA2B,wCAAwC,CAAC;AACjF,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA2B5G;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,EACjD,0BAA0B,EAAE,MAAM,EAAE,EACpC,KAAK,CAAC,EAAE,OAAO,GACd,MAAM,CAmC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AAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA2B5G;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,EACjD,0BAA0B,EAAE,MAAM,EAAE,EACpC,KAAK,CAAC,EAAE,OAAO,GACd,MAAM,CAmCR;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBxF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAgBlG;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,UAAQ,GAAG,IAAI,CAY9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/nuxt",
3
- "version": "10.74.0",
3
+ "version": "10.75.1",
4
4
  "description": "Official Sentry SDK for Nuxt",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
@@ -54,16 +54,16 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@nuxt/kit": "^3.13.2",
57
- "@sentry/browser": "10.74.0",
57
+ "@sentry/browser": "10.75.1",
58
58
  "@sentry/bundler-plugin-core": "^5.3.0",
59
- "@sentry/cloudflare": "10.74.0",
60
- "@sentry/core": "10.74.0",
61
- "@sentry/node": "10.74.0",
62
- "@sentry/node-core": "10.74.0",
59
+ "@sentry/cloudflare": "10.75.1",
60
+ "@sentry/core": "10.75.1",
61
+ "@sentry/node": "10.75.1",
62
+ "@sentry/node-core": "10.75.1",
63
63
  "@sentry/rollup-plugin": "^5.3.0",
64
- "@sentry/server-utils": "10.74.0",
64
+ "@sentry/server-utils": "10.75.1",
65
65
  "@sentry/vite-plugin": "^5.3.0",
66
- "@sentry/vue": "10.74.0",
66
+ "@sentry/vue": "10.75.1",
67
67
  "local-pkg": "^1.1.2"
68
68
  },
69
69
  "devDependencies": {