Skip to content

Commit

Permalink
feat(replay): Add example for beforeAddRecordingEvent (#7547)
Browse files Browse the repository at this point in the history
* feat(replay): Add example for `beforeAddRecordingEvent`

Closes #7447

* /remove optional chaining

* style(lint): Auto commit lint changes

* style(lint): Auto commit lint changes

* Update src/platforms/javascript/common/session-replay/privacy.mdx

Co-authored-by: Ryan Albrecht <[email protected]>

* style(lint): Auto commit lint changes

* Apply suggestions from code review

Co-authored-by: Liza Mock <[email protected]>

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Co-authored-by: Ryan Albrecht <[email protected]>
Co-authored-by: Liza Mock <[email protected]>
  • Loading branch information
4 people authored Jul 27, 2023
1 parent 9dbba27 commit ecc1d8f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/platforms/javascript/common/session-replay/privacy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,29 @@ new Sentry.Replay({
});
```

Note that 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.
### Example: Capturing 500 Status Codes Only

Here's an example showing how to only capture fetch requests that return a 500 status code. (Non-fetch requests would continue to be captured normally.)

```javascript
new Sentry.Replay({
beforeAddRecordingEvent: (event) => {
// Do not capture fetch/xhr requests, unless the response code is 500
if (
event.data.tag === "performanceSpan" &&
(event.data.payload.op === "resource.fetch" ||
event.data.payload.op === "resource.xhr") &&
event.data.payload.data.statusCode !== 500
) {
return null;
}

return event;
},
});
```

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.

### Deprecated Options

Expand Down

1 comment on commit ecc1d8f

@vercel
Copy link

@vercel vercel bot commented on ecc1d8f Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs.sentry.dev
sentry-docs-git-master.sentry.dev
docs.sentry.io

Please sign in to comment.