-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
"@sentry/react": "^9.46.0"
Framework Version
"react": "^19.1.0"
Link to Sentry event
Reproduction Example/SDK Setup
In instrument.js
:
// ...
Sentry.replayIntegration({
beforeErrorSampling: (event) => {
console.log("beforeErrorSampling", event);
if (event.level === "error") {
console.log("Capturing replay for error");
return event;
}
console.log("Not capturing replay because level is not error");
return null;
},
}),
// ...
replaysSessionSampleRate: 0.0,
replaysOnErrorSampleRate: 1.0,
In App.jsx
:
<button
type="button"
onClick={() => {
Sentry.withScope(function (scope) {
scope.setLevel("info");
// The exception has the event level set by the scope (info).
Sentry.captureException(new Error("custom error"));
});
}}
>
Send info
</button>
Steps to Reproduce
- Set up a
beforeErrorSampling
that decides when a replay should be recorded based on the event level, making sure that the replay session sampling rate is 0 - Using the scope, change the event level to one that should not send a replay to Sentry based on your logic
- Trigger an event that should not have a replay attached to it
Expected Result
The event arrives in Sentry without a replay.
Actual Result
The event arrives in Sentry with a replay.
The above is a reproduction from my test app and org. Original customer ticket here.
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it.
alexbjorlig, AndreasHald and oxymcalexbjorlig
Metadata
Metadata
Assignees
Projects
Status
No status