@sentry/nuxt 10.53.1 → 10.55.0
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.
- package/build/cjs/client/piniaIntegration.js +7 -19
- package/build/cjs/client/piniaIntegration.js.map +1 -1
- package/build/cjs/client/sdk.js +2 -9
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/vueIntegration.js +3 -10
- package/build/cjs/client/vueIntegration.js.map +1 -1
- package/build/cjs/common/debug-build.js +0 -5
- package/build/cjs/common/debug-build.js.map +1 -1
- package/build/cjs/module.js +52 -107
- package/build/cjs/module.js.map +1 -1
- package/build/cjs/server/sdk.js +20 -60
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/vendor/server-template.js +0 -6
- package/build/cjs/vendor/server-template.js.map +1 -1
- package/build/cjs/vite/addServerConfig.js +45 -144
- package/build/cjs/vite/addServerConfig.js.map +1 -1
- package/build/cjs/vite/databaseConfig.js +10 -32
- package/build/cjs/vite/databaseConfig.js.map +1 -1
- package/build/cjs/vite/middlewareConfig.js +11 -46
- package/build/cjs/vite/middlewareConfig.js.map +1 -1
- package/build/cjs/vite/sentryVitePlugin.js +7 -24
- package/build/cjs/vite/sentryVitePlugin.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +89 -248
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/cjs/vite/storageConfig.js +4 -10
- package/build/cjs/vite/storageConfig.js.map +1 -1
- package/build/cjs/vite/utils.js +51 -143
- package/build/cjs/vite/utils.js.map +1 -1
- package/build/esm/client/piniaIntegration.js +7 -19
- package/build/esm/client/piniaIntegration.js.map +1 -1
- package/build/esm/client/sdk.js +2 -9
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/vueIntegration.js +3 -10
- package/build/esm/client/vueIntegration.js.map +1 -1
- package/build/esm/common/debug-build.js +0 -5
- package/build/esm/common/debug-build.js.map +1 -1
- package/build/esm/module.js +52 -107
- package/build/esm/module.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/sdk.js +20 -60
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/vendor/server-template.js +0 -6
- package/build/esm/vendor/server-template.js.map +1 -1
- package/build/esm/vite/addServerConfig.js +45 -144
- package/build/esm/vite/addServerConfig.js.map +1 -1
- package/build/esm/vite/databaseConfig.js +10 -32
- package/build/esm/vite/databaseConfig.js.map +1 -1
- package/build/esm/vite/middlewareConfig.js +11 -46
- package/build/esm/vite/middlewareConfig.js.map +1 -1
- package/build/esm/vite/sentryVitePlugin.js +7 -24
- package/build/esm/vite/sentryVitePlugin.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +89 -248
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/esm/vite/storageConfig.js +4 -10
- package/build/esm/vite/storageConfig.js.map +1 -1
- package/build/esm/vite/utils.js +51 -143
- package/build/esm/vite/utils.js.map +1 -1
- package/build/module/module.d.mts +17 -0
- package/build/module/module.d.ts +17 -0
- package/build/module/module.json +1 -1
- package/build/module/module.mjs +6 -6
- package/build/types/common/types.d.ts +17 -0
- package/build/types/common/types.d.ts.map +1 -1
- package/build/types/vite/utils.d.ts +2 -1
- package/build/types/vite/utils.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -5,48 +5,26 @@ const core = require('@sentry/core');
|
|
|
5
5
|
const serverTemplate = require('../vendor/server-template.js');
|
|
6
6
|
|
|
7
7
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
|
-
|
|
9
|
-
* Sets up the database instrumentation.
|
|
10
|
-
*/
|
|
11
|
-
function addDatabaseInstrumentation(
|
|
12
|
-
nitro,
|
|
13
|
-
isLegacyNitro,
|
|
14
|
-
moduleOptions,
|
|
15
|
-
) {
|
|
8
|
+
function addDatabaseInstrumentation(nitro, isLegacyNitro, moduleOptions) {
|
|
16
9
|
if (!nitro.experimental?.database) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.log(
|
|
23
|
-
'[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
10
|
+
moduleOptions?.debug && core.consoleSandbox(() => {
|
|
11
|
+
console.log(
|
|
12
|
+
"[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation."
|
|
13
|
+
);
|
|
14
|
+
});
|
|
27
15
|
return;
|
|
28
16
|
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This is a different option than the one in `experimental.database`, this configures multiple database instances.
|
|
32
|
-
* keys represent database names to be passed to `useDatabase(name?)`.
|
|
33
|
-
* We also use the config to populate database span attributes.
|
|
34
|
-
* https://nitro.build/guide/database#configuration
|
|
35
|
-
*/
|
|
36
17
|
const databaseConfig = nitro.database || { default: {} };
|
|
37
|
-
|
|
38
|
-
// Create a virtual module to pass this data to runtime
|
|
39
18
|
serverTemplate.addServerTemplate({
|
|
40
|
-
filename:
|
|
19
|
+
filename: "#sentry/database-config.mjs",
|
|
41
20
|
getContents: () => {
|
|
42
21
|
return `export const databaseConfig = ${JSON.stringify(databaseConfig)};`;
|
|
43
|
-
}
|
|
22
|
+
}
|
|
44
23
|
});
|
|
45
|
-
|
|
46
24
|
if (isLegacyNitro) {
|
|
47
|
-
kit.addServerPlugin(kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/databaseConfig.js', document.baseURI).href))).resolve(
|
|
25
|
+
kit.addServerPlugin(kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/databaseConfig.js', document.baseURI).href))).resolve("./runtime/plugins/database-legacy.server"));
|
|
48
26
|
} else {
|
|
49
|
-
kit.addServerPlugin(kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/databaseConfig.js', document.baseURI).href))).resolve(
|
|
27
|
+
kit.addServerPlugin(kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/databaseConfig.js', document.baseURI).href))).resolve("./runtime/plugins/database.server"));
|
|
50
28
|
}
|
|
51
29
|
}
|
|
52
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databaseConfig.js","sources":["../../../src/vite/databaseConfig.ts"],"sourcesContent":["import { addServerPlugin, createResolver } from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport type { NitroConfig } from 'nitropack/types';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { addServerTemplate } from '../vendor/server-template';\n\n/**\n * Sets up the database instrumentation.\n */\nexport function addDatabaseInstrumentation(\n nitro: NitroConfig,\n isLegacyNitro: boolean,\n moduleOptions?: SentryNuxtModuleOptions,\n): void {\n if (!nitro.experimental?.database) {\n // We cannot use DEBUG_BUILD here because it is a runtime flag, so it is not available for build time scripts\n // So we have to pass in the module options to the build time script\n moduleOptions?.debug &&\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',\n );\n });\n\n return;\n }\n\n /**\n * This is a different option than the one in `experimental.database`, this configures multiple database instances.\n * keys represent database names to be passed to `useDatabase(name?)`.\n * We also use the config to populate database span attributes.\n * https://nitro.build/guide/database#configuration\n */\n const databaseConfig = nitro.database || { default: {} };\n\n // Create a virtual module to pass this data to runtime\n addServerTemplate({\n filename: '#sentry/database-config.mjs',\n getContents: () => {\n return `export const databaseConfig = ${JSON.stringify(databaseConfig)};`;\n },\n });\n\n if (isLegacyNitro) {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database-legacy.server'));\n } else {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database.server'));\n }\n}\n"],"names":["consoleSandbox","addServerTemplate","addServerPlugin","createResolver"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"databaseConfig.js","sources":["../../../src/vite/databaseConfig.ts"],"sourcesContent":["import { addServerPlugin, createResolver } from '@nuxt/kit';\nimport { consoleSandbox } from '@sentry/core';\nimport type { NitroConfig } from 'nitropack/types';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { addServerTemplate } from '../vendor/server-template';\n\n/**\n * Sets up the database instrumentation.\n */\nexport function addDatabaseInstrumentation(\n nitro: NitroConfig,\n isLegacyNitro: boolean,\n moduleOptions?: SentryNuxtModuleOptions,\n): void {\n if (!nitro.experimental?.database) {\n // We cannot use DEBUG_BUILD here because it is a runtime flag, so it is not available for build time scripts\n // So we have to pass in the module options to the build time script\n moduleOptions?.debug &&\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',\n );\n });\n\n return;\n }\n\n /**\n * This is a different option than the one in `experimental.database`, this configures multiple database instances.\n * keys represent database names to be passed to `useDatabase(name?)`.\n * We also use the config to populate database span attributes.\n * https://nitro.build/guide/database#configuration\n */\n const databaseConfig = nitro.database || { default: {} };\n\n // Create a virtual module to pass this data to runtime\n addServerTemplate({\n filename: '#sentry/database-config.mjs',\n getContents: () => {\n return `export const databaseConfig = ${JSON.stringify(databaseConfig)};`;\n },\n });\n\n if (isLegacyNitro) {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database-legacy.server'));\n } else {\n addServerPlugin(createResolver(import.meta.url).resolve('./runtime/plugins/database.server'));\n }\n}\n"],"names":["consoleSandbox","addServerTemplate","addServerPlugin","createResolver"],"mappings":";;;;;;;AASO,SAAS,0BAAA,CACd,KAAA,EACA,aAAA,EACA,aAAA,EACM;AACN,EAAA,IAAI,CAAC,KAAA,CAAM,YAAA,EAAc,QAAA,EAAU;AAGjC,IAAA,aAAA,EAAe,KAAA,IACbA,oBAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,GAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAEH,IAAA;AAAA,EACF;AAQA,EAAA,MAAM,iBAAiB,KAAA,CAAM,QAAA,IAAY,EAAE,OAAA,EAAS,EAAC,EAAE;AAGvD,EAAAC,gCAAA,CAAkB;AAAA,IAChB,QAAA,EAAU,6BAAA;AAAA,IACV,aAAa,MAAM;AACjB,MAAA,OAAO,CAAA,8BAAA,EAAiC,IAAA,CAAK,SAAA,CAAU,cAAc,CAAC,CAAA,CAAA,CAAA;AAAA,IACxE;AAAA,GACD,CAAA;AAED,EAAA,IAAI,aAAA,EAAe;AACjB,IAAAC,mBAAA,CAAgBC,mBAAe,wQAAe,CAAA,CAAE,OAAA,CAAQ,0CAA0C,CAAC,CAAA;AAAA,EACrG,CAAA,MAAO;AACL,IAAAD,mBAAA,CAAgBC,mBAAe,wQAAe,CAAA,CAAE,OAAA,CAAQ,mCAAmC,CAAC,CAAA;AAAA,EAC9F;AACF;;;;"}
|
|
@@ -4,50 +4,30 @@ const kit = require('@nuxt/kit');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
-
/**
|
|
8
|
-
* Adds a server import for the middleware instrumentation.
|
|
9
|
-
*/
|
|
10
7
|
function addMiddlewareImports() {
|
|
11
8
|
kit.addServerImports([
|
|
12
9
|
{
|
|
13
|
-
name:
|
|
14
|
-
from: kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/middlewareConfig.js', document.baseURI).href))).resolve(
|
|
15
|
-
}
|
|
10
|
+
name: "wrapMiddlewareHandlerWithSentry",
|
|
11
|
+
from: kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/middlewareConfig.js', document.baseURI).href))).resolve("./runtime/hooks/wrapMiddlewareHandler")
|
|
12
|
+
}
|
|
16
13
|
]);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Adds middleware instrumentation to the Nitro build.
|
|
21
|
-
*
|
|
22
|
-
* @param nitro Nitro instance
|
|
23
|
-
*/
|
|
24
15
|
function addMiddlewareInstrumentation(nitro) {
|
|
25
|
-
nitro.hooks.hook(
|
|
16
|
+
nitro.hooks.hook("rollup:before", (nitro2, rollupConfig) => {
|
|
26
17
|
if (!rollupConfig.plugins) {
|
|
27
18
|
rollupConfig.plugins = [];
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
if (!Array.isArray(rollupConfig.plugins)) {
|
|
31
21
|
rollupConfig.plugins = [rollupConfig.plugins];
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
rollupConfig.plugins.push(middlewareInstrumentationPlugin(nitro));
|
|
23
|
+
rollupConfig.plugins.push(middlewareInstrumentationPlugin(nitro2));
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creates a rollup plugin for the middleware instrumentation by transforming the middleware code.
|
|
40
|
-
*
|
|
41
|
-
* @param nitro Nitro instance
|
|
42
|
-
* @returns The rollup plugin for the middleware instrumentation.
|
|
43
|
-
*/
|
|
44
26
|
function middlewareInstrumentationPlugin(nitro) {
|
|
45
|
-
const middlewareFiles = new Set();
|
|
46
|
-
|
|
27
|
+
const middlewareFiles = /* @__PURE__ */ new Set();
|
|
47
28
|
return {
|
|
48
|
-
name:
|
|
29
|
+
name: "sentry-nuxt-middleware-instrumentation",
|
|
49
30
|
buildStart() {
|
|
50
|
-
// Collect middleware files during build start
|
|
51
31
|
nitro.scannedHandlers?.forEach(({ middleware, handler }) => {
|
|
52
32
|
if (middleware && handler) {
|
|
53
33
|
middlewareFiles.add(handler);
|
|
@@ -55,31 +35,19 @@ function middlewareInstrumentationPlugin(nitro) {
|
|
|
55
35
|
});
|
|
56
36
|
},
|
|
57
37
|
transform(code, id) {
|
|
58
|
-
// Only transform files we've identified as middleware
|
|
59
38
|
if (middlewareFiles.has(id)) {
|
|
60
39
|
const fileName = path.basename(id);
|
|
61
40
|
return {
|
|
62
41
|
code: wrapMiddlewareCode(code, fileName),
|
|
63
|
-
map: null
|
|
42
|
+
map: null
|
|
64
43
|
};
|
|
65
44
|
}
|
|
66
45
|
return null;
|
|
67
|
-
}
|
|
46
|
+
}
|
|
68
47
|
};
|
|
69
48
|
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Wraps the middleware user code to instrument it.
|
|
73
|
-
*
|
|
74
|
-
* @param originalCode The original user code of the middleware.
|
|
75
|
-
* @param fileName The name of the middleware file, used for the span name and logging.
|
|
76
|
-
*
|
|
77
|
-
* @returns The wrapped user code of the middleware.
|
|
78
|
-
*/
|
|
79
49
|
function wrapMiddlewareCode(originalCode, fileName) {
|
|
80
|
-
|
|
81
|
-
const cleanFileName = fileName.replace(/\.(ts|js|mjs|mts|cts)$/, '');
|
|
82
|
-
|
|
50
|
+
const cleanFileName = fileName.replace(/\.(ts|js|mjs|mts|cts)$/, "");
|
|
83
51
|
return `
|
|
84
52
|
import { wrapMiddlewareHandlerWithSentry } from '#imports';
|
|
85
53
|
|
|
@@ -95,10 +63,7 @@ function defineInstrumentedHandler(handlerOrObject) {
|
|
|
95
63
|
return defineHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));
|
|
96
64
|
}
|
|
97
65
|
|
|
98
|
-
${originalCode
|
|
99
|
-
.replace(/defineEventHandler\(/g, 'defineInstrumentedEventHandler(')
|
|
100
|
-
.replace(/eventHandler\(/g, 'instrumentedEventHandler(')
|
|
101
|
-
.replace(/defineHandler\(/g, 'defineInstrumentedHandler(')}
|
|
66
|
+
${originalCode.replace(/defineEventHandler\(/g, "defineInstrumentedEventHandler(").replace(/eventHandler\(/g, "instrumentedEventHandler(").replace(/defineHandler\(/g, "defineInstrumentedHandler(")}
|
|
102
67
|
`;
|
|
103
68
|
}
|
|
104
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewareConfig.js","sources":["../../../src/vite/middlewareConfig.ts"],"sourcesContent":["import { addServerImports, createResolver } from '@nuxt/kit';\nimport type { Nitro } from 'nitropack/types';\nimport * as path from 'path';\nimport type { InputPluginOption } from 'rollup';\n\n/**\n * Adds a server import for the middleware instrumentation.\n */\nexport function addMiddlewareImports(): void {\n addServerImports([\n {\n name: 'wrapMiddlewareHandlerWithSentry',\n from: createResolver(import.meta.url).resolve('./runtime/hooks/wrapMiddlewareHandler'),\n },\n ]);\n}\n\n/**\n * Adds middleware instrumentation to the Nitro build.\n *\n * @param nitro Nitro instance\n */\nexport function addMiddlewareInstrumentation(nitro: Nitro): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (!rollupConfig.plugins) {\n rollupConfig.plugins = [];\n }\n\n if (!Array.isArray(rollupConfig.plugins)) {\n rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(middlewareInstrumentationPlugin(nitro));\n });\n}\n\n/**\n * Creates a rollup plugin for the middleware instrumentation by transforming the middleware code.\n *\n * @param nitro Nitro instance\n * @returns The rollup plugin for the middleware instrumentation.\n */\nfunction middlewareInstrumentationPlugin(nitro: Nitro): InputPluginOption {\n const middlewareFiles = new Set<string>();\n\n return {\n name: 'sentry-nuxt-middleware-instrumentation',\n buildStart() {\n // Collect middleware files during build start\n nitro.scannedHandlers?.forEach(({ middleware, handler }) => {\n if (middleware && handler) {\n middlewareFiles.add(handler);\n }\n });\n },\n transform(code: string, id: string) {\n // Only transform files we've identified as middleware\n if (middlewareFiles.has(id)) {\n const fileName = path.basename(id);\n return {\n code: wrapMiddlewareCode(code, fileName),\n map: null,\n };\n }\n return null;\n },\n };\n}\n\n/**\n * Wraps the middleware user code to instrument it.\n *\n * @param originalCode The original user code of the middleware.\n * @param fileName The name of the middleware file, used for the span name and logging.\n *\n * @returns The wrapped user code of the middleware.\n */\nfunction wrapMiddlewareCode(originalCode: string, fileName: string): string {\n // Remove common file extensions\n const cleanFileName = fileName.replace(/\\.(ts|js|mjs|mts|cts)$/, '');\n\n return `\nimport { wrapMiddlewareHandlerWithSentry } from '#imports';\n\nfunction defineInstrumentedEventHandler(handlerOrObject) {\n return defineEventHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\nfunction instrumentedEventHandler(handlerOrObject) {\n return eventHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\nfunction defineInstrumentedHandler(handlerOrObject) {\n return defineHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\n${originalCode\n .replace(/defineEventHandler\\(/g, 'defineInstrumentedEventHandler(')\n .replace(/eventHandler\\(/g, 'instrumentedEventHandler(')\n .replace(/defineHandler\\(/g, 'defineInstrumentedHandler(')}\n`;\n}\n"],"names":["addServerImports","createResolver"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"middlewareConfig.js","sources":["../../../src/vite/middlewareConfig.ts"],"sourcesContent":["import { addServerImports, createResolver } from '@nuxt/kit';\nimport type { Nitro } from 'nitropack/types';\nimport * as path from 'path';\nimport type { InputPluginOption } from 'rollup';\n\n/**\n * Adds a server import for the middleware instrumentation.\n */\nexport function addMiddlewareImports(): void {\n addServerImports([\n {\n name: 'wrapMiddlewareHandlerWithSentry',\n from: createResolver(import.meta.url).resolve('./runtime/hooks/wrapMiddlewareHandler'),\n },\n ]);\n}\n\n/**\n * Adds middleware instrumentation to the Nitro build.\n *\n * @param nitro Nitro instance\n */\nexport function addMiddlewareInstrumentation(nitro: Nitro): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (!rollupConfig.plugins) {\n rollupConfig.plugins = [];\n }\n\n if (!Array.isArray(rollupConfig.plugins)) {\n rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(middlewareInstrumentationPlugin(nitro));\n });\n}\n\n/**\n * Creates a rollup plugin for the middleware instrumentation by transforming the middleware code.\n *\n * @param nitro Nitro instance\n * @returns The rollup plugin for the middleware instrumentation.\n */\nfunction middlewareInstrumentationPlugin(nitro: Nitro): InputPluginOption {\n const middlewareFiles = new Set<string>();\n\n return {\n name: 'sentry-nuxt-middleware-instrumentation',\n buildStart() {\n // Collect middleware files during build start\n nitro.scannedHandlers?.forEach(({ middleware, handler }) => {\n if (middleware && handler) {\n middlewareFiles.add(handler);\n }\n });\n },\n transform(code: string, id: string) {\n // Only transform files we've identified as middleware\n if (middlewareFiles.has(id)) {\n const fileName = path.basename(id);\n return {\n code: wrapMiddlewareCode(code, fileName),\n map: null,\n };\n }\n return null;\n },\n };\n}\n\n/**\n * Wraps the middleware user code to instrument it.\n *\n * @param originalCode The original user code of the middleware.\n * @param fileName The name of the middleware file, used for the span name and logging.\n *\n * @returns The wrapped user code of the middleware.\n */\nfunction wrapMiddlewareCode(originalCode: string, fileName: string): string {\n // Remove common file extensions\n const cleanFileName = fileName.replace(/\\.(ts|js|mjs|mts|cts)$/, '');\n\n return `\nimport { wrapMiddlewareHandlerWithSentry } from '#imports';\n\nfunction defineInstrumentedEventHandler(handlerOrObject) {\n return defineEventHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\nfunction instrumentedEventHandler(handlerOrObject) {\n return eventHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\nfunction defineInstrumentedHandler(handlerOrObject) {\n return defineHandler(wrapMiddlewareHandlerWithSentry(handlerOrObject, '${cleanFileName}'));\n}\n\n${originalCode\n .replace(/defineEventHandler\\(/g, 'defineInstrumentedEventHandler(')\n .replace(/eventHandler\\(/g, 'instrumentedEventHandler(')\n .replace(/defineHandler\\(/g, 'defineInstrumentedHandler(')}\n`;\n}\n"],"names":["addServerImports","createResolver","nitro"],"mappings":";;;;;;AAQO,SAAS,oBAAA,GAA6B;AAC3C,EAAAA,oBAAA,CAAiB;AAAA,IACf;AAAA,MACE,IAAA,EAAM,iCAAA;AAAA,MACN,MAAMC,kBAAA,CAAe,0QAAe,CAAA,CAAE,QAAQ,uCAAuC;AAAA;AACvF,GACD,CAAA;AACH;AAOO,SAAS,6BAA6B,KAAA,EAAoB;AAC/D,EAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,eAAA,EAAiB,CAACC,QAAO,YAAA,KAAiB;AACzD,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AACzB,MAAA,YAAA,CAAa,UAAU,EAAC;AAAA,IAC1B;AAEA,IAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,YAAA,CAAa,OAAO,CAAA,EAAG;AACxC,MAAA,YAAA,CAAa,OAAA,GAAU,CAAC,YAAA,CAAa,OAAO,CAAA;AAAA,IAC9C;AAEA,IAAA,YAAA,CAAa,OAAA,CAAQ,IAAA,CAAK,+BAAA,CAAgCA,MAAK,CAAC,CAAA;AAAA,EAClE,CAAC,CAAA;AACH;AAQA,SAAS,gCAAgC,KAAA,EAAiC;AACxE,EAAA,MAAM,eAAA,uBAAsB,GAAA,EAAY;AAExC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,wCAAA;AAAA,IACN,UAAA,GAAa;AAEX,MAAA,KAAA,CAAM,iBAAiB,OAAA,CAAQ,CAAC,EAAE,UAAA,EAAY,SAAQ,KAAM;AAC1D,QAAA,IAAI,cAAc,OAAA,EAAS;AACzB,UAAA,eAAA,CAAgB,IAAI,OAAO,CAAA;AAAA,QAC7B;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IACA,SAAA,CAAU,MAAc,EAAA,EAAY;AAElC,MAAA,IAAI,eAAA,CAAgB,GAAA,CAAI,EAAE,CAAA,EAAG;AAC3B,QAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,EAAE,CAAA;AACjC,QAAA,OAAO;AAAA,UACL,IAAA,EAAM,kBAAA,CAAmB,IAAA,EAAM,QAAQ,CAAA;AAAA,UACvC,GAAA,EAAK;AAAA,SACP;AAAA,MACF;AACA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF;AAUA,SAAS,kBAAA,CAAmB,cAAsB,QAAA,EAA0B;AAE1E,EAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,OAAA,CAAQ,wBAAA,EAA0B,EAAE,CAAA;AAEnE,EAAA,OAAO;AAAA;;AAAA;AAAA,8EAAA,EAIuE,aAAa,CAAA;AAAA;;AAAA;AAAA,wEAAA,EAInB,aAAa,CAAA;AAAA;;AAAA;AAAA,yEAAA,EAIZ,aAAa,CAAA;AAAA;;AAAA,EAGtF,YAAA,CACC,OAAA,CAAQ,uBAAA,EAAyB,iCAAiC,CAAA,CAClE,OAAA,CAAQ,iBAAA,EAAmB,2BAA2B,CAAA,CACtD,OAAA,CAAQ,kBAAA,EAAoB,4BAA4B,CAAC;AAAA,CAAA;AAE5D;;;;;"}
|
|
@@ -2,46 +2,29 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const sourceMaps = require('./sourceMaps.js');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Creates a Vite plugin that adds the Sentry Vite plugin and validates source map settings.
|
|
7
|
-
*/
|
|
8
|
-
function validateSourceMapsOptionsPlugin(options
|
|
9
|
-
|
|
10
|
-
) {
|
|
5
|
+
function validateSourceMapsOptionsPlugin(options) {
|
|
11
6
|
const { nuxt, moduleOptions, sourceMapsEnabled } = options;
|
|
12
7
|
const isDebug = moduleOptions.debug;
|
|
13
|
-
|
|
14
8
|
return {
|
|
15
|
-
name:
|
|
9
|
+
name: "sentry-nuxt-source-map-validation",
|
|
16
10
|
config(viteConfig, env) {
|
|
17
|
-
|
|
18
|
-
if (!sourceMapsEnabled || env.mode === 'development' || nuxt.options?._prepare) {
|
|
11
|
+
if (!sourceMapsEnabled || env.mode === "development" || nuxt.options?._prepare) {
|
|
19
12
|
return;
|
|
20
13
|
}
|
|
21
|
-
|
|
22
|
-
// Detect runtime from Vite config
|
|
23
|
-
// In Nuxt, SSR builds have build.ssr: true, client builds don't
|
|
24
|
-
const runtime = viteConfig.build?.ssr ? 'server' : 'client';
|
|
25
|
-
|
|
14
|
+
const runtime = viteConfig.build?.ssr ? "server" : "client";
|
|
26
15
|
const nuxtSourceMapSetting = sourceMaps.extractNuxtSourceMapSetting(nuxt, runtime);
|
|
27
|
-
|
|
28
|
-
// Initialize build config if needed
|
|
29
16
|
viteConfig.build = viteConfig.build || {};
|
|
30
17
|
const viteSourceMap = viteConfig.build.sourcemap;
|
|
31
|
-
|
|
32
18
|
if (isDebug) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
19
|
console.log(`[Sentry] Validating Vite config for the ${runtime} runtime.`);
|
|
35
20
|
}
|
|
36
|
-
|
|
37
|
-
// Vite source map options are the same as the Nuxt source map config options (unless overwritten)
|
|
38
21
|
sourceMaps.validateDifferentSourceMapSettings({
|
|
39
22
|
nuxtSettingKey: `sourcemap.${runtime}`,
|
|
40
23
|
nuxtSettingValue: nuxtSourceMapSetting,
|
|
41
|
-
otherSettingKey:
|
|
42
|
-
otherSettingValue: viteSourceMap
|
|
24
|
+
otherSettingKey: "viteConfig.build.sourcemap",
|
|
25
|
+
otherSettingValue: viteSourceMap
|
|
43
26
|
});
|
|
44
|
-
}
|
|
27
|
+
}
|
|
45
28
|
};
|
|
46
29
|
}
|
|
47
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentryVitePlugin.js","sources":["../../../src/vite/sentryVitePlugin.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport type { ConfigEnv, Plugin, UserConfig } from 'vite';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { extractNuxtSourceMapSetting, validateDifferentSourceMapSettings } from './sourceMaps';\n\n/**\n * Creates a Vite plugin that adds the Sentry Vite plugin and validates source map settings.\n */\nexport function validateSourceMapsOptionsPlugin(options: {\n nuxt: Nuxt;\n moduleOptions: SentryNuxtModuleOptions;\n sourceMapsEnabled: boolean;\n}): Plugin {\n const { nuxt, moduleOptions, sourceMapsEnabled } = options;\n const isDebug = moduleOptions.debug;\n\n return {\n name: 'sentry-nuxt-source-map-validation',\n config(viteConfig: UserConfig, env: ConfigEnv) {\n // Only run in production builds\n if (!sourceMapsEnabled || env.mode === 'development' || nuxt.options?._prepare) {\n return;\n }\n\n // Detect runtime from Vite config\n // In Nuxt, SSR builds have build.ssr: true, client builds don't\n const runtime = viteConfig.build?.ssr ? 'server' : 'client';\n\n const nuxtSourceMapSetting = extractNuxtSourceMapSetting(nuxt, runtime);\n\n // Initialize build config if needed\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Validating Vite config for the ${runtime} runtime.`);\n }\n\n // Vite source map options are the same as the Nuxt source map config options (unless overwritten)\n validateDifferentSourceMapSettings({\n nuxtSettingKey: `sourcemap.${runtime}`,\n nuxtSettingValue: nuxtSourceMapSetting,\n otherSettingKey: 'viteConfig.build.sourcemap',\n otherSettingValue: viteSourceMap,\n });\n },\n };\n}\n"],"names":["extractNuxtSourceMapSetting","validateDifferentSourceMapSettings"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"sentryVitePlugin.js","sources":["../../../src/vite/sentryVitePlugin.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport type { ConfigEnv, Plugin, UserConfig } from 'vite';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { extractNuxtSourceMapSetting, validateDifferentSourceMapSettings } from './sourceMaps';\n\n/**\n * Creates a Vite plugin that adds the Sentry Vite plugin and validates source map settings.\n */\nexport function validateSourceMapsOptionsPlugin(options: {\n nuxt: Nuxt;\n moduleOptions: SentryNuxtModuleOptions;\n sourceMapsEnabled: boolean;\n}): Plugin {\n const { nuxt, moduleOptions, sourceMapsEnabled } = options;\n const isDebug = moduleOptions.debug;\n\n return {\n name: 'sentry-nuxt-source-map-validation',\n config(viteConfig: UserConfig, env: ConfigEnv) {\n // Only run in production builds\n if (!sourceMapsEnabled || env.mode === 'development' || nuxt.options?._prepare) {\n return;\n }\n\n // Detect runtime from Vite config\n // In Nuxt, SSR builds have build.ssr: true, client builds don't\n const runtime = viteConfig.build?.ssr ? 'server' : 'client';\n\n const nuxtSourceMapSetting = extractNuxtSourceMapSetting(nuxt, runtime);\n\n // Initialize build config if needed\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Validating Vite config for the ${runtime} runtime.`);\n }\n\n // Vite source map options are the same as the Nuxt source map config options (unless overwritten)\n validateDifferentSourceMapSettings({\n nuxtSettingKey: `sourcemap.${runtime}`,\n nuxtSettingValue: nuxtSourceMapSetting,\n otherSettingKey: 'viteConfig.build.sourcemap',\n otherSettingValue: viteSourceMap,\n });\n },\n };\n}\n"],"names":["extractNuxtSourceMapSetting","validateDifferentSourceMapSettings"],"mappings":";;;;AAQO,SAAS,gCAAgC,OAAA,EAIrC;AACT,EAAA,MAAM,EAAE,IAAA,EAAM,aAAA,EAAe,iBAAA,EAAkB,GAAI,OAAA;AACnD,EAAA,MAAM,UAAU,aAAA,CAAc,KAAA;AAE9B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,mCAAA;AAAA,IACN,MAAA,CAAO,YAAwB,GAAA,EAAgB;AAE7C,MAAA,IAAI,CAAC,iBAAA,IAAqB,GAAA,CAAI,SAAS,aAAA,IAAiB,IAAA,CAAK,SAAS,QAAA,EAAU;AAC9E,QAAA;AAAA,MACF;AAIA,MAAA,MAAM,OAAA,GAAU,UAAA,CAAW,KAAA,EAAO,GAAA,GAAM,QAAA,GAAW,QAAA;AAEnD,MAAA,MAAM,oBAAA,GAAuBA,sCAAA,CAA4B,IAAA,EAAM,OAAO,CAAA;AAGtE,MAAA,UAAA,CAAW,KAAA,GAAQ,UAAA,CAAW,KAAA,IAAS,EAAC;AACxC,MAAA,MAAM,aAAA,GAAgB,WAAW,KAAA,CAAM,SAAA;AAEvC,MAAA,IAAI,OAAA,EAAS;AAEX,QAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,wCAAA,EAA2C,OAAO,CAAA,SAAA,CAAW,CAAA;AAAA,MAC3E;AAGA,MAAAC,6CAAA,CAAmC;AAAA,QACjC,cAAA,EAAgB,aAAa,OAAO,CAAA,CAAA;AAAA,QACpC,gBAAA,EAAkB,oBAAA;AAAA,QAClB,eAAA,EAAiB,4BAAA;AAAA,QACjB,iBAAA,EAAmB;AAAA,OACpB,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|