Skip to content

No replays captured for errors events at a 1.0 rate #11262

Closed

Description

@zkhishy

Is there an existing issue for this?

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

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 23, 2024
  2. mydea commented on Mar 25, 2024

    @mydea
    Member

    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.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Mar 25, 2024
  4. zkhishy commented on Mar 25, 2024

    @zkhishy
    Author

    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.

    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

    Can you paste the debug logs around when the error is thrown - or is nothing logged at all?

    Added

    Also, can you paste the full debug logs after calling init - it should still log something surrounding replay being set up.

    Added; there's nothing besides Sentry Logger [log]: Integration installed: Replay

    sentry-broswer-log.log

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Mar 25, 2024
  6. mydea commented on Mar 26, 2024

    @mydea
    Member

    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:

    [Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got "1.0" of type "string".
    

    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!

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Mar 26, 2024
  8. zkhishy commented on Mar 26, 2024

    @zkhishy
    Author

    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

  9. mydea commented on Mar 27, 2024

    @mydea
    Member

    You are right - we'll update this so that we try to parse string arguments to the sample rate as well!

  10. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions