1 | # @nuxtjs/sentry
|
2 |
|
3 | [![npm version][npm-version-src]][npm-version-href]
|
4 | [![npm downloads][npm-downloads-src]][npm-downloads-href]
|
5 | [![Circle CI][circle-ci-src]][circle-ci-href]
|
6 | [![Codecov][codecov-src]][codecov-href]
|
7 | [![Dependencies][david-dm-src]][david-dm-href]
|
8 | [![Standard JS][standard-js-src]][standard-js-href]
|
9 |
|
10 | > Sentry module for Nuxt.js
|
11 |
|
12 | ## Features
|
13 |
|
14 | The module enables error logging through [Sentry](http://sentry.io).
|
15 |
|
16 | - **Please note** that version 2.2.0 of this package removed the older `public_key` and `private_key` options, since the updated Sentry packages don't support these anymore.
|
17 | - **Please note** that version 2.0.0 of this package introduces a breaking change. See [#30](https://github.com/nuxt-community/sentry-module/pull/30) for more information.
|
18 |
|
19 | ## Setup
|
20 | - Add `@nuxtjs/sentry` dependency using yarn or npm to your project
|
21 | - Add `@nuxtjs/sentry` to `modules` section of `nuxt.config.js`
|
22 |
|
23 | ```js
|
24 | {
|
25 | modules: [
|
26 | '@nuxtjs/sentry',
|
27 | ],
|
28 |
|
29 | sentry: {
|
30 | dsn: '', // Enter your project's DSN here
|
31 | config: {}, // Additional config
|
32 | }
|
33 | }
|
34 | ```
|
35 |
|
36 | ### Nuxt compatibility
|
37 | Versions of NuxtJS before v2.4.0 are **not** supported by this package.
|
38 |
|
39 | ## Usage
|
40 |
|
41 | Enter your DSN in the NuxtJS config file. Additional config settings can be found [here](https://docs.sentry.io/error-reporting/configuration/?platform=browser).
|
42 |
|
43 | ### Usage in Vue component
|
44 |
|
45 | In a Vue component, `Sentry` is available as `this.$sentry`, so we can call functions like
|
46 |
|
47 | ``` js
|
48 | this.$sentry.captureException(new Error('example'))
|
49 | ```
|
50 |
|
51 | where `this` is a Vue instance.
|
52 |
|
53 | ### Usage in `asyncData`
|
54 |
|
55 | While using Nuxt's `asyncData` method, there's `$sentry` object in the `context`:
|
56 |
|
57 | ``` js
|
58 | async asyncData ({ params, $sentry }) {
|
59 | try {
|
60 | let { data } = await axios.get(`https://my-api/posts/${params.id}`)
|
61 | return { title: data.title }
|
62 | } catch (error) {
|
63 | $sentry.captureException(error)
|
64 | }
|
65 | }
|
66 | ```
|
67 |
|
68 | ### Usage in other lifecycle areas
|
69 |
|
70 | For the other special Nuxt lifecycle areas like `plugins`, `middleware`, and `nuxtServerInit`, the `$sentry` object is also accessible through the `context` object like so:
|
71 |
|
72 | ```js
|
73 | async nuxtServerInit({ commit }, { $sentry }) {
|
74 | try {
|
75 | let { data } = await axios.get(`https://my-api/timestamp`)
|
76 | commit('setTimeStamp', data)
|
77 | } catch (error) {
|
78 | $sentry.captureException(error)
|
79 | }
|
80 | }
|
81 | ```
|
82 |
|
83 | ## Options
|
84 |
|
85 | Options can be passed using either environment variables or `sentry` section in `nuxt.config.js`.
|
86 | Normally, setting required DSN information would be enough.
|
87 |
|
88 | ### dsn
|
89 | - Type: `String`
|
90 | - Default: `process.env.SENTRY_DSN || false`
|
91 | - 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.
|
92 |
|
93 | ### disabled
|
94 | - Type: `Boolean`
|
95 | - Default: `process.env.SENTRY_DISABLED || false`
|
96 | - Sentry will not be initialised if set to `true`.
|
97 |
|
98 | ### disableClientSide
|
99 | - Type: `Boolean`
|
100 | - Default: `process.env.SENTRY_DISABLE_CLIENT_SIDE || false`
|
101 |
|
102 | ### disableServerSide
|
103 | - Type: `Boolean`
|
104 | - Default: `process.env.SENTRY_DISABLE_SERVER_SIDE || false`
|
105 |
|
106 | ### initialize
|
107 | - Type: `Boolean`
|
108 | - Default: `process.env.SENTRY_INITIALIZE || true`
|
109 |
|
110 | ### publishRelease
|
111 | - Type: `Boolean`
|
112 | - Default: `process.env.SENTRY_PUBLISH_RELEASE || false`
|
113 | - See https://docs.sentry.io/workflow/releases for more information
|
114 |
|
115 | ### sourceMapStyle
|
116 | - Type: `String`
|
117 | - Default: `source-map`
|
118 | - Only has effect when `publishRelease = true`
|
119 | - The type of source maps generated when publishing release to Sentry. See https://webpack.js.org/configuration/devtool for a list of available options
|
120 | - **Note**: Consider using `hidden-source-map` instead. For most people, that should be a better option but due to it being a breaking change, it won't be set as the default until next major release
|
121 |
|
122 | ### attachCommits
|
123 | - Type: `Boolean`
|
124 | - Default: `process.env.SENTRY_AUTO_ATTACH_COMMITS || false`
|
125 | - Only has effect when `publishRelease = true`
|
126 |
|
127 | ### repo
|
128 | - Type: `String`
|
129 | - Default: `process.env.SENTRY_RELEASE_REPO || false`
|
130 | - Only has effect when `publishRelease = true && attachCommits = true`
|
131 |
|
132 | ### disableServerRelease
|
133 | - Type: `Boolean`
|
134 | - Default: `process.env.SENTRY_DISABLE_SERVER_RELEASE || false`
|
135 | - See https://docs.sentry.io/workflow/releases for more information
|
136 |
|
137 | ### disableClientRelease
|
138 | - Type: `Boolean`
|
139 | - Default: `process.env.SENTRY_DISABLE_CLIENT_RELEASE || false`
|
140 | - See https://docs.sentry.io/workflow/releases for more information
|
141 |
|
142 | ### clientIntegrations
|
143 | - Type: `Dictionary`
|
144 | - Default:
|
145 | ``` js
|
146 | {
|
147 | Dedupe: {},
|
148 | ExtraErrorData: {},
|
149 | ReportingObserver: {},
|
150 | RewriteFrames: {},
|
151 | Vue: {attachProps: true}
|
152 | }
|
153 | ```
|
154 | - See https://docs.sentry.io/platforms/node/pluggable-integrations/ for more information
|
155 |
|
156 | ### serverIntegrations
|
157 | - Type: `Dictionary`
|
158 | - Default:
|
159 | ``` js
|
160 | {
|
161 | Dedupe: {},
|
162 | ExtraErrorData: {},
|
163 | RewriteFrames: {},
|
164 | Transaction: {}
|
165 | }
|
166 | ```
|
167 | - See https://docs.sentry.io/platforms/node/pluggable-integrations/ for more information
|
168 |
|
169 | ### config
|
170 | - Type: `Object`
|
171 | - Default: `{
|
172 | environment: this.options.dev ? 'development' : 'production'
|
173 | }`
|
174 |
|
175 | ### serverConfig
|
176 | - Type: `Object`
|
177 | - Default: `{
|
178 | }`
|
179 | - If specified, values will override config values for server sentry plugin
|
180 |
|
181 | ### clientConfig
|
182 | - Type: `Object`
|
183 | - Default: `{
|
184 | }`
|
185 | - If specified, values will override config values for client sentry plugin
|
186 |
|
187 | ### webpackConfig
|
188 | - Type: `Object`
|
189 | - Default: Refer to `module.js` since defaults include various options that also change dynamically based on other options.
|
190 | - Options passed to `@sentry/webpack-plugin`. See documentation at https://github.com/getsentry/sentry-webpack-plugin/blob/master/README.md
|
191 |
|
192 | ## Submitting releases to Sentry
|
193 | Support for the [sentry-webpack-plugin](https://github.com/getsentry/sentry-webpack-plugin) was introduced [#a6cd8d3](https://github.com/nuxt-community/sentry-module/commit/a6cd8d3b983b4c6659e985736b19dc771fe7c9ea). This can be used to send releases to Sentry. Use the publishRelease option to enable this feature.
|
194 |
|
195 | Note that releases are only submitted to Sentry when `(options.publishRelease && !isDev)` is true.
|
196 |
|
197 | ## License
|
198 | [MIT License](./LICENSE)
|
199 |
|
200 | Copyright (c) Diederik van den Burger <diederik@glue.group>
|
201 |
|
202 | <!-- Badges -->
|
203 | [npm-version-src]: https://img.shields.io/npm/dt/@nuxtjs/sentry.svg?style=flat-square
|
204 | [npm-version-href]: https://npmjs.com/package/@nuxtjs/sentry
|
205 | [npm-downloads-src]: https://img.shields.io/npm/v/@nuxtjs/sentry/latest.svg?style=flat-square
|
206 | [npm-downloads-href]: https://npmjs.com/package/@nuxtjs/sentry
|
207 | [circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/sentry-module.svg?style=flat-square
|
208 | [circle-ci-href]: https://circleci.com/gh/nuxt-community/sentry-module
|
209 | [codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/sentry-module.svg?style=flat-square
|
210 | [codecov-href]: https://codecov.io/gh/nuxt-community/sentry-module
|
211 | [david-dm-src]: https://david-dm.org/nuxt-community/sentry-module/status.svg?style=flat-square
|
212 | [david-dm-href]: https://david-dm.org/nuxt-community/sentry-module
|
213 | [standard-js-src]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square
|
214 | [standard-js-href]: https://standardjs.com
|
215 |
|
\ | No newline at end of file |