Skip to content

Commit 431dee6

Browse files
authored
add RequestData integration (#5674)
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.
1 parent 0cb25fb commit 431dee6

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

src/platforms/node/common/configuration/integrations/default-integrations.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,36 @@ _(New in version 7.13.0.)_
139139
_Import name: `Sentry.Integrations.Modules`_
140140

141141
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.
142+
143+
### RequestData
144+
145+
_(New in version 7.17.1.)_
146+
147+
_Import name: `Sentry.Integrations.RequestData`_
148+
149+
This integration adds data from incoming requests to transaction and error events that occur during request handling.
150+
151+
Available options:
152+
153+
```javascript
154+
{
155+
// Controls what types of data are added to the event
156+
include: {
157+
cookies: boolean // default: true,
158+
data: boolean // default: true,
159+
headers: boolean // default: true,
160+
ip: boolean // default: false,
161+
query_string: boolean // default: true,
162+
url: boolean // default: true,
163+
user: boolean | {
164+
id: boolean // default: true,
165+
username: boolean // default: true,
166+
email: boolean // default: true,
167+
},
168+
},
169+
// Controls how the transaction will be reported. Options are 'path' (`/some/route`),
170+
// 'methodPath' (`GET /some/route`), and 'handler' (the name of the route handler
171+
// function, if available)
172+
transactionNamingScheme: string // default: 'methodPath',
173+
};
174+
```

src/platforms/node/guides/azure-functions/index.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ module.exports = async function(context, req) {
3030
try {
3131
await notExistFunction();
3232
} catch (e) {
33-
Sentry.captureException(e);
33+
Sentry.withScope(scope => {
34+
scope.setSDKProcessingMetadata({ request: req });
35+
Sentry.captureException(e);
36+
});
3437
await Sentry.flush(2000);
3538
}
3639

src/platforms/node/guides/koa/index.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ const app = new Koa();
3131
Sentry.init({ dsn: "___PUBLIC_DSN___" });
3232

3333
app.on("error", (err, ctx) => {
34-
Sentry.withScope((scope) => {
35-
scope.addEventProcessor((event) => {
36-
return Sentry.addRequestDataToEvent(event, ctx.request);
37-
});
34+
Sentry.withScope(scope => {
35+
scope.setSDKProcessingMetadata({ request: ctx.request });
3836
Sentry.captureException(err);
3937
});
4038
});

0 commit comments

Comments
 (0)