Repository navigation
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
7.107.0
Framework Version
18.2
Link to Sentry event
No response
SDK Setup
import * as Sentry from '@sentry/react';
const {
REACT_APP_SENTRY_DSN,
REACT_APP_SENTRY_TRACE_SAMPLE_RATE = 1.0,
REACT_APP_SENTRY_REPLAY_SESSIONS_SAMPLE_RATE = 0.1,
REACT_APP_SENTRY_REPLAY_ON_ERROR_SAMPLE_RATE = 1.0,
REACT_APP_SENTRY_ENVIRONMENT = 'production',
} = import.meta.env;
console.log("REPLAY_SESSIONS_SAMPLE_RATE", REACT_APP_SENTRY_REPLAY_SESSIONS_SAMPLE_RATE) // 0.1
console.log("REPLAY_ON_ERROR_SAMPLE_RATE", REACT_APP_SENTRY_REPLAY_ON_ERROR_SAMPLE_RATE) // 1.0
Sentry.init({
debug: true,
replaysSessionSampleRate: REACT_APP_SENTRY_REPLAY_SESSIONS_SAMPLE_RATE,
replaysOnErrorSampleRate: REACT_APP_SENTRY_REPLAY_ON_ERROR_SAMPLE_RATE,
dsn: REACT_APP_SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
],
environment: REACT_APP_SENTRY_ENVIRONMENT,
tracesSampleRate: REACT_APP_SENTRY_TRACE_SAMPLE_RATE, // 1.0
});
Steps to Reproduce
To reproduce, just start the app and throw errors
I'm throwing errors in various ways in the app (multiple of them to try and get around a log message from the sentry client saying it won't report an already captured exception, not sure I understood it correctly, but just in case), I'm also using
<button
type="button"
onClick={() => {
throw new Error("Sentry Test Error");
}}
>
Break the world
</button>
from https://docs.sentry.io/platforms/javascript/guides/react/session-replay/
but none of the reported errors (both manually synthesized or real errors) on the app (sentry.io/issues) have replays associated with them.
This line is always present in the output
Sentry Logger [log]: Integration installed: Replay
These lines (tagged with [Replay]) are only present when I manually call replay.start() or if I set the replaysSessionSampleRate to 1.0
Sentry Logger [info]: [Replay] Starting replay in session mode
Sentry Logger [info]: [Replay] Loading existing session
Sentry Logger [info]: [Replay] Using compression worker
...
Sentry Logger [info]: [Replay] Pausing replay
Sentry Logger [info]: [Replay] Document has become active, but session has expired
Sentry Logger [info]: [Replay] Document has become active, but session has expired
Expected Result
Errors are always sampled when I set the rate to 1.0 on errors
Actual Result
No automatic error sampling
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status
Activity
mydea commentedon Mar 25, 2024
Are the errors being captured to Sentry? Meaning, do you see this error in Sentry? We only start replay when an error was successfully sent.
Can you paste the debug logs around when the error is thrown - or is nothing logged at all?
Also, can you paste the full debug logs after calling init - it should still log something surrounding replay being set up.
zkhishy commentedon Mar 25, 2024
Yes they are. Here's the one corresponding to the error which I've attached the logs for https://ernest-energy.sentry.io/issues/5098610421
Added
Added; there's nothing besides
Sentry Logger [log]: Integration installed: Replaysentry-broswer-log.log
mydea commentedon Mar 26, 2024
Ah, I think I know what the problem is - you are passing the sample rates as strings, you need to do e.g.
replaysSessionSampleRate: Number(REACT_APP_SENTRY_REPLAY_SESSIONS_SAMPLE_RATE),(the same for all other sample rates you get from the env).You can see this log:
We don't have one like these for the replay sample rates (we should maybe add them there too...) but it'll be the same issue there, I believe!
zkhishy commentedon Mar 26, 2024
Yep, that fixed the problem, thanks! It would definitely be helpful if the SDK complained about bad config/threw an error on init instead of just accepting the bad config and silently failing
mydea commentedon Mar 27, 2024
You are right - we'll update this so that we try to parse string arguments to the sample rate as well!
feat(core): Handle string sample rates (#11305)
feat(core): Handle string sample rates (getsentry#11305)