我正在尝试将有效负载数据添加到发送到 Sentry.io 的面包屑中。
看起来就是这样。
我找到了如何添加回复。
const sentryConfig: BrowserOptions = {
beforeBreadcrumb: (breadcrumb, hint) => {
if (breadcrumb.category === 'xhr') {
// hint.xhr is a whole XHR object that you can use to modify breadcrumb
breadcrumb.data = (hint.xhr as XMLHttpRequest).response;
}
return breadcrumb;
}
};
Run Code Online (Sandbox Code Playgroud)
但我似乎找不到添加有效负载的方法。XMLHttpRequest没有这个信息。
小智 7
可以通过以下方式从 xhr 获取正文(有效负载数据):
beforeBreadcrumb: (breadcrumb, hint) => {
if (breadcrumb.category === 'xhr') {
const data = {
requestBody: hint.xhr.__sentry_xhr__.body,
response: hint.xhr.response,
responseUrl: hint.xhr.responseURL
}
return { ...breadcrumb, data }
}
return breadcrumb
}
Run Code Online (Sandbox Code Playgroud)
这是添加它的PR 。
| 归档时间: |
|
| 查看次数: |
1995 次 |
| 最近记录: |