Skip to content

Commit 53bbeec

Browse files
authored
feat!: update Sentry SDK from v6 to v7 (#461)
BREAKING CHANGE: Refer to https://sentry.nuxtjs.org/guide/migration for migration guide.
1 parent adc7c9c commit 53bbeec

File tree

17 files changed

+1249
-2660
lines changed

17 files changed

+1249
-2660
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = {
2727
'@nuxtjs/eslint-config-typescript',
2828
],
2929
rules: {
30+
'comma-dangle': 'off',
3031
'constructor-super': 'off', // ts(2335) & ts(2377)
3132
'getter-return': 'off', // ts(2378)
3233
'import/named': 'off',
@@ -54,6 +55,7 @@ module.exports = {
5455
'@typescript-eslint/adjacent-overload-signatures': 'error',
5556
'@typescript-eslint/ban-ts-comment': 'error',
5657
'@typescript-eslint/ban-types': 'error',
58+
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
5759
'@typescript-eslint/explicit-module-boundary-types': 'warn',
5860
'no-array-constructor': 'off',
5961
'@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none', requireLast: false } }],

docs/content/en/guide/migration.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Migration guide
3+
description: Follow this guide to upgrade from one major version to the other.
4+
position: 10
5+
category: Guide
6+
---
7+
8+
Follow this guide to upgrade from one major version to the other.
9+
10+
## Upgrading from v6 to v7
11+
12+
Sentry SDK dependencies updated from v6 to v7. Please read about breaking changes in Sentry SDK's [Upgrading from v6.x to v7.x](https://github.com/getsentry/sentry-javascript/blob/master/MIGRATION.md#upgrading-from-6x-to-7x) document.
13+
14+
Some of the breaking changes listed in that document are automatically handled by the module and don't need any action. Other notable changes that might require action are:
15+
16+
- When using the `tracing` option, the `@sentry/tracing` dependency needs to be upgraded from v6.x to v7.x.
17+
- The `whitelistUrls` and `blacklistUrls` Sentry `config` (or `clientConfig` / `serverConfig`) options have been renamed to `allowUrls` and `denyUrls`.
18+
- The `Vue` integration was removed as is now merged into the Sentry Browser SDK. If you have been passing custom `Vue` options through the `clientIntegrations.Vue` object then those can now be merged directly into the `clientConfig` option (without the parent `Vue` key).
19+
- The `UserAgent` integration was renamed to `HttpContext`. If you have been passing custom configuration to that integration through `clientIntegrations` option then you should rename the key.

docs/content/en/guide/setup.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,37 @@ Add `@nuxtjs/sentry` dependency to your project:
3030
</code-block>
3131
</code-group>
3232

33-
Then, add `@nuxtjs/sentry` to the `modules` section of `nuxt.config.js`:
33+
Then, add `@nuxtjs/sentry` to the `modules` section of `nuxt.config.js` and set your unique `dsn` value:
3434

3535
```js [nuxt.config.js]
3636
{
3737
modules: [
3838
'@nuxtjs/sentry'
3939
],
4040
sentry: {
41-
dsn: '', // Enter your project's DSN here
42-
// Additional Module Options go here
43-
// https://sentry.nuxtjs.org/sentry/options
41+
dsn: '', // Enter your project's DSN.
42+
// Additional Module Options.
4443
config: {
45-
// Add native Sentry config here
46-
// https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/
44+
// Optional Sentry SDK configuration.
45+
// Those options are shared by both the Browser and the Server instances.
46+
// Browser-only and Server-only options should go
47+
// into `clientConfig` and `serverConfig` objects respectively.
4748
},
4849
}
4950
}
5051
```
5152

53+
See [Options](/sentry/options) for a list of available options.
54+
55+
<alert type="info">
56+
57+
For Typescript or type-checked JavaScript projects, you might have to install the `@sentry/tracing` package even when not using the tracing functionality. In that case, the package can be installed as a dev-only dependency.
58+
59+
</alert>
60+
5261
## Types
5362

54-
For typescript projects, add `@nuxtjs/sentry` to tsconfig types array
63+
In Typescript or type-checked JavaScript projects, add `@nuxtjs/sentry` to the `types` array in `tsconfig.json` to enable module types.
5564

5665
```json [tsconfig.json]
5766
{
@@ -62,7 +71,3 @@ For typescript projects, add `@nuxtjs/sentry` to tsconfig types array
6271
}
6372
}
6473
```
65-
66-
## Configuration
67-
68-
See [Options](/sentry/options) for a list of available options

docs/content/en/sentry/lazy-loading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You can also pass a lazy config object in your module options (see [options](/se
2020
#### `$sentry` (mocked)
2121
- Type: `Object`
2222

23-
Normally `$sentry` would always refer to the `@sentry/browser` API. But if we lazy load Sentry this API wont be available until Sentry has loaded. If you don't want to worry about whether Sentry is loaded or not, a mocked Sentry API is injected into the Nuxt.js context that will execute all Sentry API calls once Sentry is loaded
23+
Normally `$sentry` would always refer to the `@sentry/vue` API. But if we lazy load Sentry this API wont be available until Sentry has loaded. If you don't want to worry about whether Sentry is loaded or not, a mocked Sentry API is injected into the Nuxt.js context that will execute all Sentry API calls once Sentry is loaded
2424

2525
See: [`injectMock`](/sentry/options#lazy) and [`mockApiMethods`](/sentry/options#lazy) options.
2626

docs/content/en/sentry/options.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Options can be passed using either:
1212

1313
The `config`, `serverConfig` and `clientConfig` options can also be configured using [Runtime Config](/sentry/runtime-config).
1414

15-
Normally, just setting DSN would be enough.
15+
The `dsn` is the only option that is required to enable Sentry reporting.
1616

1717
### dsn
1818

1919
- Type: `String`
2020
- Default: `process.env.SENTRY_DSN || ''`
21-
- If no `dsn` is provided, Sentry will be initialised, but errors will not be logged. See [#47](https://github.com/nuxt-community/sentry-module/issues/47) for more information about this.
21+
- If no `dsn` is provided then Sentry will be initialized using mocked instance to prevent the code that references `$sentry` from crashing. No errors will be reported using that mocked instance.
2222

2323
### lazy
2424

@@ -68,7 +68,7 @@ Normally, just setting DSN would be enough.
6868
- **mockApiMethods**
6969
- Type: `Boolean` or `Array`
7070
- Default `true`
71-
- Which API methods from `@sentry/browser` should be mocked. You can use this to only mock methods you really use.
71+
- Which API methods from `@sentry/vue` should be mocked. You can use this to only mock methods you really use.
7272
- This option is ignored when `injectMock: false`
7373
- If `mockApiMethods: true` then all available API methods will be mocked
7474
> If `injectMock: true` then _captureException_ will always be mocked for use with the window.onerror listener
@@ -231,22 +231,23 @@ Note that the module sets the following defaults when publishing is enabled:
231231
- Default:
232232
```js
233233
{
234-
Dedupe: {},
235234
ExtraErrorData: {},
236235
ReportingObserver: {},
237236
RewriteFrames: {},
238-
Vue: {attachProps: true, logErrors: this.options.dev}
239237
}
240238
```
241-
- Sentry by default also enables these browser integrations: `InboundFilters`, `FunctionToString`, `TryCatch`, `Breadcrumbs`, `GlobalHandlers`, `LinkedErrors`, `UserAgent`. Their options can be overridden by specifying them manually in the object.
242-
- Here is the full list of client integrations that are supported: `Breadcrumbs`, `CaptureConsole`, `Debug`, `Dedupe`, `ExtraErrorData`, `FunctionToString`, `GlobalHandlers`, `InboundFilters`, `LinkedErrors`, `ReportingObserver`, `RewriteFrames`, `TryCatch`, `UserAgent`, `Vue`.
243-
- User-provided configuration is merged with the default configuration so to disable integration that is enabled by default, you have to pass `false` as a value. For example to disable `ExtraErrorData` integration (only), set the option to:
239+
- Sentry by default also enables the following browser integrations: `InboundFilters`, `FunctionToString`, `TryCatch`, `Breadcrumbs`, `GlobalHandlers`, `LinkedErrors`, `Dedupe`, `HttpContext`.
240+
- The full list of client integrations that are supported: `Breadcrumbs`, `CaptureConsole`, `Debug`, `Dedupe`, `ExtraErrorData`, `FunctionToString`, `GlobalHandlers`, `HttpContext`, `InboundFilters`, `LinkedErrors`, `ReportingObserver`, `RewriteFrames`, `TryCatch`.
241+
- Integration options can be specified in the object value corresponding to the individual integration key.
242+
- To disable integration that is enabled by default, pass `false` as a value. For example to disable `ExtraErrorData` integration (only), set the option to:
244243
```js
245244
{
246-
ExtraErrorData: false
245+
ExtraErrorData: false,
246+
ReportingObserver: {},
247+
RewriteFrames: {},
247248
}
248249
```
249-
- See https://docs.sentry.io/platforms/javascript/configuration/integrations/default/ and https://docs.sentry.io/platforms/javascript/configuration/integrations/plugin/ for more information on the integrations and their configuration
250+
- See also [Sentry Browser Integrations](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/integrations/) for more information on configuring each integration.
250251
251252
### serverIntegrations
252253
@@ -257,17 +258,20 @@ Note that the module sets the following defaults when publishing is enabled:
257258
Dedupe: {},
258259
ExtraErrorData: {},
259260
RewriteFrames: {},
260-
Transaction: {}
261261
}
262262
```
263-
- Here is the full list of server integrations that are supported: `CaptureConsole`, `Debug`, `Dedupe`, `ExtraErrorData`, `RewriteFrames`, `Modules`, `Transaction`.
264-
- User-provided configuration is merged with the default configuration so to disable integration that is enabled by default, you have to pass `false` as a value. For example to disable `ExtraErrorData` integration (only), set the option to:
263+
- Sentry by default also enables the following server integrations: `InboundFilters`, `FunctionToString`, `Console`, `Http`, `OnUncaughtException`, `OnUnhandledRejection`, `ContextLines`, `Context`, `Modules`, `RequestData`, `LinkedErrors`.
264+
- The full list of server integrations that are supported includes the ones above plus: `CaptureConsole`, `Debug`, `Dedupe`, `ExtraErrorData`, `RewriteFrames`, `Transaction`.
265+
- Integration options can be specified in the object value corresponding to the individual integration key.
266+
- To disable integration that is enabled by default, pass `false` as a value. For example to disable `ExtraErrorData` integration (only), set the option to:
265267
```js
266268
{
267-
ExtraErrorData: false
269+
Dedupe: {},
270+
ExtraErrorData: false,
271+
RewriteFrames: {},
268272
}
269273
```
270-
- See https://docs.sentry.io/platforms/node/pluggable-integrations/ for more information on the integrations and their configuration
274+
- See also [Sentry Server Integrations](https://docs.sentry.io/platforms/node/configuration/integrations/) for more information on configuring each integration.
271275
272276
### customClientIntegrations
273277
@@ -308,29 +312,29 @@ export default function () {
308312
309313
<alert type="info">
310314
311-
`@sentry/tracing@6` (version 6 and not newer) should be installed manually when using this option.
315+
`@sentry/tracing@7` (version 7) should be installed manually when using this option.
312316
313317
</alert>
314318
315-
- Enables the BrowserTracing integration for client performance monitoring
319+
- Enables Sentry Performance Monitoring on the [server](https://docs.sentry.io/platforms/node/performance/) and [browser](https://docs.sentry.io/platforms/javascript/guides/vue/performance/) side.
316320
- Takes the following object configuration format (default values shown):
317321
```js
318322
{
319323
tracesSampleRate: 1.0,
324+
browserTracing: {},
320325
vueOptions: {
321-
tracing: true,
322-
tracingOptions: {
323-
hooks: [ 'mount', 'update' ],
324-
timeout: 2000,
325-
trackComponents: true
326-
}
326+
trackComponents: true,
327327
},
328-
browserOptions: {}
329328
}
330329
```
331-
- Sentry documentation strongly recommends reducing the `tracesSampleRate` value; it should be between 0.0 and 1.0 (percentage of requests to capture)
332-
- The `vueOptions` are passed to the `Vue` integration, see https://docs.sentry.io/platforms/javascript/guides/vue/#monitor-performance for more information
333-
- `browserOptions` are passed to the `BrowserTracing` integration, see https://github.com/getsentry/sentry-javascript/tree/master/packages/tracing for more information
330+
- On the browser side the `BrowserTracing` integration is enabled by default and adds automatic instrumentation for monitoring the performance of the application. See available [`BrowserTracing` options](https://docs.sentry.io/platforms/javascript/guides/vue/performance/instrumentation/automatic-instrumentation/).
331+
- On the browser side extra options for [Tracking Vue components](https://docs.sentry.io/platforms/javascript/guides/vue/features/component-tracking/) can be passed through the `vueOptions` object.
332+
333+
<alert type="info">
334+
335+
The `tracesSampleRate` value can be between 0.0 and 1.0 (percentage of requests to capture) and Sentry documentation strongly recommends reducing the value from the default 1.0.
336+
337+
</alert>
334338
335339
### config
336340
@@ -341,22 +345,24 @@ export default function () {
341345
environment: this.options.dev ? 'development' : 'production'
342346
}
343347
```
344-
- Sentry options common to the server and client that are passed to `Sentry.init(options)`. See Sentry documentation at https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/
345-
- Note that `config.dsn` is automatically set based on the root `dsn` option
346-
- The value for `config.release` is automatically inferred from the local repo unless specified manually
347-
- Do not use `config.integrations`, use clientIntegrations or serverIntegrations
348+
- Sentry options common to the Server and Browser SDKs that are passed to `Sentry.init()`. See Sentry's documentation for [Basic Browser Options](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/) and [Basic Server Options](https://docs.sentry.io/platforms/node/configuration/options/).
349+
- Note that `config.dsn` is automatically set based on the root `dsn` option.
350+
- The value for `config.release` is automatically inferred from the local repo unless specified manually.
351+
- Do not set `config.integrations`, use `clientIntegrations` and `serverIntegrations` options instead.
348352

349353
### serverConfig
350354

351355
- Type: `Object`
352356
- Default: `{}`
353-
- Specified key will override common Sentry options for server sentry plugin
357+
- Server-specific Sentry SDK options.
358+
- The specified keys will override common options set in the `config` key.
354359

355360
### clientConfig
356361

357362
- Type: `Object`
358363
- Default: `{}`
359-
- Specified keys will override common Sentry options for client sentry plugin
364+
- Browser-specific Sentry SDK options.
365+
- The specified keys will override common options set in the `config` key.
360366

361367
### requestHandlerConfig
362368

lib/core/options.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import merge from 'lodash.mergewith'
22
import * as Integrations from '@sentry/integrations'
33
import { canInitialize } from './utils'
44

5-
export const PLUGGABLE_INTEGRATIONS = ['CaptureConsole', 'Debug', 'Dedupe', 'ExtraErrorData', 'ReportingObserver', 'RewriteFrames', 'Vue']
6-
export const BROWSER_INTEGRATIONS = ['InboundFilters', 'FunctionToString', 'TryCatch', 'Breadcrumbs', 'GlobalHandlers', 'LinkedErrors', 'UserAgent']
5+
export const PLUGGABLE_INTEGRATIONS = ['CaptureConsole', 'Debug', 'Dedupe', 'ExtraErrorData', 'ReportingObserver', 'RewriteFrames']
6+
export const BROWSER_INTEGRATIONS = ['InboundFilters', 'FunctionToString', 'TryCatch', 'Breadcrumbs', 'GlobalHandlers', 'LinkedErrors', 'HttpContext']
77
const SERVER_INTEGRATIONS = ['CaptureConsole', 'Debug', 'Dedupe', 'ExtraErrorData', 'RewriteFrames', 'Modules', 'Transaction']
88

99
/** @param {import('../../types/sentry').IntegrationsConfiguration} integrations */
@@ -74,7 +74,7 @@ function resolveLazyOptions (options, apiMethods, logger) {
7474

7575
const notfoundMethods = mockMethods.filter(method => !apiMethods.includes(method))
7676
if (notfoundMethods.length) {
77-
logger.warn('Some specified methods to mock weren\'t found in @sentry/browser:', notfoundMethods)
77+
logger.warn('Some specified methods to mock weren\'t found in @sentry/vue:', notfoundMethods)
7878
}
7979

8080
if (!options.lazy.mockApiMethods.includes('captureException')) {
@@ -93,24 +93,18 @@ function resolveTracingOptions (options, config) {
9393
if (!options.tracing) {
9494
return
9595
}
96-
const userOptions = typeof options.tracing === 'boolean' ? {} : options.tracing
9796
/** @type {NonNullable<import('../../types/sentry').TracingConfiguration>} */
98-
const tracingOptions = merge(
99-
{
100-
tracesSampleRate: 1.0,
101-
vueOptions: {
102-
tracing: true,
103-
tracingOptions: {
104-
hooks: ['mount', 'update'],
105-
timeout: 2000,
106-
trackComponents: true,
107-
},
108-
},
109-
browserOptions: {},
97+
const defaultOptions = {
98+
tracesSampleRate: 1,
99+
browserTracing: {},
100+
vueOptions: {
101+
trackComponents: true,
110102
},
111-
userOptions,
112-
)
113-
if (!config.tracesSampleRate) {
103+
}
104+
const userOptions = typeof options.tracing === 'boolean' ? {} : options.tracing
105+
/** @type {NonNullable<import('../../types/sentry').TracingConfiguration>} */
106+
const tracingOptions = merge(defaultOptions, userOptions)
107+
if (config.tracesSampleRate === undefined) {
114108
config.tracesSampleRate = tracingOptions.tracesSampleRate
115109
}
116110
options.tracing = tracingOptions
@@ -128,7 +122,7 @@ export async function resolveClientOptions (moduleContainer, moduleOptions, logg
128122

129123
options.config = merge({}, options.config, options.clientConfig)
130124

131-
const apiMethods = await getApiMethods('@sentry/browser')
125+
const apiMethods = await getApiMethods('@sentry/vue')
132126
resolveLazyOptions(options, apiMethods, logger)
133127
resolveTracingOptions(options, options.config)
134128

lib/module.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ export default function SentryModule (moduleOptions) {
3131
sourceMapStyle: 'source-map',
3232
tracing: false,
3333
clientIntegrations: {
34-
Dedupe: {},
3534
ExtraErrorData: {},
3635
ReportingObserver: {},
3736
RewriteFrames: {},
38-
Vue: { attachProps: true, logErrors: this.options.dev },
3937
},
4038
serverIntegrations: {
4139
Dedupe: {},

0 commit comments

Comments
 (0)