@sentry/nuxt 8.20.0 → 8.21.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/README.md CHANGED
@@ -126,18 +126,6 @@ other imports:
126
126
  }
127
127
  ```
128
128
 
129
- If you are getting an `import-in-the-middle` error message, add the package with a minimum version of `1.10.0` as a
130
- dependency to your `package.json`
131
- ([issue reference](https://github.com/getsentry/sentry-javascript-examples/pull/38#issuecomment-2245259327)):
132
-
133
- ```json
134
- {
135
- "dependencies": {
136
- "import-in-the-middle": "1.10.0"
137
- }
138
- }
139
- ```
140
-
141
129
  ## Uploading Source Maps
142
130
 
143
131
  To upload source maps, you can use the `sourceMapsUploadOptions` option inside the `sentry` options of your
@@ -10,7 +10,8 @@ const core = require('@sentry/core');
10
10
  */
11
11
  function init(options) {
12
12
  const sentryOptions = {
13
- defaultIntegrations: [...browser.getDefaultIntegrations(options), browser.browserTracingIntegration()],
13
+ /* BrowserTracing is added later with the Nuxt client plugin */
14
+ defaultIntegrations: [...browser.getDefaultIntegrations(options)],
14
15
  ...options,
15
16
  };
16
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import {\n browserTracingIntegration,\n getDefaultIntegrations as getBrowserDefaultIntegrations,\n init as initBrowser,\n} from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/types';\nimport type { SentryNuxtOptions } from '../common/types';\n\n/**\n * Initializes the client-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtOptions): Client | undefined {\n const sentryOptions = {\n defaultIntegrations: [...getBrowserDefaultIntegrations(options), browserTracingIntegration()],\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'vue']);\n\n return initBrowser(sentryOptions);\n}\n"],"names":["getBrowserDefaultIntegrations","browserTracingIntegration","applySdkMetadata","initBrowser"],"mappings":";;;;;AASA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAyC;AACrE,EAAE,MAAM,gBAAgB;AACxB,IAAI,mBAAmB,EAAE,CAAC,GAAGA,8BAA6B,CAAC,OAAO,CAAC,EAAEC,iCAAyB,EAAE,CAAC;AACjG,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAEC,qBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1D;AACA,EAAE,OAAOC,YAAW,CAAC,aAAa,CAAC,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowser } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/types';\nimport type { SentryNuxtOptions } from '../common/types';\n\n/**\n * Initializes the client-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtOptions): Client | undefined {\n const sentryOptions = {\n /* BrowserTracing is added later with the Nuxt client plugin */\n defaultIntegrations: [...getBrowserDefaultIntegrations(options)],\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'vue']);\n\n return initBrowser(sentryOptions);\n}\n"],"names":["getBrowserDefaultIntegrations","applySdkMetadata","initBrowser"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAyC;AACrE,EAAE,MAAM,gBAAgB;AACxB;AACA,IAAI,mBAAmB,EAAE,CAAC,GAAGA,8BAA6B,CAAC,OAAO,CAAC,CAAC;AACpE,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAEC,qBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1D;AACA,EAAE,OAAOC,YAAW,CAAC,aAAa,CAAC,CAAA;AACnC;;;;"}
@@ -1,4 +1,4 @@
1
- import { getDefaultIntegrations, browserTracingIntegration, init as init$1 } from '@sentry/browser';
1
+ import { getDefaultIntegrations, init as init$1 } from '@sentry/browser';
2
2
  import { applySdkMetadata } from '@sentry/core';
3
3
 
4
4
  /**
@@ -8,7 +8,8 @@ import { applySdkMetadata } from '@sentry/core';
8
8
  */
9
9
  function init(options) {
10
10
  const sentryOptions = {
11
- defaultIntegrations: [...getDefaultIntegrations(options), browserTracingIntegration()],
11
+ /* BrowserTracing is added later with the Nuxt client plugin */
12
+ defaultIntegrations: [...getDefaultIntegrations(options)],
12
13
  ...options,
13
14
  };
14
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import {\n browserTracingIntegration,\n getDefaultIntegrations as getBrowserDefaultIntegrations,\n init as initBrowser,\n} from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/types';\nimport type { SentryNuxtOptions } from '../common/types';\n\n/**\n * Initializes the client-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtOptions): Client | undefined {\n const sentryOptions = {\n defaultIntegrations: [...getBrowserDefaultIntegrations(options), browserTracingIntegration()],\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'vue']);\n\n return initBrowser(sentryOptions);\n}\n"],"names":["getBrowserDefaultIntegrations","initBrowser"],"mappings":";;;AASA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAyC;AACrE,EAAE,MAAM,gBAAgB;AACxB,IAAI,mBAAmB,EAAE,CAAC,GAAGA,sBAA6B,CAAC,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;AACjG,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAE,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1D;AACA,EAAE,OAAOC,MAAW,CAAC,aAAa,CAAC,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowser } from '@sentry/browser';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { Client } from '@sentry/types';\nimport type { SentryNuxtOptions } from '../common/types';\n\n/**\n * Initializes the client-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtOptions): Client | undefined {\n const sentryOptions = {\n /* BrowserTracing is added later with the Nuxt client plugin */\n defaultIntegrations: [...getBrowserDefaultIntegrations(options)],\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'vue']);\n\n return initBrowser(sentryOptions);\n}\n"],"names":["getBrowserDefaultIntegrations","initBrowser"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAyC;AACrE,EAAE,MAAM,gBAAgB;AACxB;AACA,IAAI,mBAAmB,EAAE,CAAC,GAAGA,sBAA6B,CAAC,OAAO,CAAC,CAAC;AACpE,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAE,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAC1D;AACA,EAAE,OAAOC,MAAW,CAAC,aAAa,CAAC,CAAA;AACnC;;;;"}
@@ -2,85 +2,84 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  type SourceMapsOptions = {
4
4
  /**
5
- * Options for the Sentry Vite plugin to customize the source maps upload process.
5
+ * If this flag is `true`, and an auth token is detected, the Sentry SDK will
6
+ * automatically generate and upload source maps to Sentry during a production build.
6
7
  *
7
- * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
8
- * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
8
+ * @default true
9
+ */
10
+ enabled?: boolean;
11
+ /**
12
+ * The auth token to use when uploading source maps to Sentry.
13
+ *
14
+ * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
15
+ *
16
+ * To create an auth token, follow this guide:
17
+ * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
18
+ */
19
+ authToken?: string;
20
+ /**
21
+ * The organization slug of your Sentry organization.
22
+ * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
23
+ */
24
+ org?: string;
25
+ /**
26
+ * The project slug of your Sentry project.
27
+ * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
28
+ */
29
+ project?: string;
30
+ /**
31
+ * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
32
+ * It will not collect any sensitive or user-specific data.
33
+ *
34
+ * @default true
35
+ */
36
+ telemetry?: boolean;
37
+ /**
38
+ * Options related to sourcemaps
9
39
  */
10
- sourceMapsUploadOptions?: {
40
+ sourcemaps?: {
11
41
  /**
12
- * If this flag is `true`, and an auth token is detected, the Sentry integration will
13
- * automatically generate and upload source maps to Sentry during a production build.
42
+ * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
43
+ *
44
+ * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
45
+ * setup will be used. Use this option to override these defaults, for instance if you have a
46
+ * customized build setup that diverges from Nuxt's defaults.
14
47
  *
15
- * @default true
48
+ * The globbing patterns must follow the implementation of the `glob` package.
49
+ * @see https://www.npmjs.com/package/glob#glob-primer
16
50
  */
17
- enabled?: boolean;
51
+ assets?: string | Array<string>;
18
52
  /**
19
- * The auth token to use when uploading source maps to Sentry.
53
+ * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
20
54
  *
21
- * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
55
+ * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
56
+ * or the default value for `assets` are uploaded.
22
57
  *
23
- * To create an auth token, follow this guide:
24
- * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
25
- */
26
- authToken?: string;
27
- /**
28
- * The organization slug of your Sentry organization.
29
- * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
58
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
30
59
  */
31
- org?: string;
60
+ ignore?: string | Array<string>;
32
61
  /**
33
- * The project slug of your Sentry project.
34
- * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
35
- */
36
- project?: string;
37
- /**
38
- * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
39
- * It will not collect any sensitive or user-specific data.
62
+ * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
63
+ * upload to Sentry has been completed.
40
64
  *
41
- * @default true
42
- */
43
- telemetry?: boolean;
44
- /**
45
- * Options related to sourcemaps
65
+ * @default [] - By default no files are deleted.
66
+ *
67
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
46
68
  */
47
- sourcemaps?: {
48
- /**
49
- * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
50
- *
51
- * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
52
- * setup will be used. Use this option to override these defaults, for instance if you have a
53
- * customized build setup that diverges from Nuxt's defaults.
54
- *
55
- * The globbing patterns must follow the implementation of the `glob` package.
56
- * @see https://www.npmjs.com/package/glob#glob-primer
57
- */
58
- assets?: string | Array<string>;
59
- /**
60
- * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
61
- *
62
- * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
63
- * or the default value for `assets` are uploaded.
64
- *
65
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
66
- */
67
- ignore?: string | Array<string>;
68
- /**
69
- * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
70
- * upload to Sentry has been completed.
71
- *
72
- * @default [] - By default no files are deleted.
73
- *
74
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
75
- */
76
- filesToDeleteAfterUpload?: string | Array<string>;
77
- };
69
+ filesToDeleteAfterUpload?: string | Array<string>;
78
70
  };
79
71
  };
80
72
  /**
81
73
  * Build options for the Sentry module. These options are used during build-time by the Sentry SDK.
82
74
  */
83
- type SentryNuxtModuleOptions = SourceMapsOptions & {
75
+ type SentryNuxtModuleOptions = {
76
+ /**
77
+ * Options for the Sentry Vite plugin to customize the source maps upload process.
78
+ *
79
+ * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
80
+ * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
81
+ */
82
+ sourceMapsUploadOptions?: SourceMapsOptions;
84
83
  /**
85
84
  * Enable debug functionality of the SDK during build-time.
86
85
  * Enabling this will give you, for example, logs about source maps.
@@ -2,85 +2,84 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  type SourceMapsOptions = {
4
4
  /**
5
- * Options for the Sentry Vite plugin to customize the source maps upload process.
5
+ * If this flag is `true`, and an auth token is detected, the Sentry SDK will
6
+ * automatically generate and upload source maps to Sentry during a production build.
6
7
  *
7
- * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
8
- * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
8
+ * @default true
9
+ */
10
+ enabled?: boolean;
11
+ /**
12
+ * The auth token to use when uploading source maps to Sentry.
13
+ *
14
+ * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
15
+ *
16
+ * To create an auth token, follow this guide:
17
+ * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
18
+ */
19
+ authToken?: string;
20
+ /**
21
+ * The organization slug of your Sentry organization.
22
+ * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
23
+ */
24
+ org?: string;
25
+ /**
26
+ * The project slug of your Sentry project.
27
+ * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
28
+ */
29
+ project?: string;
30
+ /**
31
+ * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
32
+ * It will not collect any sensitive or user-specific data.
33
+ *
34
+ * @default true
35
+ */
36
+ telemetry?: boolean;
37
+ /**
38
+ * Options related to sourcemaps
9
39
  */
10
- sourceMapsUploadOptions?: {
40
+ sourcemaps?: {
11
41
  /**
12
- * If this flag is `true`, and an auth token is detected, the Sentry integration will
13
- * automatically generate and upload source maps to Sentry during a production build.
42
+ * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
43
+ *
44
+ * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
45
+ * setup will be used. Use this option to override these defaults, for instance if you have a
46
+ * customized build setup that diverges from Nuxt's defaults.
14
47
  *
15
- * @default true
48
+ * The globbing patterns must follow the implementation of the `glob` package.
49
+ * @see https://www.npmjs.com/package/glob#glob-primer
16
50
  */
17
- enabled?: boolean;
51
+ assets?: string | Array<string>;
18
52
  /**
19
- * The auth token to use when uploading source maps to Sentry.
53
+ * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
20
54
  *
21
- * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
55
+ * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
56
+ * or the default value for `assets` are uploaded.
22
57
  *
23
- * To create an auth token, follow this guide:
24
- * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
25
- */
26
- authToken?: string;
27
- /**
28
- * The organization slug of your Sentry organization.
29
- * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
58
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
30
59
  */
31
- org?: string;
60
+ ignore?: string | Array<string>;
32
61
  /**
33
- * The project slug of your Sentry project.
34
- * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
35
- */
36
- project?: string;
37
- /**
38
- * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
39
- * It will not collect any sensitive or user-specific data.
62
+ * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
63
+ * upload to Sentry has been completed.
40
64
  *
41
- * @default true
42
- */
43
- telemetry?: boolean;
44
- /**
45
- * Options related to sourcemaps
65
+ * @default [] - By default no files are deleted.
66
+ *
67
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
46
68
  */
47
- sourcemaps?: {
48
- /**
49
- * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
50
- *
51
- * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
52
- * setup will be used. Use this option to override these defaults, for instance if you have a
53
- * customized build setup that diverges from Nuxt's defaults.
54
- *
55
- * The globbing patterns must follow the implementation of the `glob` package.
56
- * @see https://www.npmjs.com/package/glob#glob-primer
57
- */
58
- assets?: string | Array<string>;
59
- /**
60
- * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
61
- *
62
- * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
63
- * or the default value for `assets` are uploaded.
64
- *
65
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
66
- */
67
- ignore?: string | Array<string>;
68
- /**
69
- * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
70
- * upload to Sentry has been completed.
71
- *
72
- * @default [] - By default no files are deleted.
73
- *
74
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
75
- */
76
- filesToDeleteAfterUpload?: string | Array<string>;
77
- };
69
+ filesToDeleteAfterUpload?: string | Array<string>;
78
70
  };
79
71
  };
80
72
  /**
81
73
  * Build options for the Sentry module. These options are used during build-time by the Sentry SDK.
82
74
  */
83
- type SentryNuxtModuleOptions = SourceMapsOptions & {
75
+ type SentryNuxtModuleOptions = {
76
+ /**
77
+ * Options for the Sentry Vite plugin to customize the source maps upload process.
78
+ *
79
+ * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
80
+ * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
81
+ */
82
+ sourceMapsUploadOptions?: SourceMapsOptions;
84
83
  /**
85
84
  * Enable debug functionality of the SDK during build-time.
86
85
  * Enabling this will give you, for example, logs about source maps.
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "8.20.0",
7
+ "version": "8.21.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.0",
10
10
  "unbuild": "2.0.0"
@@ -82,7 +82,11 @@ export default defineNuxtPlugin(() => {})`
82
82
  function findDefaultSdkInitFile(type) {
83
83
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
84
84
  const cwd = process.cwd();
85
- const filePath = possibleFileExtensions.map((e) => path.resolve(path.join(cwd, `sentry.${type}.config.${e}`))).find((filename) => fs.existsSync(filename));
85
+ const filePath = possibleFileExtensions.map(
86
+ (e) => path.resolve(
87
+ type === "server" ? path.join(cwd, "public", `instrument.${type}.${e}`) : path.join(cwd, `sentry.${type}.config.${e}`)
88
+ )
89
+ ).find((filename) => fs.existsSync(filename));
86
90
  return filePath ? path.basename(filePath) : void 0;
87
91
  }
88
92
 
@@ -1,7 +1,15 @@
1
1
  import { getClient } from "@sentry/core";
2
- import { vueIntegration } from "@sentry/vue";
2
+ import { browserTracingIntegration, vueIntegration } from "@sentry/vue";
3
3
  import { defineNuxtPlugin } from "nuxt/app";
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
+ if (typeof __SENTRY_TRACING__ === "undefined" || __SENTRY_TRACING__) {
6
+ const sentryClient = getClient();
7
+ if (sentryClient && "$router" in nuxtApp) {
8
+ sentryClient.addIntegration(
9
+ browserTracingIntegration({ router: nuxtApp.$router, routeLabel: "path" })
10
+ );
11
+ }
12
+ }
5
13
  nuxtApp.hook("app:created", (vueApp) => {
6
14
  const sentryClient = getClient();
7
15
  if (sentryClient) {
@@ -1,7 +1,7 @@
1
1
  import { captureException } from "@sentry/node";
2
2
  import { H3Error } from "h3";
3
3
  import { defineNitroPlugin } from "nitropack/runtime";
4
- import { extractErrorContext } from "../utils.js";
4
+ import { addSentryTracingMetaTags, extractErrorContext } from "../utils.js";
5
5
  export default defineNitroPlugin((nitroApp) => {
6
6
  nitroApp.hooks.hook("error", (error, errorContext) => {
7
7
  if (error instanceof H3Error) {
@@ -15,4 +15,7 @@ export default defineNitroPlugin((nitroApp) => {
15
15
  mechanism: { handled: false }
16
16
  });
17
17
  });
18
+ nitroApp.hooks.hook("render:html", (html) => {
19
+ addSentryTracingMetaTags(html.head);
20
+ });
18
21
  });
@@ -1,4 +1,7 @@
1
+ import { getActiveSpan, getRootSpan, spanToTraceHeader } from "@sentry/core";
2
+ import { getDynamicSamplingContextFromSpan } from "@sentry/opentelemetry";
1
3
  import { dropUndefinedKeys } from "@sentry/utils";
4
+ import { dynamicSamplingContextToSentryBaggageHeader } from "@sentry/utils";
2
5
  export function extractErrorContext(errorContext) {
3
6
  const structuredContext = {
4
7
  method: void 0,
@@ -16,3 +19,15 @@ export function extractErrorContext(errorContext) {
16
19
  }
17
20
  return dropUndefinedKeys(structuredContext);
18
21
  }
22
+ export function addSentryTracingMetaTags(head) {
23
+ const activeSpan = getActiveSpan();
24
+ const rootSpan = activeSpan ? getRootSpan(activeSpan) : void 0;
25
+ if (rootSpan) {
26
+ const traceParentData = spanToTraceHeader(rootSpan);
27
+ const dynamicSamplingContext = dynamicSamplingContextToSentryBaggageHeader(
28
+ getDynamicSamplingContextFromSpan(rootSpan)
29
+ );
30
+ head.push(`<meta name="sentry-trace" content="${traceParentData}"/>`);
31
+ head.push(`<meta name="baggage" content="${dynamicSamplingContext}"/>`);
32
+ }
33
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/client/sdk.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CASnE"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/client/sdk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAUnE"}
@@ -2,85 +2,84 @@ import type { init } from '@sentry/vue';
2
2
  export type SentryNuxtOptions = Omit<Parameters<typeof init>[0] & object, 'app'>;
3
3
  type SourceMapsOptions = {
4
4
  /**
5
- * Options for the Sentry Vite plugin to customize the source maps upload process.
5
+ * If this flag is `true`, and an auth token is detected, the Sentry SDK will
6
+ * automatically generate and upload source maps to Sentry during a production build.
6
7
  *
7
- * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
8
- * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
8
+ * @default true
9
+ */
10
+ enabled?: boolean;
11
+ /**
12
+ * The auth token to use when uploading source maps to Sentry.
13
+ *
14
+ * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
15
+ *
16
+ * To create an auth token, follow this guide:
17
+ * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
18
+ */
19
+ authToken?: string;
20
+ /**
21
+ * The organization slug of your Sentry organization.
22
+ * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
23
+ */
24
+ org?: string;
25
+ /**
26
+ * The project slug of your Sentry project.
27
+ * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
28
+ */
29
+ project?: string;
30
+ /**
31
+ * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
32
+ * It will not collect any sensitive or user-specific data.
33
+ *
34
+ * @default true
35
+ */
36
+ telemetry?: boolean;
37
+ /**
38
+ * Options related to sourcemaps
9
39
  */
10
- sourceMapsUploadOptions?: {
40
+ sourcemaps?: {
11
41
  /**
12
- * If this flag is `true`, and an auth token is detected, the Sentry integration will
13
- * automatically generate and upload source maps to Sentry during a production build.
42
+ * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
43
+ *
44
+ * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
45
+ * setup will be used. Use this option to override these defaults, for instance if you have a
46
+ * customized build setup that diverges from Nuxt's defaults.
14
47
  *
15
- * @default true
48
+ * The globbing patterns must follow the implementation of the `glob` package.
49
+ * @see https://www.npmjs.com/package/glob#glob-primer
16
50
  */
17
- enabled?: boolean;
51
+ assets?: string | Array<string>;
18
52
  /**
19
- * The auth token to use when uploading source maps to Sentry.
53
+ * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
20
54
  *
21
- * Instead of specifying this option, you can also set the `SENTRY_AUTH_TOKEN` environment variable.
55
+ * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
56
+ * or the default value for `assets` are uploaded.
22
57
  *
23
- * To create an auth token, follow this guide:
24
- * @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens
25
- */
26
- authToken?: string;
27
- /**
28
- * The organization slug of your Sentry organization.
29
- * Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable.
58
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
30
59
  */
31
- org?: string;
60
+ ignore?: string | Array<string>;
32
61
  /**
33
- * The project slug of your Sentry project.
34
- * Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable.
35
- */
36
- project?: string;
37
- /**
38
- * If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
39
- * It will not collect any sensitive or user-specific data.
62
+ * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
63
+ * upload to Sentry has been completed.
40
64
  *
41
- * @default true
42
- */
43
- telemetry?: boolean;
44
- /**
45
- * Options related to sourcemaps
65
+ * @default [] - By default no files are deleted.
66
+ *
67
+ * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
46
68
  */
47
- sourcemaps?: {
48
- /**
49
- * A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
50
- *
51
- * If this option is not specified, sensible defaults based on your adapter and nuxt.config.js
52
- * setup will be used. Use this option to override these defaults, for instance if you have a
53
- * customized build setup that diverges from Nuxt's defaults.
54
- *
55
- * The globbing patterns must follow the implementation of the `glob` package.
56
- * @see https://www.npmjs.com/package/glob#glob-primer
57
- */
58
- assets?: string | Array<string>;
59
- /**
60
- * A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
61
- *
62
- * @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
63
- * or the default value for `assets` are uploaded.
64
- *
65
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
66
- */
67
- ignore?: string | Array<string>;
68
- /**
69
- * A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
70
- * upload to Sentry has been completed.
71
- *
72
- * @default [] - By default no files are deleted.
73
- *
74
- * The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
75
- */
76
- filesToDeleteAfterUpload?: string | Array<string>;
77
- };
69
+ filesToDeleteAfterUpload?: string | Array<string>;
78
70
  };
79
71
  };
80
72
  /**
81
73
  * Build options for the Sentry module. These options are used during build-time by the Sentry SDK.
82
74
  */
83
- export type SentryNuxtModuleOptions = SourceMapsOptions & {
75
+ export type SentryNuxtModuleOptions = {
76
+ /**
77
+ * Options for the Sentry Vite plugin to customize the source maps upload process.
78
+ *
79
+ * These options are always read from the `sentry` module options in the `nuxt.config.(js|ts).
80
+ * Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files.
81
+ */
82
+ sourceMapsUploadOptions?: SourceMapsOptions;
84
83
  /**
85
84
  * Enable debug functionality of the SDK during build-time.
86
85
  * Enabling this will give you, for example, logs about source maps.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjF,KAAK,iBAAiB,GAAG;IACvB;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE;QACxB;;;;;WAKG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAElB;;;;;;;WAOG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;;WAGG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;QAEb;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;;;;WAKG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QAEpB;;WAEG;QACH,UAAU,CAAC,EAAE;YACX;;;;;;;;;eASG;YACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAEhC;;;;;;;eAOG;YACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAEhC;;;;;;;eAOG;YACH,wBAAwB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;SACnD,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG;IACxD;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjF,KAAK,iBAAiB,GAAG;IACvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;;;;;;;;WASG;QACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAEhC;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAEhC;;;;;;;WAOG;QACH,wBAAwB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;KACnD,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,iBAAiB,CAAC;IAE5C;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.client.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.client.ts"],"names":[],"mappings":";AAIA,wBAQG"}
1
+ {"version":3,"file":"sentry.client.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.client.ts"],"names":[],"mappings":";AA+BA,wBAoBG"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AAKA,wBAiBG"}
1
+ {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AAMA,wBAsBG"}
@@ -1,8 +1,15 @@
1
1
  import type { Context } from '@sentry/types';
2
2
  import type { CapturedErrorContext } from 'nitropack';
3
+ import type { NuxtRenderHTMLContext } from 'nuxt/app';
3
4
  /**
4
5
  * Extracts the relevant context information from the error context (H3Event in Nitro Error)
5
6
  * and created a structured context object.
6
7
  */
7
8
  export declare function extractErrorContext(errorContext: CapturedErrorContext): Context;
9
+ /**
10
+ * Adds Sentry tracing <meta> tags to the returned html page.
11
+ *
12
+ * Exported only for testing
13
+ */
14
+ export declare function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head']): void;
8
15
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,GAAG,OAAO,CAmB/E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,GAAG,OAAO,CAmB/E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI,CAalF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/nuxt",
3
- "version": "8.20.0",
3
+ "version": "8.21.0",
4
4
  "description": "Official Sentry SDK for Nuxt (EXPERIMENTAL)",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
@@ -43,14 +43,14 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@nuxt/kit": "^3.12.2",
46
- "@sentry/browser": "8.20.0",
47
- "@sentry/core": "8.20.0",
48
- "@sentry/node": "8.20.0",
49
- "@sentry/opentelemetry": "8.20.0",
50
- "@sentry/types": "8.20.0",
51
- "@sentry/utils": "8.20.0",
46
+ "@sentry/browser": "8.21.0",
47
+ "@sentry/core": "8.21.0",
48
+ "@sentry/node": "8.21.0",
49
+ "@sentry/opentelemetry": "8.21.0",
50
+ "@sentry/types": "8.21.0",
51
+ "@sentry/utils": "8.21.0",
52
52
  "@sentry/vite-plugin": "2.20.1",
53
- "@sentry/vue": "8.20.0"
53
+ "@sentry/vue": "8.21.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@nuxt/module-builder": "0.8.0",