@sentry/nuxt 10.53.1 → 10.54.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
package/build/esm/module.js
CHANGED
|
@@ -10,40 +10,34 @@ import { findDefaultSdkInitFile, getNitroMajorVersion, addOTelCommonJSImportAlia
|
|
|
10
10
|
|
|
11
11
|
const module$1 = defineNuxtModule({
|
|
12
12
|
meta: {
|
|
13
|
-
name:
|
|
14
|
-
configKey:
|
|
13
|
+
name: "@sentry/nuxt/module",
|
|
14
|
+
configKey: "sentry",
|
|
15
15
|
compatibility: {
|
|
16
|
-
nuxt:
|
|
17
|
-
}
|
|
16
|
+
nuxt: ">=3.7.0"
|
|
17
|
+
}
|
|
18
18
|
},
|
|
19
19
|
defaults: {},
|
|
20
20
|
async setup(moduleOptionsParam, nuxt) {
|
|
21
21
|
if (moduleOptionsParam?.enabled === false) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
const moduleOptions = {
|
|
26
25
|
...moduleOptionsParam,
|
|
27
26
|
autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,
|
|
28
27
|
experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
]
|
|
28
|
+
"default",
|
|
29
|
+
"handler",
|
|
30
|
+
"server"
|
|
31
|
+
]
|
|
33
32
|
};
|
|
34
|
-
|
|
35
33
|
const moduleDirResolver = createResolver(import.meta.url);
|
|
36
34
|
const buildDirResolver = createResolver(nuxt.options.buildDir);
|
|
37
|
-
|
|
38
|
-
const clientConfigFile = findDefaultSdkInitFile('client', nuxt);
|
|
39
|
-
|
|
35
|
+
const clientConfigFile = await findDefaultSdkInitFile("client", nuxt, moduleOptions);
|
|
40
36
|
if (clientConfigFile) {
|
|
41
|
-
// Inject the client-side Sentry config file with a side effect import
|
|
42
37
|
addPluginTemplate({
|
|
43
|
-
mode:
|
|
44
|
-
filename:
|
|
38
|
+
mode: "client",
|
|
39
|
+
filename: "sentry-client-config.mjs",
|
|
45
40
|
order: 0,
|
|
46
|
-
|
|
47
41
|
// Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)
|
|
48
42
|
// Makes it possible to call useRuntimeConfig() in the user-defined sentry config file
|
|
49
43
|
getContents: () => `
|
|
@@ -54,91 +48,64 @@ const module$1 = defineNuxtModule({
|
|
|
54
48
|
async setup() {
|
|
55
49
|
await import("${buildDirResolver.resolve(`/${clientConfigFile}`)}")
|
|
56
50
|
}
|
|
57
|
-
})
|
|
51
|
+
});`
|
|
58
52
|
});
|
|
59
|
-
|
|
60
|
-
// Add the plugin which loads client integrations etc. -
|
|
61
|
-
// this must run after the sentry-client-config plugin has run, and the client is initialized!
|
|
62
53
|
addPlugin({
|
|
63
|
-
src: moduleDirResolver.resolve(
|
|
64
|
-
mode:
|
|
65
|
-
order: 1
|
|
54
|
+
src: moduleDirResolver.resolve("./runtime/plugins/sentry.client"),
|
|
55
|
+
mode: "client",
|
|
56
|
+
order: 1
|
|
66
57
|
});
|
|
67
58
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const nuxtMajor = parseInt((nuxt )._version?.split('.')[0] ?? '3', 10);
|
|
59
|
+
const serverConfigFile = await findDefaultSdkInitFile("server", nuxt, moduleOptions);
|
|
60
|
+
const isNitroV3 = await getNitroMajorVersion() >= 3;
|
|
61
|
+
const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
|
|
72
62
|
const isMinNuxtV4 = nuxtMajor >= 4;
|
|
73
|
-
|
|
74
63
|
if (serverConfigFile) {
|
|
75
64
|
if (isNitroV3) {
|
|
76
|
-
addServerPlugin(moduleDirResolver.resolve(
|
|
77
|
-
addServerPlugin(moduleDirResolver.resolve(
|
|
65
|
+
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler.server"));
|
|
66
|
+
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/update-route-name.server"));
|
|
78
67
|
} else {
|
|
79
|
-
addServerPlugin(moduleDirResolver.resolve(
|
|
80
|
-
addServerPlugin(moduleDirResolver.resolve(
|
|
68
|
+
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler-legacy.server"));
|
|
69
|
+
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/update-route-name-legacy.server"));
|
|
81
70
|
}
|
|
82
|
-
|
|
83
|
-
addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));
|
|
84
|
-
|
|
71
|
+
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/sentry.server"));
|
|
85
72
|
if (isMinNuxtV4) {
|
|
86
|
-
addPlugin({ src: moduleDirResolver.resolve(
|
|
73
|
+
addPlugin({ src: moduleDirResolver.resolve("./runtime/plugins/route-detector.server"), mode: "server" });
|
|
87
74
|
} else {
|
|
88
|
-
addPlugin({ src: moduleDirResolver.resolve(
|
|
75
|
+
addPlugin({ src: moduleDirResolver.resolve("./runtime/plugins/route-detector-legacy.server"), mode: "server" });
|
|
89
76
|
}
|
|
90
|
-
|
|
91
|
-
// Preps the middleware instrumentation module.
|
|
92
77
|
addMiddlewareImports();
|
|
93
78
|
addStorageInstrumentation(nuxt, !isNitroV3);
|
|
94
79
|
addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);
|
|
95
80
|
}
|
|
96
|
-
|
|
97
81
|
if (clientConfigFile || serverConfigFile) {
|
|
98
82
|
setupSourceMaps(moduleOptions, nuxt, addVitePlugin);
|
|
99
83
|
}
|
|
100
|
-
|
|
101
84
|
addOTelCommonJSImportAlias(nuxt, isNitroV3);
|
|
102
|
-
|
|
103
85
|
let pagesData = [];
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.filter(page => {
|
|
109
|
-
// Check for dynamic parameter (e.g., :userId or [userId])
|
|
110
|
-
return page.path.includes(':') || page?.file?.includes('[');
|
|
111
|
-
});
|
|
86
|
+
nuxt.hooks.hook("pages:extend", (pages) => {
|
|
87
|
+
pagesData = pages.map((page) => ({ file: page.file, path: page.path })).filter((page) => {
|
|
88
|
+
return page.path.includes(":") || page?.file?.includes("[");
|
|
89
|
+
});
|
|
112
90
|
});
|
|
113
|
-
|
|
114
91
|
if (isMinNuxtV4) {
|
|
115
|
-
const pagesDataVirtualModuleId =
|
|
116
|
-
|
|
117
|
-
// Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)
|
|
92
|
+
const pagesDataVirtualModuleId = "#sentry/nuxt-pages-data.mjs";
|
|
118
93
|
addVitePlugin({
|
|
119
|
-
name:
|
|
120
|
-
resolveId: id =>
|
|
121
|
-
load: id =>
|
|
122
|
-
id === `\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,
|
|
94
|
+
name: "sentry-nuxt-pages-data-virtual",
|
|
95
|
+
resolveId: (id) => id === pagesDataVirtualModuleId ? `\0${pagesDataVirtualModuleId}` : null,
|
|
96
|
+
load: (id) => id === `\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : void 0
|
|
123
97
|
});
|
|
124
98
|
} else {
|
|
125
|
-
// Nuxt v3: register as a build template (accessible via #build/)
|
|
126
99
|
addTemplate({
|
|
127
|
-
filename:
|
|
128
|
-
getContents: () => `export default ${JSON.stringify(pagesData, null, 2)}
|
|
100
|
+
filename: "sentry--nuxt-pages-data.mjs",
|
|
101
|
+
getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`
|
|
129
102
|
});
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
nuxt.hook('prepare:types', options => {
|
|
134
|
-
const tsConfig = options.tsConfig ;
|
|
135
|
-
|
|
104
|
+
nuxt.hook("prepare:types", (options) => {
|
|
105
|
+
const tsConfig = options.tsConfig;
|
|
136
106
|
if (!tsConfig.include) {
|
|
137
107
|
tsConfig.include = [];
|
|
138
108
|
}
|
|
139
|
-
|
|
140
|
-
// Add type references for useRuntimeConfig in root files for nuxt v4
|
|
141
|
-
// Should be relative to `root/.nuxt`
|
|
142
109
|
if (clientConfigFile) {
|
|
143
110
|
const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);
|
|
144
111
|
tsConfig.include.push(relativePath);
|
|
@@ -148,87 +115,65 @@ const module$1 = defineNuxtModule({
|
|
|
148
115
|
tsConfig.include.push(relativePath);
|
|
149
116
|
}
|
|
150
117
|
});
|
|
151
|
-
|
|
152
|
-
nuxt.hooks.hook('nitro:init', nitro => {
|
|
118
|
+
nuxt.hooks.hook("nitro:init", (nitro) => {
|
|
153
119
|
if (nuxt.options?._prepare) {
|
|
154
120
|
return;
|
|
155
121
|
}
|
|
156
|
-
|
|
157
122
|
if (serverConfigFile) {
|
|
158
123
|
addMiddlewareInstrumentation(nitro);
|
|
159
124
|
}
|
|
160
|
-
|
|
161
|
-
if (serverConfigFile?.includes('.server.config')) {
|
|
125
|
+
if (serverConfigFile?.includes(".server.config")) {
|
|
162
126
|
consoleSandbox(() => {
|
|
163
127
|
const serverDir = nitro.options.output.serverDir;
|
|
164
|
-
|
|
165
|
-
// Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
166
|
-
if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {
|
|
167
|
-
// eslint-disable-next-line no-console
|
|
128
|
+
if (serverDir.includes(".netlify") || !!process.env.NETLIFY) {
|
|
168
129
|
console.warn(
|
|
169
|
-
|
|
130
|
+
"[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/"
|
|
170
131
|
);
|
|
171
132
|
}
|
|
172
|
-
|
|
173
|
-
// Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL
|
|
174
|
-
if (serverDir.includes('.vercel') || !!process.env.VERCEL) {
|
|
175
|
-
// eslint-disable-next-line no-console
|
|
133
|
+
if (serverDir.includes(".vercel") || !!process.env.VERCEL) {
|
|
176
134
|
console.warn(
|
|
177
|
-
|
|
135
|
+
"[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/"
|
|
178
136
|
);
|
|
179
137
|
}
|
|
180
138
|
});
|
|
181
|
-
|
|
182
|
-
if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {
|
|
139
|
+
if (moduleOptions.autoInjectServerSentry !== "experimental_dynamic-import") {
|
|
183
140
|
addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);
|
|
184
|
-
|
|
185
141
|
if (moduleOptions.debug) {
|
|
186
142
|
const serverDirResolver = createResolver(nitro.options.output.serverDir);
|
|
187
|
-
const serverConfigPath = serverDirResolver.resolve(
|
|
188
|
-
|
|
189
|
-
// For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs
|
|
143
|
+
const serverConfigPath = serverDirResolver.resolve("sentry.server.config.mjs");
|
|
190
144
|
const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;
|
|
191
|
-
|
|
192
145
|
consoleSandbox(() => {
|
|
193
|
-
// eslint-disable-next-line no-console
|
|
194
146
|
console.log(
|
|
195
|
-
`[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
|
|
147
|
+
`[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/.`
|
|
196
148
|
);
|
|
197
|
-
|
|
198
149
|
if (nitro.options.dev) {
|
|
199
|
-
// eslint-disable-next-line no-console
|
|
200
150
|
console.log(
|
|
201
|
-
`[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
|
|
151
|
+
`[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.`
|
|
202
152
|
);
|
|
203
153
|
} else {
|
|
204
|
-
// eslint-disable-next-line no-console
|
|
205
154
|
console.log(
|
|
206
|
-
`[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 [...]\`)
|
|
155
|
+
`[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 [...]\`).`
|
|
207
156
|
);
|
|
208
157
|
}
|
|
209
158
|
});
|
|
210
159
|
}
|
|
211
160
|
}
|
|
212
|
-
|
|
213
|
-
if (moduleOptions.autoInjectServerSentry === 'top-level-import') {
|
|
161
|
+
if (moduleOptions.autoInjectServerSentry === "top-level-import") {
|
|
214
162
|
addSentryTopImport(moduleOptions, nitro);
|
|
215
163
|
}
|
|
216
|
-
|
|
217
|
-
if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {
|
|
164
|
+
if (moduleOptions.autoInjectServerSentry === "experimental_dynamic-import") {
|
|
218
165
|
addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);
|
|
219
|
-
|
|
220
166
|
if (moduleOptions.debug) {
|
|
221
167
|
consoleSandbox(() => {
|
|
222
|
-
// eslint-disable-next-line no-console
|
|
223
168
|
console.log(
|
|
224
|
-
|
|
169
|
+
"[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes."
|
|
225
170
|
);
|
|
226
171
|
});
|
|
227
172
|
}
|
|
228
173
|
}
|
|
229
174
|
}
|
|
230
175
|
});
|
|
231
|
-
}
|
|
176
|
+
}
|
|
232
177
|
});
|
|
233
178
|
|
|
234
179
|
export { module$1 as default };
|
package/build/esm/module.js.map
CHANGED
|
@@ -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 { 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 = findDefaultSdkInitFile('client', nuxt);\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 = findDefaultSdkInitFile('server', nuxt);\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 (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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EAAA;AACA;AACA,gBAAA,OAAA,CAAA,GAAA;AACA,kBAAA,CAAA,iHAAA,EAAA,wBAAA,CAAA,mJAAA,CAAA;AACA,iBAAA;AACA,cAAA,CAAA,MAAA;AACA;AACA,gBAAA,OAAA,CAAA,GAAA;AACA,kBAAA,CAAA,sGAAA,EAAA,wBAAA,CAAA,mEAAA,EAAA,wBAAA,CAAA,gBAAA,CAAA;AACA,iBAAA;AACA,cAAA;AACA,YAAA,CAAA,CAAA;AACA,UAAA;AACA,QAAA;;AAEA,QAAA,IAAA,aAAA,CAAA,sBAAA,KAAA,kBAAA,EAAA;AACA,UAAA,kBAAA,CAAA,aAAA,EAAA,KAAA,CAAA;AACA,QAAA;;AAEA,QAAA,IAAA,aAAA,CAAA,sBAAA,KAAA,6BAAA,EAAA;AACA,UAAA,gCAAA,CAAA,KAAA,EAAA,gBAAA,EAAA,aAAA,CAAA;;AAEA,UAAA,IAAA,aAAA,CAAA,KAAA,EAAA;AACA,YAAA,cAAA,CAAA,MAAA;AACA;AACA,cAAA,OAAA,CAAA,GAAA;AACA,gBAAA,8HAAA;AACA,eAAA;AACA,YAAA,CAAA,CAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA,CAAA,CAAA;AACA,EAAA,CAAA;AACA,CAAA,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 { 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 (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":";;;;;;;;;;AAsBA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAA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AAc,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;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.54.0"}
|
package/build/esm/server/sdk.js
CHANGED
|
@@ -4,115 +4,75 @@ import { init as init$1, getDefaultIntegrations, httpIntegration } from '@sentry
|
|
|
4
4
|
import { isCjs } from '@sentry/node-core';
|
|
5
5
|
import { DEBUG_BUILD } from '../common/debug-build.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Initializes the server-side of the Nuxt SDK
|
|
9
|
-
*
|
|
10
|
-
* @param options Configuration options for the SDK.
|
|
11
|
-
*/
|
|
12
7
|
function init(options) {
|
|
13
8
|
const envFallback = !isCjs() && import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;
|
|
14
9
|
const sentryOptions = {
|
|
15
10
|
environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,
|
|
16
11
|
defaultIntegrations: getNuxtDefaultIntegrations(options),
|
|
17
|
-
...options
|
|
12
|
+
...options
|
|
18
13
|
};
|
|
19
|
-
|
|
20
|
-
applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);
|
|
21
|
-
|
|
14
|
+
applySdkMetadata(sentryOptions, "nuxt", ["nuxt", "node"]);
|
|
22
15
|
const client = init$1(sentryOptions);
|
|
23
|
-
|
|
24
16
|
getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));
|
|
25
17
|
getGlobalScope().addEventProcessor(clientSourceMapErrorFilter(options));
|
|
26
|
-
|
|
27
18
|
return client;
|
|
28
19
|
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Filter out transactions for resource requests which we don't want to send to Sentry
|
|
32
|
-
* for quota reasons.
|
|
33
|
-
*
|
|
34
|
-
* Only exported for testing
|
|
35
|
-
*/
|
|
36
20
|
function lowQualityTransactionsFilter(options) {
|
|
37
21
|
return Object.assign(
|
|
38
|
-
(event => {
|
|
39
|
-
if (event.type !==
|
|
22
|
+
((event) => {
|
|
23
|
+
if (event.type !== "transaction" || !event.transaction || isCacheEvent(event)) {
|
|
40
24
|
return event;
|
|
41
25
|
}
|
|
42
|
-
|
|
43
|
-
// Check if this looks like a parametrized route (contains :param or :param() patterns)
|
|
44
26
|
const hasRouteParameters = /\/:[^(/\s]*(\([^)]*\))?[^/\s]*/.test(event.transaction);
|
|
45
|
-
|
|
46
27
|
if (hasRouteParameters) {
|
|
47
28
|
return event;
|
|
48
29
|
}
|
|
49
|
-
|
|
50
|
-
// We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out
|
|
51
|
-
// path.extname will return an empty string for normal page requests
|
|
52
30
|
if (path.extname(event.transaction)) {
|
|
53
|
-
options.debug &&
|
|
54
|
-
DEBUG_BUILD &&
|
|
55
|
-
debug.log('NuxtLowQualityTransactionsFilter filtered transaction: ', event.transaction);
|
|
31
|
+
options.debug && DEBUG_BUILD && debug.log("NuxtLowQualityTransactionsFilter filtered transaction: ", event.transaction);
|
|
56
32
|
return null;
|
|
57
33
|
}
|
|
58
34
|
return event;
|
|
59
|
-
})
|
|
60
|
-
{ id:
|
|
35
|
+
}),
|
|
36
|
+
{ id: "NuxtLowQualityTransactionsFilter" }
|
|
61
37
|
);
|
|
62
38
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The browser devtools try to get the source maps, but as client source maps may not be available there is going to be an error (no problem for the application though).
|
|
66
|
-
*
|
|
67
|
-
* Only exported for testing
|
|
68
|
-
*/
|
|
69
39
|
function clientSourceMapErrorFilter(options) {
|
|
70
40
|
return Object.assign(
|
|
71
|
-
(event => {
|
|
41
|
+
((event) => {
|
|
72
42
|
const errorMsg = event.exception?.values?.[0]?.value;
|
|
73
43
|
if (errorMsg?.match(/^ENOENT: no such file or directory, open '.*\/_nuxt\/.*\.js\.map'/)) {
|
|
74
|
-
options.debug && DEBUG_BUILD && debug.log(
|
|
44
|
+
options.debug && DEBUG_BUILD && debug.log("NuxtClientSourceMapErrorFilter filtered error: ", errorMsg);
|
|
75
45
|
return null;
|
|
76
46
|
}
|
|
77
47
|
return event;
|
|
78
|
-
})
|
|
79
|
-
{ id:
|
|
48
|
+
}),
|
|
49
|
+
{ id: "NuxtClientSourceMapErrorFilter" }
|
|
80
50
|
);
|
|
81
51
|
}
|
|
82
|
-
|
|
83
52
|
function getNuxtDefaultIntegrations(options) {
|
|
84
53
|
return [
|
|
85
|
-
...getDefaultIntegrations(options).filter(integration => integration.name !==
|
|
54
|
+
...getDefaultIntegrations(options).filter((integration) => integration.name !== "Http"),
|
|
86
55
|
// The httpIntegration is added as defaultIntegration, so users can still overwrite it
|
|
87
56
|
httpIntegration({
|
|
88
57
|
instrumentation: {
|
|
89
58
|
responseHook: () => {
|
|
90
|
-
// Makes it possible to end the tracing span before closing the Vercel lambda (https://vercel.com/docs/functions/functions-api-reference#waituntil)
|
|
91
59
|
vercelWaitUntil(flushSafelyWithTimeout());
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
95
63
|
];
|
|
96
64
|
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.
|
|
100
|
-
*/
|
|
101
65
|
async function flushSafelyWithTimeout() {
|
|
102
66
|
try {
|
|
103
|
-
DEBUG_BUILD && debug.log(
|
|
104
|
-
await flush(
|
|
105
|
-
DEBUG_BUILD && debug.log(
|
|
67
|
+
DEBUG_BUILD && debug.log("Flushing events...");
|
|
68
|
+
await flush(2e3);
|
|
69
|
+
DEBUG_BUILD && debug.log("Done flushing events");
|
|
106
70
|
} catch (e) {
|
|
107
|
-
DEBUG_BUILD && debug.log(
|
|
71
|
+
DEBUG_BUILD && debug.log("Error while flushing events:\n", e);
|
|
108
72
|
}
|
|
109
73
|
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Checks if the event is a cache event.
|
|
113
|
-
*/
|
|
114
74
|
function isCacheEvent(e) {
|
|
115
|
-
return e.contexts?.trace?.origin ===
|
|
75
|
+
return e.contexts?.trace?.origin === "auto.cache.nuxt";
|
|
116
76
|
}
|
|
117
77
|
|
|
118
78
|
export { clientSourceMapErrorFilter, init, lowQualityTransactionsFilter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { Client, Event, EventProcessor, Integration } from '@sentry/core';\nimport {\n applySdkMetadata,\n debug,\n DEFAULT_ENVIRONMENT,\n DEV_ENVIRONMENT,\n flush,\n getGlobalScope,\n vercelWaitUntil,\n} from '@sentry/core';\nimport {\n getDefaultIntegrations as getDefaultNodeIntegrations,\n httpIntegration,\n init as initNode,\n type NodeOptions,\n} from '@sentry/node';\nimport { isCjs } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../common/debug-build';\nimport type { SentryNuxtServerOptions } from '../common/types';\n\n/**\n * Initializes the server-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtServerOptions): Client | undefined {\n const envFallback = !isCjs() && import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;\n const sentryOptions = {\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,\n defaultIntegrations: getNuxtDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);\n\n const client = initNode(sentryOptions);\n\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n getGlobalScope().addEventProcessor(clientSourceMapErrorFilter(options));\n\n return client;\n}\n\n/**\n * Filter out transactions for resource requests which we don't want to send to Sentry\n * for quota reasons.\n *\n * Only exported for testing\n */\nexport function lowQualityTransactionsFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction' || !event.transaction || isCacheEvent(event)) {\n return event;\n }\n\n // Check if this looks like a parametrized route (contains :param or :param() patterns)\n const hasRouteParameters = /\\/:[^(/\\s]*(\\([^)]*\\))?[^/\\s]*/.test(event.transaction);\n\n if (hasRouteParameters) {\n return event;\n }\n\n // We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out\n // path.extname will return an empty string for normal page requests\n if (path.extname(event.transaction)) {\n options.debug &&\n DEBUG_BUILD &&\n debug.log('NuxtLowQualityTransactionsFilter filtered transaction: ', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * The browser devtools try to get the source maps, but as client source maps may not be available there is going to be an error (no problem for the application though).\n *\n * Only exported for testing\n */\nexport function clientSourceMapErrorFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n const errorMsg = event.exception?.values?.[0]?.value;\n if (errorMsg?.match(/^ENOENT: no such file or directory, open '.*\\/_nuxt\\/.*\\.js\\.map'/)) {\n options.debug && DEBUG_BUILD && debug.log('NuxtClientSourceMapErrorFilter filtered error: ', errorMsg);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtClientSourceMapErrorFilter' },\n );\n}\n\nfunction getNuxtDefaultIntegrations(options: NodeOptions): Integration[] {\n return [\n ...getDefaultNodeIntegrations(options).filter(integration => integration.name !== 'Http'),\n // The httpIntegration is added as defaultIntegration, so users can still overwrite it\n httpIntegration({\n instrumentation: {\n responseHook: () => {\n // Makes it possible to end the tracing span before closing the Vercel lambda (https://vercel.com/docs/functions/functions-api-reference#waituntil)\n vercelWaitUntil(flushSafelyWithTimeout());\n },\n },\n }),\n ];\n}\n\n/**\n * Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.\n */\nasync function flushSafelyWithTimeout(): Promise<void> {\n try {\n DEBUG_BUILD && debug.log('Flushing events...');\n await flush(2000);\n DEBUG_BUILD && debug.log('Done flushing events');\n } catch (e) {\n DEBUG_BUILD && debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Checks if the event is a cache event.\n */\nfunction isCacheEvent(e: Event): boolean {\n return e.contexts?.trace?.origin === 'auto.cache.nuxt';\n}\n"],"names":["initNode","getDefaultNodeIntegrations"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { Client, Event, EventProcessor, Integration } from '@sentry/core';\nimport {\n applySdkMetadata,\n debug,\n DEFAULT_ENVIRONMENT,\n DEV_ENVIRONMENT,\n flush,\n getGlobalScope,\n vercelWaitUntil,\n} from '@sentry/core';\nimport {\n getDefaultIntegrations as getDefaultNodeIntegrations,\n httpIntegration,\n init as initNode,\n type NodeOptions,\n} from '@sentry/node';\nimport { isCjs } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../common/debug-build';\nimport type { SentryNuxtServerOptions } from '../common/types';\n\n/**\n * Initializes the server-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtServerOptions): Client | undefined {\n const envFallback = !isCjs() && import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;\n const sentryOptions = {\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,\n defaultIntegrations: getNuxtDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);\n\n const client = initNode(sentryOptions);\n\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n getGlobalScope().addEventProcessor(clientSourceMapErrorFilter(options));\n\n return client;\n}\n\n/**\n * Filter out transactions for resource requests which we don't want to send to Sentry\n * for quota reasons.\n *\n * Only exported for testing\n */\nexport function lowQualityTransactionsFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction' || !event.transaction || isCacheEvent(event)) {\n return event;\n }\n\n // Check if this looks like a parametrized route (contains :param or :param() patterns)\n const hasRouteParameters = /\\/:[^(/\\s]*(\\([^)]*\\))?[^/\\s]*/.test(event.transaction);\n\n if (hasRouteParameters) {\n return event;\n }\n\n // We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out\n // path.extname will return an empty string for normal page requests\n if (path.extname(event.transaction)) {\n options.debug &&\n DEBUG_BUILD &&\n debug.log('NuxtLowQualityTransactionsFilter filtered transaction: ', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * The browser devtools try to get the source maps, but as client source maps may not be available there is going to be an error (no problem for the application though).\n *\n * Only exported for testing\n */\nexport function clientSourceMapErrorFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n const errorMsg = event.exception?.values?.[0]?.value;\n if (errorMsg?.match(/^ENOENT: no such file or directory, open '.*\\/_nuxt\\/.*\\.js\\.map'/)) {\n options.debug && DEBUG_BUILD && debug.log('NuxtClientSourceMapErrorFilter filtered error: ', errorMsg);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtClientSourceMapErrorFilter' },\n );\n}\n\nfunction getNuxtDefaultIntegrations(options: NodeOptions): Integration[] {\n return [\n ...getDefaultNodeIntegrations(options).filter(integration => integration.name !== 'Http'),\n // The httpIntegration is added as defaultIntegration, so users can still overwrite it\n httpIntegration({\n instrumentation: {\n responseHook: () => {\n // Makes it possible to end the tracing span before closing the Vercel lambda (https://vercel.com/docs/functions/functions-api-reference#waituntil)\n vercelWaitUntil(flushSafelyWithTimeout());\n },\n },\n }),\n ];\n}\n\n/**\n * Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.\n */\nasync function flushSafelyWithTimeout(): Promise<void> {\n try {\n DEBUG_BUILD && debug.log('Flushing events...');\n await flush(2000);\n DEBUG_BUILD && debug.log('Done flushing events');\n } catch (e) {\n DEBUG_BUILD && debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Checks if the event is a cache event.\n */\nfunction isCacheEvent(e: Event): boolean {\n return e.contexts?.trace?.origin === 'auto.cache.nuxt';\n}\n"],"names":["initNode","getDefaultNodeIntegrations"],"mappings":";;;;;;AA0BO,SAAS,KAAK,OAAA,EAAsD;AACzE,EAAA,MAAM,cAAc,CAAC,KAAA,EAAM,IAAK,MAAA,CAAA,IAAA,CAAY,MAAM,eAAA,GAAkB,mBAAA;AACpE,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,WAAA,EAAa,OAAA,CAAQ,WAAA,IAAe,OAAA,CAAQ,IAAI,kBAAA,IAAsB,WAAA;AAAA,IACtE,mBAAA,EAAqB,2BAA2B,OAAO,CAAA;AAAA,IACvD,GAAG;AAAA,GACL;AAEA,EAAA,gBAAA,CAAiB,aAAA,EAAe,MAAA,EAAQ,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAA;AAExD,EAAA,MAAM,MAAA,GAASA,OAAS,aAAa,CAAA;AAErC,EAAA,cAAA,EAAe,CAAE,iBAAA,CAAkB,4BAAA,CAA6B,OAAO,CAAC,CAAA;AACxE,EAAA,cAAA,EAAe,CAAE,iBAAA,CAAkB,0BAAA,CAA2B,OAAO,CAAC,CAAA;AAEtE,EAAA,OAAO,MAAA;AACT;AAQO,SAAS,6BAA6B,OAAA,EAAkD;AAC7F,EAAA,OAAO,MAAA,CAAO,MAAA;AAAA,KACX,CAAA,KAAA,KAAS;AACR,MAAA,IAAI,KAAA,CAAM,SA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A,QACf,cAAc,MAAM;AAElB,UAAA,eAAA,CAAgB,wBAAwB,CAAA;AAAA,QAC1C;AAAA;AACF,KACD;AAAA,GACH;AACF;AAKA,eAAe,sBAAA,GAAwC;AACrD,EAAA,IAAI;AACF,IAAA,WAAA,IAAe,KAAA,CAAM,IAAI,oBAAoB,CAAA;AAC7C,IAAA,MAAM,MAAM,GAAI,CAAA;AAChB,IAAA,WAAA,IAAe,KAAA,CAAM,IAAI,sBAAsB,CAAA;AAAA,EACjD,SAAS,CAAA,EAAG;AACV,IAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,gCAAA,EAAkC,CAAC,CAAA;AAAA,EAC9D;AACF;AAKA,SAAS,aAAa,CAAA,EAAmB;AACvC,EAAA,OAAO,CAAA,CAAE,QAAA,EAAU,KAAA,EAAO,MAAA,KAAW,iBAAA;AACvC;;;;"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { useNuxt } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Adds a virtual file that can be used within the Nuxt Nitro server build.
|
|
5
|
-
* Available in NuxtKit v4, so we are porting it here.
|
|
6
|
-
* https://github.com/nuxt/nuxt/blob/d6df732eec1a3bd442bdb325b0335beb7e10cd64/packages/kit/src/template.ts#L55-L62
|
|
7
|
-
*/
|
|
8
3
|
function addServerTemplate(template) {
|
|
9
4
|
const nuxt = useNuxt();
|
|
10
5
|
if (template.filename) {
|
|
11
6
|
nuxt.options.nitro.virtual = nuxt.options.nitro.virtual || {};
|
|
12
7
|
nuxt.options.nitro.virtual[template.filename] = template.getContents;
|
|
13
8
|
}
|
|
14
|
-
|
|
15
9
|
return template;
|
|
16
10
|
}
|
|
17
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-template.js","sources":["../../../src/vendor/server-template.ts"],"sourcesContent":["import { useNuxt } from '@nuxt/kit';\nimport type { NuxtTemplate } from '@nuxt/schema';\n\n/**\n * Adds a virtual file that can be used within the Nuxt Nitro server build.\n * Available in NuxtKit v4, so we are porting it here.\n * https://github.com/nuxt/nuxt/blob/d6df732eec1a3bd442bdb325b0335beb7e10cd64/packages/kit/src/template.ts#L55-L62\n */\nexport function addServerTemplate(template: NuxtTemplate): NuxtTemplate {\n const nuxt = useNuxt();\n if (template.filename) {\n nuxt.options.nitro.virtual = nuxt.options.nitro.virtual || {};\n nuxt.options.nitro.virtual[template.filename] = template.getContents;\n }\n\n return template;\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"server-template.js","sources":["../../../src/vendor/server-template.ts"],"sourcesContent":["import { useNuxt } from '@nuxt/kit';\nimport type { NuxtTemplate } from '@nuxt/schema';\n\n/**\n * Adds a virtual file that can be used within the Nuxt Nitro server build.\n * Available in NuxtKit v4, so we are porting it here.\n * https://github.com/nuxt/nuxt/blob/d6df732eec1a3bd442bdb325b0335beb7e10cd64/packages/kit/src/template.ts#L55-L62\n */\nexport function addServerTemplate(template: NuxtTemplate): NuxtTemplate {\n const nuxt = useNuxt();\n if (template.filename) {\n nuxt.options.nitro.virtual = nuxt.options.nitro.virtual || {};\n nuxt.options.nitro.virtual[template.filename] = template.getContents;\n }\n\n return template;\n}\n"],"names":[],"mappings":";;AAQO,SAAS,kBAAkB,QAAA,EAAsC;AACtE,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,IAAI,SAAS,QAAA,EAAU;AACrB,IAAA,IAAA,CAAK,QAAQ,KAAA,CAAM,OAAA,GAAU,KAAK,OAAA,CAAQ,KAAA,CAAM,WAAW,EAAC;AAC5D,IAAA,IAAA,CAAK,QAAQ,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,QAAQ,IAAI,QAAA,CAAS,WAAA;AAAA,EAC3D;AAEA,EAAA,OAAO,QAAA;AACT;;;;"}
|