Skip to content

Commit adc7c9c

Browse files
authored
docs: add information about enriching events (#473)
1 parent 08d7e6c commit adc7c9c

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

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

0 commit comments

Comments
 (0)