Skip to content

Commit 5edd9ad

Browse files
author
Christian Hotz
committed
own docs section for new feature
1 parent 0bb1861 commit 5edd9ad

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

README.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ await server.register({
2525

2626
The plugin options, you can pass in while registering are the following:
2727

28-
| property | type | description |
29-
|:--------------------------|:-------------|:-----------------------------------------------------------------------------------------------------------------------------|
30-
| `baseUri` | string | [uri](https://github.com/hapijs/joi/blob/master/API.md#stringurioptions) to be used as base for captured urls |
31-
| `trackUser` | boolean | Whether or not to track the user via the per-request scope. Default: `true` |
32-
| `scope.tags` | object | An array of tags to be sent with every event |
33-
| `scope.tags.name` | string | The name of a tag |
34-
| `scope.tags.value` | any | The value of a tag |
35-
| `scope.extra` | object | An object of arbitrary format to be sent as extra data on every event |
36-
| `client` | object | **required** A [@sentry/node](https://www.npmjs.com/package/@sentry/node) instance which was already initialized (using `Sentry.init`) OR an options object to be passed to an internally initialized [@sentry/node](https://www.npmjs.com/package/@sentry/node) (`client.dsn` is only required in the latter case) |
37-
| `client.dsn` | string/false | **required** The Dsn used to connect to Sentry and identify the project. If false, the SDK will not send any data to Sentry. |
38-
| `client.debug` | boolean | Turn debug mode on/off |
39-
| `client.release` | string | Tag events with the version/release identifier of your application |
40-
| `client.environment` | string | The current environment of your application (e.g. `'production'`) |
41-
| `client.sampleRate` | number | A global sample rate to apply to all events (0 - 1) |
42-
| `client.maxBreadcrumbs` | number | The maximum number of breadcrumbs sent with events. Default: `100` |
43-
| `client.attachStacktrace` | any | Attaches stacktraces to pure capture message / log integrations |
44-
| `client.sendDefaultPii` | boolean | If this flag is enabled, certain personally identifiable information is added by active integrations |
45-
| `client.serverName` | string | Overwrite the server name (device name) |
46-
| `client.beforeSend` | func | A callback invoked during event submission, allowing to optionally modify the event before it is sent to Sentry |
47-
| `client.beforeBreadcrumb` | func | A callback invoked when adding a breadcrumb, allowing to optionally modify it before adding it to future events. |
48-
| `catchLogErrors` | boolean/array | Whether or not to capture errors logged via `server.log` or `request.log`. Events must contain one `['error', 'fatal', 'fail']` tags or match one of the specified tags and pass an `Error` instance as data. Default: `false` |
28+
| property | type | description |
29+
|:--------------------------|:--------------|:-----------------------------------------------------------------------------------------------------------------------------|
30+
| `baseUri` | string | [uri](https://github.com/hapijs/joi/blob/master/API.md#stringurioptions) to be used as base for captured urls |
31+
| `trackUser` | boolean | Whether or not to track the user via the per-request scope. Default: `true` |
32+
| `scope.tags` | object | An array of tags to be sent with every event |
33+
| `scope.tags.name` | string | The name of a tag |
34+
| `scope.tags.value` | any | The value of a tag |
35+
| `scope.extra` | object | An object of arbitrary format to be sent as extra data on every event |
36+
| `client` | object | **required** A [@sentry/node](https://www.npmjs.com/package/@sentry/node) instance which was already initialized (using `Sentry.init`) OR an options object to be passed to an internally initialized [@sentry/node](https://www.npmjs.com/package/@sentry/node) (`client.dsn` is only required in the latter case) |
37+
| `client.dsn` | string/false | **required** The Dsn used to connect to Sentry and identify the project. If false, the SDK will not send any data to Sentry. |
38+
| `client.debug` | boolean | Turn debug mode on/off |
39+
| `client.release` | string | Tag events with the version/release identifier of your application |
40+
| `client.environment` | string | The current environment of your application (e.g. `'production'`) |
41+
| `client.sampleRate` | number | A global sample rate to apply to all events (0 - 1) |
42+
| `client.maxBreadcrumbs` | number | The maximum number of breadcrumbs sent with events. Default: `100` |
43+
| `client.attachStacktrace` | any | Attaches stacktraces to pure capture message / log integrations |
44+
| `client.sendDefaultPii` | boolean | If this flag is enabled, certain personally identifiable information is added by active integrations |
45+
| `client.serverName` | string | Overwrite the server name (device name) |
46+
| `client.beforeSend` | func | A callback invoked during event submission, allowing to optionally modify the event before it is sent to Sentry |
47+
| `client.beforeBreadcrumb` | func | A callback invoked when adding a breadcrumb, allowing to optionally modify it before adding it to future events. |
48+
| `catchLogErrors` | boolean/array | Handles [capturing server.log and request.log events](#capturing-serverlog-and-requestlog-events). Default: `false` |
4949

5050
The `baseUri` option is used internally to get a correct URL in sentry issues.
5151
The `scope` option is used to set up a global
@@ -91,6 +91,20 @@ server.route({
9191
});
9292
```
9393

94+
## Capturing server.log and request.log events
95+
96+
You can enable capturing of `request.log` and `server.log` events using the `catchLogErrors` option.
97+
All events which are `Error` objects and are tagged by one of `['error', 'fatal', 'fail']` are
98+
automatically being tracked when `catchLogErrors` is set to `true`, e.g.:
99+
100+
```js
101+
request.log(['error', 'foo'], new Error('Oh no!'));
102+
server.log(['error', 'foo'], new Error('No no!'));
103+
```
104+
105+
The considered tags can be changed by setting `catchLogErrors` to a custom array of tags like
106+
`['error', 'warn', 'failure']`.
107+
94108
## Capturing the request body
95109

96110
`hapi-sentry` currently does not capture the body for performance reasons. You can use the following snippet to capture the body in all sentry errors:

0 commit comments

Comments
 (0)