Mobile replay: no way to scrub network request and response bodies before they are sent

未关闭
#6,873 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

这个 Issue 还没有评估数据。

描述

Feature React-Native Replays
Versions

@sentry/react-native 8.30.0, @sentry/core 10.76.0, sentry-cocoa 9.30.1 (bundled), React Native 0.86.3, Expo 57.

What's missing

mobileReplayIntegration can capture request and response bodies for the replay Network tab (networkDetailAllowUrls, networkCaptureBodies). There is no way for the app to scrub those bodies before they leave the device. The only control is networkDetailDenyUrls, which drops the whole body of an endpoint.

beforeBreadcrumb can't be used for this:

  • the bodies are attached in the beforeAddBreadcrumb hook, which runs after beforeBreadcrumb
  • for fetch responses (blob bodies) the enriched breadcrumb is sent to native later through syncBreadcrumbToNative, which skips every hook

So an app that wants bodies, minus a token or card field, has to choose between leaking the field and losing the whole body. Server-side data scrubbing is best effort and runs after the data has already left the device.

The web replay has the same capture options plus hooks to scrub recording data before it's sent, so this is a gap on mobile.

What we did

We added an option to mobileReplayIntegration that takes a function. Each captured request or response body is parsed as JSON when possible, passed through the function, and the result is what gets sent. We pass the same redaction function we use in beforeSend, so a body loses the same fields an error event would.

One edge case: a body over the 150 KB limit is truncated, and a truncated body can't be reliably parsed and scrubbed. When the option is set, we drop such a body entirely (keeping the size warning) instead of sending it unscrubbed.

It would be great to have an official option like this, or any hook that runs on the final network details for both the synchronous and the async (blob) path.

主要语言
TypeScript
星标
1.8k
派生
371
平均合并
22 小时 3 分钟
30 天内合并 PR
106

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-react-native 的其他 Issue

查看 getsentry/sentry-react-native 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。