@sentry/nuxt 10.69.0 → 11.0.0-alpha.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/module.js +1 -3
- package/build/cjs/module.js.map +1 -1
- package/build/cjs/vite/addServerConfig.js +0 -4
- package/build/cjs/vite/addServerConfig.js.map +1 -1
- package/build/cjs/vite/orchestrion.js +9 -2
- package/build/cjs/vite/orchestrion.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +32 -46
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/esm/module.js +1 -3
- package/build/esm/module.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/vite/addServerConfig.js +0 -4
- package/build/esm/vite/addServerConfig.js.map +1 -1
- package/build/esm/vite/orchestrion.js +9 -2
- package/build/esm/vite/orchestrion.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +30 -44
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/module/common/types.d.ts +3 -168
- package/build/module/module.json +1 -1
- package/build/module/module.mjs +40 -53
- package/build/module/runtime/hooks/updateRouteBeforeResponse.js +3 -5
- package/build/module/runtime/hooks/wrapMiddlewareHandler.js +8 -4
- package/build/module/runtime/plugins/route-detector-legacy.server.js +4 -12
- package/build/module/runtime/plugins/route-detector.server.js +3 -13
- package/build/module/runtime/plugins/sentry-cloudflare.server.js +5 -2
- package/build/module/runtime/utils/instrumentStorage.js +27 -7
- package/build/module/vite/addServerConfig.d.ts +1 -1
- package/build/module/vite/orchestrion.d.ts +6 -1
- package/build/module/vite/sourceMaps.d.ts +2 -2
- package/build/types/common/types.d.ts +3 -168
- package/build/types/common/types.d.ts.map +1 -1
- package/build/types/index.types.d.ts +1 -0
- package/build/types/index.types.d.ts.map +1 -1
- package/build/types/module.d.ts.map +1 -1
- package/build/types/runtime/hooks/updateRouteBeforeResponse.d.ts.map +1 -1
- package/build/types/runtime/hooks/wrapMiddlewareHandler.d.ts.map +1 -1
- package/build/types/runtime/plugins/database-legacy.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/database.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/handler-legacy.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/handler.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/route-detector-legacy.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/route-detector.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/sentry-cloudflare.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/sentry.client.d.ts.map +1 -1
- package/build/types/runtime/plugins/sentry.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/storage-legacy.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/storage.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/update-route-name-legacy.server.d.ts.map +1 -1
- package/build/types/runtime/plugins/update-route-name.server.d.ts.map +1 -1
- package/build/types/runtime/utils/instrumentStorage.d.ts.map +1 -1
- package/build/types/vite/addServerConfig.d.ts +1 -1
- package/build/types/vite/orchestrion.d.ts +6 -1
- package/build/types/vite/orchestrion.d.ts.map +1 -1
- package/build/types/vite/sourceMaps.d.ts +2 -2
- package/build/types/vite/sourceMaps.d.ts.map +1 -1
- package/package.json +12 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuildTimeOptionsBase } from '@sentry/core';
|
|
2
2
|
import type { init as initNode } from '@sentry/node';
|
|
3
|
-
import type { SentryRollupPluginOptions } from '@sentry/rollup
|
|
4
|
-
import type { SentryVitePluginOptions } from '@sentry/vite
|
|
3
|
+
import type { SentryRollupPluginOptions } from '@sentry/bundler-plugins/rollup';
|
|
4
|
+
import type { SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';
|
|
5
5
|
import type { init as initVue } from '@sentry/vue';
|
|
6
6
|
export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & object, 'app'>;
|
|
7
7
|
export type SentryNuxtServerOptions = Parameters<typeof initNode>[0] & {
|
|
@@ -18,144 +18,6 @@ export type SentryNuxtServerOptions = Parameters<typeof initNode>[0] & {
|
|
|
18
18
|
*/
|
|
19
19
|
enableNitroErrorHandler?: boolean;
|
|
20
20
|
};
|
|
21
|
-
type SourceMapsOptions = {
|
|
22
|
-
/**
|
|
23
|
-
* Suppresses all logs.
|
|
24
|
-
*
|
|
25
|
-
* @default false
|
|
26
|
-
* @deprecated Use option `silent` instead of `sourceMapsUploadOptions.silent`
|
|
27
|
-
*/
|
|
28
|
-
silent?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
|
|
31
|
-
*
|
|
32
|
-
* By default, the plugin will simply throw an error, thereby stopping the bundling process.
|
|
33
|
-
* If an `errorHandler` callback is provided, compilation will continue, unless an error is
|
|
34
|
-
* thrown in the provided callback.
|
|
35
|
-
*
|
|
36
|
-
* To allow compilation to continue but still emit a warning, set this option to the following:
|
|
37
|
-
*
|
|
38
|
-
* ```js
|
|
39
|
-
* (err) => {
|
|
40
|
-
* console.warn(err);
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @deprecated Use option `errorHandler` instead of `sourceMapsUploadOptions.errorHandler`
|
|
45
|
-
*/
|
|
46
|
-
errorHandler?: (err: Error) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Options related to managing the Sentry releases for a build.
|
|
49
|
-
*
|
|
50
|
-
* More info: https://docs.sentry.io/product/releases/
|
|
51
|
-
*
|
|
52
|
-
* @deprecated Use option `release` instead of `sourceMapsUploadOptions.release`
|
|
53
|
-
*/
|
|
54
|
-
release?: {
|
|
55
|
-
/**
|
|
56
|
-
* Unique identifier for the release you want to create.
|
|
57
|
-
*
|
|
58
|
-
* This value can also be specified via the `SENTRY_RELEASE` environment variable.
|
|
59
|
-
*
|
|
60
|
-
* Defaults to automatically detecting a value for your environment.
|
|
61
|
-
* This includes values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA.
|
|
62
|
-
* (the latter requires access to git CLI and for the root directory to be a valid repository)
|
|
63
|
-
*
|
|
64
|
-
* If you didn't provide a value and the plugin can't automatically detect one, no release will be created.
|
|
65
|
-
*
|
|
66
|
-
* @deprecated Use `release.name` instead of `sourceMapsUploadOptions.release.name`
|
|
67
|
-
*/
|
|
68
|
-
name?: string;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* If this flag is `true`, and an auth token is detected, the Sentry SDK will
|
|
72
|
-
* automatically generate and upload source maps to Sentry during a production build.
|
|
73
|
-
*
|
|
74
|
-
* @default true
|
|
75
|
-
* @deprecated Use option `sourcemaps.disable` instead of `sourceMapsUploadOptions.enabled`
|
|
76
|
-
*/
|
|
77
|
-
enabled?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* The auth token to use when uploading source maps to Sentry.
|
|
80
|
-
*
|
|
81
|
-
* Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
|
|
82
|
-
*
|
|
83
|
-
* To create an auth token, follow this guide:
|
|
84
|
-
* @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
|
|
85
|
-
* @deprecated Use option `authToken` instead of `sourceMapsUploadOptions.authToken`
|
|
86
|
-
*/
|
|
87
|
-
authToken?: string;
|
|
88
|
-
/**
|
|
89
|
-
* The organization slug of your Sentry organization.
|
|
90
|
-
* Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
|
|
91
|
-
* @deprecated Use option `org` instead of `sourceMapsUploadOptions.org`
|
|
92
|
-
*/
|
|
93
|
-
org?: string;
|
|
94
|
-
/**
|
|
95
|
-
* The URL of your Sentry instance if you're using self-hosted Sentry.
|
|
96
|
-
*
|
|
97
|
-
* @default https://sentry.io by default the plugin will point towards the Sentry SaaS URL
|
|
98
|
-
* @deprecated Use `sentryUrl` instead of `sourceMapsUploadOptions.url`
|
|
99
|
-
*/
|
|
100
|
-
url?: string;
|
|
101
|
-
/**
|
|
102
|
-
* The project slug of your Sentry project.
|
|
103
|
-
* Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
|
|
104
|
-
*
|
|
105
|
-
* @deprecated Use option `project` instead of `sourceMapsUploadOptions.project`
|
|
106
|
-
*/
|
|
107
|
-
project?: string;
|
|
108
|
-
/**
|
|
109
|
-
* If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
|
|
110
|
-
* It will not collect any sensitive or user-specific data.
|
|
111
|
-
*
|
|
112
|
-
* @default true
|
|
113
|
-
* @deprecated Use option `telemetry` instead of `sourceMapsUploadOptions.telemetry`
|
|
114
|
-
*/
|
|
115
|
-
telemetry?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Options related to sourcemaps
|
|
118
|
-
*
|
|
119
|
-
* @deprecated Use option `sourcemaps` instead of `sourceMapsUploadOptions.sourcemaps`
|
|
120
|
-
*/
|
|
121
|
-
sourcemaps?: {
|
|
122
|
-
/**
|
|
123
|
-
* A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
|
|
124
|
-
*
|
|
125
|
-
* If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
|
|
126
|
-
* setup will be used. Use this option to override these defaults, for instance if you have a
|
|
127
|
-
* customized build setup that diverges from Nuxt's defaults.
|
|
128
|
-
*
|
|
129
|
-
* The globbing patterns must follow the implementation of the `glob` package.
|
|
130
|
-
* @see https://www.npmjs.com/package/glob#glob-primer
|
|
131
|
-
*
|
|
132
|
-
* @deprecated Use option `sourcemaps.assets` instead of `sourceMapsUploadOptions.sourcemaps.assets`
|
|
133
|
-
*/
|
|
134
|
-
assets?: string | Array<string>;
|
|
135
|
-
/**
|
|
136
|
-
* A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
|
|
137
|
-
*
|
|
138
|
-
* @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
|
|
139
|
-
* or the default value for `assets` are uploaded.
|
|
140
|
-
*
|
|
141
|
-
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
|
|
142
|
-
*
|
|
143
|
-
* @deprecated Use option `sourcemaps.ignore` instead of `sourceMapsUploadOptions.sourcemaps.ignore`
|
|
144
|
-
*/
|
|
145
|
-
ignore?: string | Array<string>;
|
|
146
|
-
/**
|
|
147
|
-
* A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
|
|
148
|
-
* upload to Sentry has been completed.
|
|
149
|
-
*
|
|
150
|
-
* @default [] - By default no files are deleted.
|
|
151
|
-
*
|
|
152
|
-
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
|
|
153
|
-
*
|
|
154
|
-
* @deprecated Use option `sourcemaps.filesToDeleteAfterUpload` instead of `sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload`
|
|
155
|
-
*/
|
|
156
|
-
filesToDeleteAfterUpload?: string | Array<string>;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
21
|
/**
|
|
160
22
|
* Build options for the Sentry module. These options are used during build-time by the Sentry SDK.
|
|
161
23
|
*/
|
|
@@ -166,32 +28,6 @@ export type SentryNuxtModuleOptions = BuildTimeOptionsBase & {
|
|
|
166
28
|
* @default true
|
|
167
29
|
*/
|
|
168
30
|
enabled?: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Experimental build-time options that may change or be removed without notice.
|
|
171
|
-
*/
|
|
172
|
-
_experimental?: {
|
|
173
|
-
/**
|
|
174
|
-
* Enables build-time diagnostics-channel instrumentation for supported dependencies bundled into the Nitro server.
|
|
175
|
-
*
|
|
176
|
-
* 1. Call `Sentry.experimentalUseDiagnosticsChannelInjection()` just before `Sentry.init()`
|
|
177
|
-
* 2. Remove `--import ./.output/server/sentry.server.config.mjs` from your `start`script
|
|
178
|
-
* 3. Add `sentry.autoInjectServerSentry: 'top-level-import'` in `nuxt.config.ts` so Sentry's server configuration is automatically imported
|
|
179
|
-
*
|
|
180
|
-
* @default false
|
|
181
|
-
* @experimental May change or be removed in any release.
|
|
182
|
-
*/
|
|
183
|
-
useDiagnosticsChannelInjection?: boolean;
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Options for the Sentry Vite plugin to customize the source maps upload process.
|
|
187
|
-
*
|
|
188
|
-
* These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
|
|
189
|
-
* Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
|
|
190
|
-
*
|
|
191
|
-
* @deprecated This option was deprecated as it adds unnecessary nesting.
|
|
192
|
-
* Put the options one level higher to the root-level of the `sentry` module options.
|
|
193
|
-
*/
|
|
194
|
-
sourceMapsUploadOptions?: SourceMapsOptions;
|
|
195
31
|
/**
|
|
196
32
|
*
|
|
197
33
|
* Enables (partial) server tracing by automatically injecting Sentry for environments where modifying the node option `--import` is not possible.
|
|
@@ -249,11 +85,10 @@ export type SentryNuxtModuleOptions = BuildTimeOptionsBase & {
|
|
|
249
85
|
*/
|
|
250
86
|
experimental_entrypointWrappedFunctions?: string[];
|
|
251
87
|
/**
|
|
252
|
-
* Options to be passed directly to the Sentry Rollup Plugin (`@sentry/rollup
|
|
88
|
+
* Options to be passed directly to the Sentry Rollup Plugin (`@sentry/bundler-plugins/rollup`) and Sentry Vite Plugin (`@sentry/bundler-plugins/vite`) that ship with the Sentry Nuxt SDK.
|
|
253
89
|
* You can use this option to override any options the SDK passes to the Vite (for Nuxt) and Rollup (for Nitro) plugin.
|
|
254
90
|
*
|
|
255
91
|
* Please note that this option is unstable and may change in a breaking way in any release.
|
|
256
92
|
*/
|
|
257
93
|
unstable_sentryBundlerPluginOptions?: SentryRollupPluginOptions & SentryVitePluginOptions;
|
|
258
94
|
};
|
|
259
|
-
export {};
|
package/build/module/module.json
CHANGED
package/build/module/module.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { existsSync } from 'node:fs';
|
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';
|
|
7
7
|
import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';
|
|
8
|
-
import { sentryRollupPlugin } from '@sentry/rollup
|
|
9
|
-
import { sentryVitePlugin } from '@sentry/vite
|
|
8
|
+
import { sentryRollupPlugin } from '@sentry/bundler-plugins/rollup';
|
|
9
|
+
import { sentryVitePlugin } from '@sentry/bundler-plugins/vite';
|
|
10
10
|
|
|
11
11
|
async function getNitroMajorVersion() {
|
|
12
12
|
try {
|
|
@@ -230,9 +230,6 @@ function wrapEntryWithDynamicImport({
|
|
|
230
230
|
if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {
|
|
231
231
|
return { id: source, moduleSideEffects: true };
|
|
232
232
|
}
|
|
233
|
-
if (source === "import-in-the-middle/hook.mjs") {
|
|
234
|
-
return { id: source, moduleSideEffects: true, external: true };
|
|
235
|
-
}
|
|
236
233
|
if (options.isEntry && source.includes(".mjs") && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
|
|
237
234
|
const resolution = await this.resolve(source, importer, options);
|
|
238
235
|
if (!resolution || resolution?.external) return resolution;
|
|
@@ -256,7 +253,6 @@ function wrapEntryWithDynamicImport({
|
|
|
256
253
|
// Regular `import` of the Sentry config
|
|
257
254
|
`import ${JSON.stringify(resolvedSentryConfigPath)};
|
|
258
255
|
import(${JSON.stringify(entryId)});
|
|
259
|
-
import 'import-in-the-middle/hook.mjs';
|
|
260
256
|
${reExportedFunctions}
|
|
261
257
|
`
|
|
262
258
|
);
|
|
@@ -362,18 +358,25 @@ ${originalCode.replace(/defineEventHandler\(/g, "defineInstrumentedEventHandler(
|
|
|
362
358
|
}
|
|
363
359
|
|
|
364
360
|
const IORedisDependencies = ["standard-as-callback"];
|
|
365
|
-
function setupOrchestrion(nuxt) {
|
|
361
|
+
function setupOrchestrion(nuxt, hasServerConfig, buildTimeInstrumentation) {
|
|
362
|
+
if (buildTimeInstrumentation === false) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
366
365
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
367
366
|
if (nuxt.options?._prepare) {
|
|
368
367
|
return;
|
|
369
368
|
}
|
|
369
|
+
const isCloudflare = !!nitroConfig.preset?.replace(/-/g, "_").startsWith("cloudflare");
|
|
370
|
+
if (!hasServerConfig && !isCloudflare) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
370
373
|
nitroConfig.rollupConfig ?? (nitroConfig.rollupConfig = {});
|
|
371
374
|
if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === void 0) {
|
|
372
375
|
nitroConfig.rollupConfig.plugins = [];
|
|
373
376
|
} else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {
|
|
374
377
|
nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];
|
|
375
378
|
}
|
|
376
|
-
nitroConfig.rollupConfig.plugins.push(sentryOrchestrionPlugin());
|
|
379
|
+
nitroConfig.rollupConfig.plugins.push(sentryOrchestrionPlugin({}));
|
|
377
380
|
const externals = nitroConfig.externals || (nitroConfig.externals = {});
|
|
378
381
|
const inline = externals.inline;
|
|
379
382
|
const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];
|
|
@@ -409,11 +412,7 @@ function validateSourceMapsOptionsPlugin(options) {
|
|
|
409
412
|
|
|
410
413
|
function setupSourceMaps(moduleOptions, nuxt, addVitePlugin) {
|
|
411
414
|
const isDebug = moduleOptions.debug;
|
|
412
|
-
const
|
|
413
|
-
const sourceMapsEnabled = moduleOptions.sourcemaps?.disable === true ? false : moduleOptions.sourcemaps?.disable === false ? true : (
|
|
414
|
-
// eslint-disable-next-line typescript/no-deprecated
|
|
415
|
-
sourceMapsUploadOptions.enabled ?? true
|
|
416
|
-
);
|
|
415
|
+
const sourceMapsEnabled = moduleOptions.sourcemaps?.disable !== true;
|
|
417
416
|
const shouldDeleteFilesFallback = { client: true, server: true };
|
|
418
417
|
nuxt.hook("modules:done", () => {
|
|
419
418
|
if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {
|
|
@@ -422,8 +421,7 @@ function setupSourceMaps(moduleOptions, nuxt, addVitePlugin) {
|
|
|
422
421
|
shouldDeleteFilesFallback.server = previousSourceMapSettings.server === "unset";
|
|
423
422
|
if (isDebug && (shouldDeleteFilesFallback.client || shouldDeleteFilesFallback.server)) {
|
|
424
423
|
const enabledDeleteFallbacks = shouldDeleteFilesFallback.client && shouldDeleteFilesFallback.server ? "client-side and server-side" : shouldDeleteFilesFallback.server ? "server-side" : "client-side";
|
|
425
|
-
if (!moduleOptions.sourcemaps?.filesToDeleteAfterUpload
|
|
426
|
-
!sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload) {
|
|
424
|
+
if (!moduleOptions.sourcemaps?.filesToDeleteAfterUpload) {
|
|
427
425
|
console.log(
|
|
428
426
|
`[Sentry] We enabled \`'hidden'\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be automatically deleted after uploading them to Sentry.`
|
|
429
427
|
);
|
|
@@ -468,44 +466,23 @@ function normalizePath(path) {
|
|
|
468
466
|
return path.replace(/^(\.\.\/)+/, "./");
|
|
469
467
|
}
|
|
470
468
|
function getPluginOptions(moduleOptions, shouldDeleteFilesFallback) {
|
|
471
|
-
const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};
|
|
472
|
-
const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server;
|
|
473
|
-
const fallbackFilesToDelete = [
|
|
474
|
-
...shouldDeleteFilesFallback?.client ? [".*/**/public/**/*.map"] : [],
|
|
475
|
-
...shouldDeleteFilesFallback?.server ? [".*/**/server/**/*.map", ".*/**/output/**/*.map", ".*/**/function/**/*.map"] : []
|
|
476
|
-
];
|
|
477
469
|
const sourcemapsOptions = moduleOptions.sourcemaps || {};
|
|
478
|
-
const
|
|
479
|
-
const filesToDeleteAfterUpload = sourcemapsOptions.filesToDeleteAfterUpload ?? // eslint-disable-next-line typescript/no-deprecated
|
|
480
|
-
deprecatedSourcemapsOptions.filesToDeleteAfterUpload;
|
|
481
|
-
if (typeof filesToDeleteAfterUpload === "undefined" && shouldDeleteFilesAfterUpload && moduleOptions.debug) {
|
|
482
|
-
console.log(
|
|
483
|
-
`[Sentry] Setting \`sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete.map((path) => `"${path}"`).join(", ")}]\` to delete generated source maps after they were uploaded to Sentry.`
|
|
484
|
-
);
|
|
485
|
-
}
|
|
470
|
+
const filesToDeleteAfterUpload = resolveFilesToDeleteAfterUpload(moduleOptions, shouldDeleteFilesFallback);
|
|
486
471
|
return {
|
|
487
472
|
applicationKey: moduleOptions.applicationKey,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
authToken: moduleOptions.authToken ?? sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,
|
|
494
|
-
// eslint-disable-next-line typescript/no-deprecated
|
|
495
|
-
telemetry: moduleOptions.telemetry ?? sourceMapsUploadOptions.telemetry ?? true,
|
|
496
|
-
// eslint-disable-next-line typescript/no-deprecated
|
|
497
|
-
url: moduleOptions.sentryUrl ?? sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,
|
|
473
|
+
org: moduleOptions.org ?? process.env.SENTRY_ORG,
|
|
474
|
+
project: moduleOptions.project ?? process.env.SENTRY_PROJECT,
|
|
475
|
+
authToken: moduleOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,
|
|
476
|
+
telemetry: moduleOptions.telemetry ?? true,
|
|
477
|
+
url: moduleOptions.sentryUrl ?? process.env.SENTRY_URL,
|
|
498
478
|
headers: moduleOptions.headers,
|
|
499
479
|
debug: moduleOptions.debug ?? false,
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
// eslint-disable-next-line typescript/no-deprecated
|
|
503
|
-
errorHandler: moduleOptions.errorHandler ?? sourceMapsUploadOptions.errorHandler,
|
|
480
|
+
silent: moduleOptions.silent ?? false,
|
|
481
|
+
errorHandler: moduleOptions.errorHandler,
|
|
504
482
|
bundleSizeOptimizations: moduleOptions.bundleSizeOptimizations,
|
|
505
483
|
// todo: test if this can be overridden by the user
|
|
506
484
|
release: {
|
|
507
|
-
|
|
508
|
-
name: moduleOptions.release?.name ?? sourceMapsUploadOptions.release?.name,
|
|
485
|
+
name: moduleOptions.release?.name,
|
|
509
486
|
// Support all release options from BuildTimeOptionsBase
|
|
510
487
|
...moduleOptions.release,
|
|
511
488
|
...moduleOptions?.unstable_sentryBundlerPluginOptions?.release
|
|
@@ -521,16 +498,28 @@ function getPluginOptions(moduleOptions, shouldDeleteFilesFallback) {
|
|
|
521
498
|
// The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')
|
|
522
499
|
// We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).
|
|
523
500
|
// If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
ignore: sourcemapsOptions.ignore ?? deprecatedSourcemapsOptions.ignore ?? void 0,
|
|
528
|
-
filesToDeleteAfterUpload: filesToDeleteAfterUpload ? filesToDeleteAfterUpload : shouldDeleteFilesFallback?.server || shouldDeleteFilesFallback?.client ? fallbackFilesToDelete : void 0,
|
|
501
|
+
assets: sourcemapsOptions.assets ?? void 0,
|
|
502
|
+
ignore: sourcemapsOptions.ignore ?? void 0,
|
|
503
|
+
filesToDeleteAfterUpload,
|
|
529
504
|
rewriteSources: sourcemapsOptions.rewriteSources ?? normalizePath,
|
|
530
505
|
...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps
|
|
531
506
|
}
|
|
532
507
|
};
|
|
533
508
|
}
|
|
509
|
+
function resolveFilesToDeleteAfterUpload(moduleOptions, shouldDeleteFilesFallback) {
|
|
510
|
+
const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server;
|
|
511
|
+
const fallbackFilesToDelete = [
|
|
512
|
+
...shouldDeleteFilesFallback?.client ? [".*/**/public/**/*.map"] : [],
|
|
513
|
+
...shouldDeleteFilesFallback?.server ? [".*/**/server/**/*.map", ".*/**/output/**/*.map", ".*/**/function/**/*.map"] : []
|
|
514
|
+
];
|
|
515
|
+
const filesToDeleteAfterUpload = moduleOptions.sourcemaps?.filesToDeleteAfterUpload;
|
|
516
|
+
if (typeof filesToDeleteAfterUpload === "undefined" && shouldDeleteFilesAfterUpload && moduleOptions.debug) {
|
|
517
|
+
console.log(
|
|
518
|
+
`[Sentry] Setting \`sentry.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete.map((path) => `"${path}"`).join(", ")}]\` to delete generated source maps after they were uploaded to Sentry.`
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
return filesToDeleteAfterUpload ? filesToDeleteAfterUpload : shouldDeleteFilesAfterUpload ? fallbackFilesToDelete : void 0;
|
|
522
|
+
}
|
|
534
523
|
function extractNuxtSourceMapSetting(nuxt, runtime) {
|
|
535
524
|
if (!runtime) {
|
|
536
525
|
return void 0;
|
|
@@ -718,10 +707,8 @@ var module$1 = defineNuxtModule({
|
|
|
718
707
|
const isNitroV3 = await getNitroMajorVersion() >= 3;
|
|
719
708
|
const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
|
|
720
709
|
const isMinNuxtV4 = nuxtMajor >= 4;
|
|
710
|
+
setupOrchestrion(nuxt, !!serverConfigFile, moduleOptions.buildTimeInstrumentation);
|
|
721
711
|
if (serverConfigFile) {
|
|
722
|
-
if (moduleOptions._experimental?.useDiagnosticsChannelInjection) {
|
|
723
|
-
setupOrchestrion(nuxt);
|
|
724
|
-
}
|
|
725
712
|
if (isNitroV3) {
|
|
726
713
|
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler.server"));
|
|
727
714
|
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/update-route-name.server"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getActiveSpan, getRootSpan,
|
|
1
|
+
import { getActiveSpan, getRootSpan, isObjectLike, debug } from '@sentry/core';
|
|
2
|
+
import { setHttpServerSpanRouteAttribute } from '@sentry/server-utils';
|
|
2
3
|
|
|
3
4
|
function getMatchedRoutePath(event) {
|
|
4
5
|
const matchedRoute = event.context.matchedRoute;
|
|
@@ -14,6 +15,7 @@ function updateRouteBeforeResponse(event) {
|
|
|
14
15
|
if (matchedRoutePath === "/**") {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
18
|
+
setHttpServerSpanRouteAttribute(matchedRoutePath);
|
|
17
19
|
const activeSpan = getActiveSpan();
|
|
18
20
|
if (!activeSpan) {
|
|
19
21
|
return;
|
|
@@ -22,10 +24,6 @@ function updateRouteBeforeResponse(event) {
|
|
|
22
24
|
if (!rootSpan) {
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
rootSpan.setAttributes({
|
|
26
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
|
|
27
|
-
"http.route": matchedRoutePath
|
|
28
|
-
});
|
|
29
27
|
const params = event.context?.params;
|
|
30
28
|
if (isObjectLike(params)) {
|
|
31
29
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SENTRY_OP } from '@sentry/conventions/attributes';
|
|
2
|
+
import { WEB_SERVER_MIDDLEWARE_SPAN_OP } from '@sentry/conventions/op';
|
|
3
|
+
import { debug, getClient, httpHeadersToSpanAttributes, startSpan, SPAN_STATUS_OK, SPAN_STATUS_ERROR, captureException, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, flushIfServerless, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
|
|
2
4
|
|
|
3
5
|
function wrapMiddlewareHandlerWithSentry(handler, fileName) {
|
|
4
6
|
if (!isEventHandlerObject(handler)) {
|
|
@@ -72,7 +74,7 @@ function normalizeHandlers(handlers, normalizer) {
|
|
|
72
74
|
}
|
|
73
75
|
function getSpanAttributes(event, middlewareName, hookName, index) {
|
|
74
76
|
const attributes = {
|
|
75
|
-
[
|
|
77
|
+
[SENTRY_OP]: WEB_SERVER_MIDDLEWARE_SPAN_OP,
|
|
76
78
|
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "custom",
|
|
77
79
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.middleware.nuxt",
|
|
78
80
|
"nuxt.middleware.name": middlewareName,
|
|
@@ -94,8 +96,10 @@ function getSpanAttributes(event, middlewareName, hookName, index) {
|
|
|
94
96
|
if (!Object.keys(headers).length && eventH3v2?.req?.headers instanceof Headers) {
|
|
95
97
|
headers = Object.fromEntries(eventH3v2?.req.headers.entries());
|
|
96
98
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
+
const client = getClient();
|
|
100
|
+
if (client) {
|
|
101
|
+
Object.assign(attributes, httpHeadersToSpanAttributes(headers, client.getDataCollectionOptions()));
|
|
102
|
+
}
|
|
99
103
|
return attributes;
|
|
100
104
|
}
|
|
101
105
|
function isEventHandlerObject(handler) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { debug
|
|
1
|
+
import { debug } from '@sentry/core';
|
|
2
2
|
import { defineNuxtPlugin } from 'nuxt/app';
|
|
3
3
|
import { extractParametrizedRouteFromContext } from '../utils/route-extraction.js';
|
|
4
|
+
import { setHttpServerSpanRouteAttribute } from '@sentry/server-utils';
|
|
4
5
|
|
|
5
6
|
var routeDetectorLegacy_server = defineNuxtPlugin((nuxtApp) => {
|
|
6
7
|
nuxtApp.hooks.hook("app:rendered", async (renderContext) => {
|
|
@@ -22,17 +23,8 @@ var routeDetectorLegacy_server = defineNuxtPlugin((nuxtApp) => {
|
|
|
22
23
|
if (routeInfo === null) {
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const rootSpan = getRootSpan(activeSpan);
|
|
28
|
-
if (!rootSpan) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
debug.log("Matched parametrized server route:", routeInfo.parametrizedRoute);
|
|
32
|
-
rootSpan.setAttributes({
|
|
33
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
|
|
34
|
-
"http.route": routeInfo.parametrizedRoute
|
|
35
|
-
});
|
|
26
|
+
if (routeInfo.parametrizedRoute) {
|
|
27
|
+
setHttpServerSpanRouteAttribute(routeInfo.parametrizedRoute);
|
|
36
28
|
}
|
|
37
29
|
});
|
|
38
30
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { debug
|
|
1
|
+
import { debug } from '@sentry/core';
|
|
2
2
|
import { defineNuxtPlugin } from 'nuxt/app';
|
|
3
3
|
import { extractParametrizedRouteFromContext } from '../utils/route-extraction.js';
|
|
4
|
+
import { setHttpServerSpanRouteAttribute } from '@sentry/server-utils';
|
|
4
5
|
|
|
5
6
|
var routeDetector_server = defineNuxtPlugin((nuxtApp) => {
|
|
6
7
|
nuxtApp.hooks.hook("app:rendered", async (renderContext) => {
|
|
@@ -22,18 +23,7 @@ var routeDetector_server = defineNuxtPlugin((nuxtApp) => {
|
|
|
22
23
|
if (routeInfo === null) {
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
if (activeSpan && routeInfo.parametrizedRoute) {
|
|
27
|
-
const rootSpan = getRootSpan(activeSpan);
|
|
28
|
-
if (!rootSpan) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
debug.log("Matched parametrized server route:", routeInfo.parametrizedRoute);
|
|
32
|
-
rootSpan.setAttributes({
|
|
33
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
|
|
34
|
-
"http.route": routeInfo.parametrizedRoute
|
|
35
|
-
});
|
|
36
|
-
}
|
|
26
|
+
setHttpServerSpanRouteAttribute(routeInfo.parametrizedRoute);
|
|
37
27
|
});
|
|
38
28
|
});
|
|
39
29
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { setAsyncLocalStorageAsyncContextStrategy,
|
|
1
|
+
import { setAsyncLocalStorageAsyncContextStrategy, getDefaultIntegrations } from '@sentry/cloudflare';
|
|
2
|
+
import { wrapRequestHandler } from '@sentry/cloudflare/request';
|
|
2
3
|
import { debug, getIsolationScope, getDefaultIsolationScope, getTraceData } from '@sentry/core';
|
|
3
4
|
import { sentryCaptureErrorHook } from '../hooks/captureErrorHook.js';
|
|
4
5
|
import { updateRouteBeforeResponse } from '../hooks/updateRouteBeforeResponse.js';
|
|
@@ -25,7 +26,9 @@ const sentryCloudflareNitroPlugin = (optionsOrFn) => (nitroApp) => {
|
|
|
25
26
|
cf: getCfProperties(event)
|
|
26
27
|
});
|
|
27
28
|
const requestHandlerOptions = {
|
|
28
|
-
|
|
29
|
+
// `wrapRequestHandler` only sets up the integrations that work without `nodejs_compat`.
|
|
30
|
+
// Nitro's Cloudflare presets require the flag anyway, so opt into the full set.
|
|
31
|
+
options: { defaultIntegrations: getDefaultIntegrations(cloudflareOptions), ...cloudflareOptions },
|
|
29
32
|
request,
|
|
30
33
|
context: getCloudflareProperties(event).context
|
|
31
34
|
};
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SENTRY_OP } from '@sentry/conventions/attributes';
|
|
2
|
+
import { DATABASE_CACHE_REMOVE_SPAN_OP, DATABASE_CACHE_PUT_SPAN_OP, DATABASE_CACHE_GET_SPAN_OP } from '@sentry/conventions/op';
|
|
3
|
+
import { debug, startSpan, SPAN_STATUS_OK, SEMANTIC_ATTRIBUTE_CACHE_HIT, SPAN_STATUS_ERROR, captureException, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, flushIfServerless, SEMANTIC_ATTRIBUTE_CACHE_KEY, isObjectLike } from '@sentry/core';
|
|
2
4
|
|
|
3
|
-
const CACHE_HIT_METHODS = /* @__PURE__ */ new Set(["hasItem", "getItem", "getItemRaw"]);
|
|
5
|
+
const CACHE_HIT_METHODS = /* @__PURE__ */ new Set(["hasItem", "getItem", "getItemRaw", "getItems"]);
|
|
6
|
+
const METHOD_SPAN_OPS = {
|
|
7
|
+
hasItem: DATABASE_CACHE_GET_SPAN_OP,
|
|
8
|
+
getItem: DATABASE_CACHE_GET_SPAN_OP,
|
|
9
|
+
getItemRaw: DATABASE_CACHE_GET_SPAN_OP,
|
|
10
|
+
getItems: DATABASE_CACHE_GET_SPAN_OP,
|
|
11
|
+
getKeys: DATABASE_CACHE_GET_SPAN_OP,
|
|
12
|
+
setItem: DATABASE_CACHE_PUT_SPAN_OP,
|
|
13
|
+
setItemRaw: DATABASE_CACHE_PUT_SPAN_OP,
|
|
14
|
+
setItems: DATABASE_CACHE_PUT_SPAN_OP,
|
|
15
|
+
removeItem: DATABASE_CACHE_REMOVE_SPAN_OP,
|
|
16
|
+
clear: DATABASE_CACHE_REMOVE_SPAN_OP
|
|
17
|
+
};
|
|
4
18
|
async function createStoragePlugin(useStorage, userStorageMounts) {
|
|
5
19
|
const storage = useStorage();
|
|
6
20
|
const userMounts = new Set(userStorageMounts.map((m) => `${m}:`));
|
|
@@ -54,7 +68,7 @@ function createMethodWrapper(original, methodName, driver, mountBase) {
|
|
|
54
68
|
const result = await target.apply(thisArg, args);
|
|
55
69
|
span.setStatus({ code: SPAN_STATUS_OK });
|
|
56
70
|
if (CACHE_HIT_METHODS.has(methodName)) {
|
|
57
|
-
span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT,
|
|
71
|
+
span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT, resolveCacheHit(methodName, args[0], result));
|
|
58
72
|
}
|
|
59
73
|
return result;
|
|
60
74
|
} catch (error) {
|
|
@@ -86,13 +100,10 @@ function wrapStorageMount(storage) {
|
|
|
86
100
|
mountWithInstrumentation.__sentry_instrumented__ = true;
|
|
87
101
|
return mountWithInstrumentation;
|
|
88
102
|
}
|
|
89
|
-
function normalizeMethodName(methodName) {
|
|
90
|
-
return methodName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
91
|
-
}
|
|
92
103
|
function createSpanStartOptions(methodName, driver, mountBase, args) {
|
|
93
104
|
const keys = getCacheKeys(args?.[0], mountBase);
|
|
94
105
|
const attributes = {
|
|
95
|
-
[
|
|
106
|
+
[SENTRY_OP]: METHOD_SPAN_OPS[methodName],
|
|
96
107
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.cache.nuxt",
|
|
97
108
|
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: keys.length > 1 ? keys : keys[0],
|
|
98
109
|
"db.operation.name": methodName,
|
|
@@ -120,6 +131,15 @@ function normalizeKey(key, prefix) {
|
|
|
120
131
|
return `${prefix}${key == null ? "" : String(key)}`;
|
|
121
132
|
}
|
|
122
133
|
const CACHED_FN_HANDLERS_RE = /^nitro:(functions|handlers):/i;
|
|
134
|
+
function resolveCacheHit(methodName, key, result) {
|
|
135
|
+
if (methodName === "hasItem") {
|
|
136
|
+
return Boolean(result);
|
|
137
|
+
}
|
|
138
|
+
if (methodName === "getItems") {
|
|
139
|
+
return Array.isArray(result) && result.some((item) => isObjectLike(item) && item.value != null);
|
|
140
|
+
}
|
|
141
|
+
return isCacheHit(key, result);
|
|
142
|
+
}
|
|
123
143
|
function isCacheHit(key, value) {
|
|
124
144
|
try {
|
|
125
145
|
const isEmpty = value == null;
|
|
@@ -16,7 +16,7 @@ export declare function addSentryTopImport(moduleOptions: SentryNuxtModuleOption
|
|
|
16
16
|
* This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)
|
|
17
17
|
* and adds the Sentry server config with the static `import` declaration.
|
|
18
18
|
*
|
|
19
|
-
* With this, the Sentry server config can be loaded before all other modules of the application
|
|
19
|
+
* With this, the Sentry server config can be loaded before all other modules of the application.
|
|
20
20
|
* See: https://nodejs.org/api/module.html#enabling
|
|
21
21
|
*/
|
|
22
22
|
export declare function addDynamicImportEntryFileWrapper(nitro: Nitro, serverConfigFile: string, moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> & Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>): void;
|
|
@@ -2,5 +2,10 @@ import type { Nuxt } from '@nuxt/schema';
|
|
|
2
2
|
/**
|
|
3
3
|
* Configures Nitro to bundle and transform dependencies that publish tracing
|
|
4
4
|
* events through diagnostics channels.
|
|
5
|
+
*
|
|
6
|
+
* `hasServerConfig` reflects whether a `sentry.server.config` file was found. On Node the SDK is
|
|
7
|
+
* initialized from that file, so orchestrion only makes sense when it exists. On Cloudflare the SDK
|
|
8
|
+
* is initialized through `sentryCloudflareNitroPlugin` instead (no server config file), so the
|
|
9
|
+
* transform must still run there — detected via the Nitro preset.
|
|
5
10
|
*/
|
|
6
|
-
export declare function setupOrchestrion(nuxt: Nuxt): void;
|
|
11
|
+
export declare function setupOrchestrion(nuxt: Nuxt, hasServerConfig: boolean, buildTimeInstrumentation?: boolean): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Nuxt } from '@nuxt/schema';
|
|
2
|
-
import { type SentryRollupPluginOptions } from '@sentry/rollup
|
|
3
|
-
import { type SentryVitePluginOptions } from '@sentry/vite
|
|
2
|
+
import { type SentryRollupPluginOptions } from '@sentry/bundler-plugins/rollup';
|
|
3
|
+
import { type SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';
|
|
4
4
|
import type { NitroConfig } from 'nitropack';
|
|
5
5
|
import type { Plugin } from 'vite';
|
|
6
6
|
import type { SentryNuxtModuleOptions } from '../common/types';
|