RequestData
将传入请求的数据添加到事件中。 (默认)
此集成仅在服务器环境中工作(Node.js, Bun, Deno)。
Import name: Sentry.requestDataIntegration
此集成默认启用。如果你希望修改默认集成,请阅读 此内容。
此集成将传入请求的数据添加到请求处理期间发生的事务和错误事件中。
Copied
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [Sentry.requestDataIntegration()],
});
通过传递 include
选项,你可以定义要捕获的请求数据:
Copied
requestDataIntegration({
// 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',
})