Skip to content

Commit

Permalink
add RequestData integration (#5674)
Browse files Browse the repository at this point in the history
This adds documentation for the new `RequestData` integration in the node SDK, which adds request data to events. For frameworks where we don't have wrappers in the SDK, and merely tell people how to use sentry in the docs, this also adds storing the request in scope metadata to our boilerplate.
  • Loading branch information
lobsterkatie authored Nov 3, 2022
1 parent 0cb25fb commit 431dee6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,36 @@ _(New in version 7.13.0.)_
_Import name: `Sentry.Integrations.Modules`_

This integration fetches names of all currently installed Node modules and attaches the list to the event. Once fetched, Sentry will cache the list for later reuse.

### RequestData

_(New in version 7.17.1.)_

_Import name: `Sentry.Integrations.RequestData`_

This integration adds data from incoming requests to transaction and error events that occur during request handling.

Available options:

```javascript
{
// Controls what types of data are added to the event
include: {
cookies: boolean // default: true,
data: boolean // default: true,
headers: boolean // default: true,
ip: boolean // default: false,
query_string: boolean // default: true,
url: boolean // default: true,
user: boolean | {
id: boolean // default: true,
username: boolean // default: true,
email: boolean // default: true,
},
},
// Controls how the transaction will be reported. Options are 'path' (`/some/route`),
// 'methodPath' (`GET /some/route`), and 'handler' (the name of the route handler
// function, if available)
transactionNamingScheme: string // default: 'methodPath',
};
```
5 changes: 4 additions & 1 deletion src/platforms/node/guides/azure-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ module.exports = async function(context, req) {
try {
await notExistFunction();
} catch (e) {
Sentry.captureException(e);
Sentry.withScope(scope => {
scope.setSDKProcessingMetadata({ request: req });
Sentry.captureException(e);
});
await Sentry.flush(2000);
}

Expand Down
6 changes: 2 additions & 4 deletions src/platforms/node/guides/koa/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ const app = new Koa();
Sentry.init({ dsn: "___PUBLIC_DSN___" });

app.on("error", (err, ctx) => {
Sentry.withScope((scope) => {
scope.addEventProcessor((event) => {
return Sentry.addRequestDataToEvent(event, ctx.request);
});
Sentry.withScope(scope => {
scope.setSDKProcessingMetadata({ request: ctx.request });
Sentry.captureException(err);
});
});
Expand Down

1 comment on commit 431dee6

@vercel
Copy link

@vercel vercel bot commented on 431dee6 Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs.sentry.dev
docs.sentry.io
sentry-docs-git-master.sentry.dev

Please sign in to comment.