Skip to content

Commit a0820ca

Browse files
committed
Merge branch 'fix/tree-shake' into beta
* fix/tree-shake: feat: enable tree shaking of Sentry SDK debug code chore(lint): enable linting for more files within the repo chore(deps): update lock file fix(deps): update sentry dependencies to ^7.28.0 (#478) docs: minor updates about dependencies and lazy+tracing feat: support plugin path for clientConfig and serverConfig (#477) feat(tracing): enable Vue Router instrumentation by default (#476) Revert "feat(tracing): enable Vue Router instrumentation by default" feat(tracing): enable Vue Router instrumentation by default chore(lint): tweak eslint ignore directives for generated plugin files chore(deps): update devdependency sentry-testkit to v5 chore(deps): update devdependency @nuxtjs/eslint-config-typescript to v12 chore(deps): update sentry dependencies to ^7.27.0 (#474) feat!: update Sentry SDK from v6 to v7 (#461) docs: add information about enriching events (#473) fix: gracefully handle Nuxt versions without Runtime Config (#472)
2 parents 54b3959 + 45362c6 commit a0820ca

21 files changed

+1394
-2808
lines changed

.eslintignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
!.eslintrc.js
22
!.release-it.js
3+
4+
# un-ignore @nuxtjs/eslint-config
5+
!*.d.ts
6+
!.nuxt/sentry.*.js
7+
8+
dist/
39
lib/plugin.*
410
lib/templates/*.*
5-
test/fixture/*/.nuxt
11+

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
extends: [
33
'@nuxtjs/eslint-config',
44
],
5-
ignorePatterns: ['dist/'],
65
rules: {
76
'comma-dangle': ['error', 'always-multiline'],
87
'import/named': 'off',

.release-it.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
module.exports = {
33
git: {
44
commitMessage: 'chore: release ${version}',
5-
tagName: 'v${version}'
5+
tagName: 'v${version}',
66
},
77
npm: {
8-
publish: false
8+
publish: false,
99
},
1010
github: {
1111
release: true,
1212
releaseName: '${version}',
13-
releaseNotes: 'echo "${changelog}" | sed 1,2d'
13+
releaseNotes: 'echo "${changelog}" | sed 1,2d',
1414
},
1515
plugins: {
1616
'@release-it/conventional-changelog': {
1717
preset: 'conventionalcommits',
18-
infile: 'CHANGELOG.md'
19-
}
20-
}
18+
infile: 'CHANGELOG.md',
19+
},
20+
},
2121
}

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: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,30 @@ 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+
Note that the Sentry SDK dependencies (`@sentry/*`) are not pinned and can be updated independently from the module itself by running `npm upgrade @nuxtjs/sentry` or `yarn update @nuxtjs/sentry`. That means you don't have to wait for a new module release if you want to update to the latest SDK version.
56+
5257
<alert type="info">
5358

5459
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.
@@ -68,7 +73,3 @@ In Typescript or type-checked JavaScript projects, add `@nuxtjs/sentry` to the `
6873
}
6974
}
7075
```
71-
72-
## Configuration
73-
74-
See [Options](/sentry/options) for a list of available options.

docs/content/en/guide/usage.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
---
2-
title: Usage
3-
description: 'Usage of Sentry into Nuxt'
2+
title: Usage / API
3+
description: 'Usage of Sentry in Nuxt'
44
position: 3
55
category: Guide
66
---
77

8-
Enter your DSN in the Nuxt.js config file. Additional config options can be found [here](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/).
9-
108
### Automatic Capturing
11-
Once installed, Sentry automatically reports errors, uncaught exceptions, and unhandled rejections. No need for further steps, unless you like to report (certain) exceptions manually (or have deactivated integrations like 'GlobalError'). In this case, find below how to send reports manually.
9+
10+
Once enabled, Sentry automatically reports errors, uncaught exceptions and unhandled rejections. No need for further steps, unless you like to report (certain) exceptions manually or have deactivated integrations like `GlobalError`. In this case, find out below how to send reports manually.
11+
12+
### Enriching Reported Events
13+
14+
Sentry SDK provides API for enhancing events that are being reported. For example, you can:
15+
- set user information like IP address or username using `Sentry.setUser` API
16+
- add custom structured data using `Sentry.setContext` API
17+
- set custom key/value pairs (tags) that get indexed and can be used for filtering and searching using `Sentry.setTag` API
18+
- add file attachments using `scope.addAttachment` API
19+
- manually add breadcrumbs using `Sentry.addBreadcrumb` API
20+
- and other...
21+
22+
Read more about [Enriching Events](https://docs.sentry.io/platforms/javascript/guides/vue/enriching-events/).
1223

1324
### Usage in Vue components
1425

1526
In a Vue component, `Sentry` is available as `this.$sentry`, so we can call functions like
1627

17-
``` js
28+
```js
1829
this.$sentry.captureException(new Error('example'))
1930
```
2031

2132
where `this` is a Vue instance.
2233

2334
### Usage in `asyncData`
2435

25-
While using Nuxt's `asyncData` method, there's `$sentry` object in the `context`:
36+
While using Nuxt's `asyncData` method, there's `$sentry` object in the `context` object:
2637

27-
``` js
38+
```js
2839
async asyncData ({ params, $sentry }) {
2940
try {
3041
let { data } = await axios.get(`https://my-api/posts/${params.id}`)
@@ -37,7 +48,7 @@ async asyncData ({ params, $sentry }) {
3748

3849
### Usage in server middleware
3950

40-
Sentry instance is accessible through the `process.sentry`.
51+
Server Sentry instance is accessible through `process.sentry`.
4152

4253
### Usage in other lifecycle areas
4354

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ position: 6
55
category: Sentry
66
---
77

8-
<alert type="warning">
8+
Set `lazy: true` in your module options to load Sentry lazily on the client. This will prevent Sentry from being included in your main bundle and should result in a faster initial page load.
99

10-
Please be aware that lazy loading could prevent some errors that happen early during app loading from being reported.
10+
You can also pass a lazy config object in your module options (see [options](/sentry/options#lazy) for more information).
1111

12-
</alert>
12+
<alert type="info">
1313

14-
Set `lazy: true` in your module options to load Sentry lazily on the client. This will prevent Sentry from being included in your main bundle **but could result in some errors not being reported**.
14+
Please be aware that lazy loading could prevent some errors that happen early during app loading from being reported and, if `tracing` is enabled, some performance metrics might not be accurate.
1515

16-
You can also pass a lazy config object in your module options (see [options](/sentry/options#lazy) for more information).
16+
</alert>
1717

1818
### Injected properties
1919

docs/content/en/sentry/options.md

Lines changed: 68 additions & 27 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

@@ -123,6 +123,7 @@ Normally, just setting DSN would be enough.
123123
- Default: `sentry`
124124
- Specified object in Nuxt config in `publicRuntimeConfig[runtimeConfigKey]` will override some options at runtime. See documentation at https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-runtime-config/
125125
- Used to define the environment at runtime for example
126+
- See also [Runtime Config](/sentry/runtime-config) documentation.
126127
127128
### disabled
128129
@@ -230,21 +231,23 @@ Note that the module sets the following defaults when publishing is enabled:
230231
- Default:
231232
```js
232233
{
233-
Dedupe: {},
234234
ExtraErrorData: {},
235235
ReportingObserver: {},
236-
RewriteFrames: {}
236+
RewriteFrames: {},
237237
}
238238
```
239-
- 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.
240-
- 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`.
241-
- 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:
242243
```js
243244
{
244-
ExtraErrorData: false
245+
ExtraErrorData: false,
246+
ReportingObserver: {},
247+
RewriteFrames: {},
245248
}
246249
```
247-
- 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.
248251
249252
### serverIntegrations
250253
@@ -255,17 +258,20 @@ Note that the module sets the following defaults when publishing is enabled:
255258
Dedupe: {},
256259
ExtraErrorData: {},
257260
RewriteFrames: {},
258-
Transaction: {}
259261
}
260262
```
261-
- Here is the full list of server integrations that are supported: `CaptureConsole`, `Debug`, `Dedupe`, `ExtraErrorData`, `RewriteFrames`, `Modules`, `Transaction`.
262-
- 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:
263267
```js
264268
{
265-
ExtraErrorData: false
269+
Dedupe: {},
270+
ExtraErrorData: false,
271+
RewriteFrames: {},
266272
}
267273
```
268-
- 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.
269275
270276
### customClientIntegrations
271277
@@ -306,21 +312,29 @@ export default function () {
306312
307313
<alert type="info">
308314
309-
`@sentry/tracing@7` (version 7 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.
310316
311317
</alert>
312318
313-
- 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.
314320
- Takes the following object configuration format (default values shown):
315321
```js
316322
{
317323
tracesSampleRate: 1.0,
318-
trackComponents: true
319-
browserTracing: {}
324+
browserTracing: {},
325+
vueOptions: {
326+
trackComponents: true,
327+
},
320328
}
321329
```
322-
- Sentry documentation strongly recommends reducing the `tracesSampleRate` value; it should be between 0.0 and 1.0 (percentage of requests to capture)
323-
- See available [browserTracing options](https://docs.sentry.io/platforms/javascript/guides/vue/performance/instrumentation/automatic-instrumentation/#configuration-options)
330+
- On the browser side the `BrowserTracing` integration is enabled by default and adds automatic instrumentation for monitoring the performance of the application. The [Vue Router Integration](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/integrations/vue-router/) is also automatically enabled. See all 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>
324338
325339
### config
326340
@@ -331,22 +345,49 @@ export default function () {
331345
environment: this.options.dev ? 'development' : 'production'
332346
}
333347
```
334-
- 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/
335-
- Note that `config.dsn` is automatically set based on the root `dsn` option
336-
- The value for `config.release` is automatically inferred from the local repo unless specified manually
337-
- 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.
338352

339353
### serverConfig
340354

341355
- Type: `Object`
342356
- Default: `{}`
343-
- Specified key will override common Sentry options for server sentry plugin
357+
- Sentry SDK [Basic Server Options](https://docs.sentry.io/platforms/node/configuration/options/).
358+
- The specified keys will override common options set in the `config` key.
359+
- The value can be a string in which case it needs to be a file path (can use [webpack aliases](https://nuxtjs.org/docs/2.x/directory-structure/assets#aliases)) pointing to a javascript file whose default export (a function) returns the configuration object. This is necessary in case some of the options rely on imported values or can't be serialized. The function can be `async`. Artificial example that switches out the `transport`:
360+
```js [~/config/sentry-server-config.js]
361+
import { makeNodeTransport } from '@sentry/node'
362+
363+
export default function() {
364+
return {
365+
transport: makeNodeTransport,
366+
}
367+
}
368+
```
344369

345370
### clientConfig
346371

347-
- Type: `Object`
372+
- Type: `Object` or `String`
348373
- Default: `{}`
349-
- Specified keys will override common Sentry options for client sentry plugin
374+
- Sentry SDK [Basic Browser Options](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/).
375+
- The specified keys will override common options set in the `config` key.
376+
- The value can be a string in which case it needs to be a file path (can use [webpack aliases](https://nuxtjs.org/docs/2.x/directory-structure/assets#aliases)) pointing to a javascript file whose default export (a function) returns the configuration object. This is necessary in case some of the options rely on imported values or can't be serialized. The function is passed a `Nuxt Context` argument and can be `async`. Example of how to enable [User Feedback](https://docs.sentry.io/platforms/javascript/enriching-events/user-feedback/) dialog:
377+
```js [~/config/sentry-client-config.js]
378+
import { showReportDialog } from '@sentry/vue'
379+
380+
export default function(context) {
381+
return {
382+
beforeSend (event, hint) {
383+
if (event.exception) {
384+
showReportDialog({ eventId: event.event_id })
385+
}
386+
return event
387+
},
388+
}
389+
}
390+
```
350391

351392
### requestHandlerConfig
352393

docs/content/en/sentry/runtime-config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ publicRuntimeConfig: {
2828
```
2929

3030
You can customize the key that is used to access settings from `publicRuntimeConfig` by setting [`runtimeConfigKey`](/sentry/options#runtimeconfigkey) in the non-runtime options.
31+
32+
This functionality is supported from Nuxt 2.13 and up.

docs/nuxt.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import theme from '@nuxt/content-theme-docs'
22

33
export default theme({
44
docs: {
5-
primaryColor: '#ae9dff'
6-
}
5+
primaryColor: '#ae9dff',
6+
},
77
})

0 commit comments

Comments
 (0)