Skip to content

Commit c2b2d1b

Browse files
billyvgvivianyentranlizokm
authored
feat(replay): Add docs for scrubbing URLs on the replay event (#9058)
Adds an example for scrubbing URLS from the replay event using `addEventProcessor` Closes getsentry/sentry-javascript#9871 --------- Co-authored-by: vivianyentran <[email protected]> Co-authored-by: Liza Mock <[email protected]>
1 parent c7be9cf commit c2b2d1b

File tree

1 file changed

+28
-0
lines changed
  • docs/platforms/javascript/common/session-replay

1 file changed

+28
-0
lines changed

docs/platforms/javascript/common/session-replay/privacy.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,34 @@ Sentry.replayIntegration({
110110

111111
We also have [server-side PII scrubbing](/product/data-management-settings/scrubbing/server-side-scrubbing/) for this data. It looks for certain patterns such as American social security numbers, credit cards, and private keys.
112112

113+
### Example: Scrubbing URLs
114+
115+
By default, URLs are stored in both recording and replay events.
116+
117+
To scrub the URL in a recording event, use the above `beforeAddRecordingEvent`.
118+
119+
To scrub the URL in a replay event, use `addEventProcessor`:
120+
121+
```javascript
122+
Sentry.addEventProcessor(event) => {
123+
// Ensure that we specifically look at replay events
124+
if (event.type !== 'replay_event') {
125+
// Return the event, otherwise the event will be dropped
126+
return event;
127+
}
128+
129+
// Your URL scrubbing function
130+
function urlScrubber(url: string) {
131+
return url.replace(/([a-z0-9]{3}\.[a-z]{5}\.[a-z]{7})/, '[Filtered]');
132+
}
133+
134+
// Scrub all URLs with your scrubbing function
135+
event.urls = event.urls.map(urlScrubber);
136+
137+
return event;
138+
});
139+
```
140+
113141
### Deprecated Options
114142

115143
Note that the privacy API prior to version 7.35.0 has been deprecated and replaced with the options above. Please see the [Replay migration guide](https://github.com/getsentry/sentry-javascript/blob/master/packages/replay/MIGRATION.md#upgrading-replay-from-7340-to-7350---6645) for further information.

0 commit comments

Comments
 (0)