getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
37.08k stars 3.98k forks source link

replaysOnErrorSampleRate seems to apply to warnings #70028

Open Sweater-Baron opened 2 weeks ago

Sweater-Baron commented 2 weeks ago

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Set up @sentry/react with replaysOnErrorSampleRate set to a value > 0
  2. Make sure your site logs a warning, e.g. console.warn("Example console warning")

Expected Result

Replays are not recorded for warnings

Actual Result

Replays are recorded for warnings.

This doesn't, in general, seem useful. Replays are useful on errors, for helping to reproduce the error, but I don't think I've ever needed to reproduce a warning, so this just seems like a waste of replay quota and I suspect it's not intended behavior?

Product Area

Replays

Link

No response

DSN

https://56fd57d3e4904a0081fe82111f5db5ee@o1412184.ingest.sentry.io/6751029

Version

No response

getsantry[bot] commented 2 weeks ago

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] commented 2 weeks ago

Routing to @getsentry/product-owners-replays for triage ⏲️

jas-kas commented 2 weeks ago

Hey @Sweater-Baron 👋

Thanks for reporting this.

Are the 'warnings' you're referring to reflected as Sentry errors in the product? (i.e., in our Issues stream) If so, you can choose to filter out any errors for our replaysOnErrorSampleRate with beforeErrorSampling: https://docs.sentry.io/platforms/javascript/session-replay/configuration/

If you don't want to see these warnings whatsoever in the product, you can filter them out all together with beforeSend: https://docs.sentry.io/platforms/javascript/configuration/options/

Let me know if that helps!

bruno-garcia commented 2 weeks ago

By any chance do you have attachStacktrace = true ? curious if that plays a role

billyvg commented 2 weeks ago

Are you using the captureConsole integration? console.warn by itself should not trigger a replay.

Sweater-Baron commented 2 weeks ago

We are using captureConsole to capture console.warn as issues in Sentry. We don't want to filter out the warnings themselves, just don't want replays to be recorded for them.

In the Sentry UI, the level of the issues for these warnings is correctly listed as "Level: Warning", not error level.

We are not using attachStacktrace in our Sentry.init, so I assume it must be whatever its default value is.

Here's the full Sentry init, if that's helpful:

Sentry.init({
  dsn: 'https://56fd57d3e4904a0081fe82111f5db5ee@o1412184.ingest.sentry.io/6751029',
  integrations: [
    new Sentry.BrowserTracing({
      tracePropagationTargets: [/^https:\/\/(.*\.)?mysite\.com\/api.*/],
    }),
    new Sentry.Replay({
      maskAllText: false,
      blockAllMedia: false,
    }),
    new CaptureConsoleIntegration({
      levels: ['warn', 'error', 'debug', 'assert'],
    }),
    new ExtraErrorDataIntegration(),
    new ReportingObserverIntegration({
      types: ['crash'],
    }),
    new SessionTimingIntegration(),
  ],
  environment: environmentName, // a string
  release: releaseId, // a string
  sampleRate: isLocalDev ? 0 : 1,
  replaysSessionSampleRate: 0,
  replaysOnErrorSampleRate: isLocalDev ? 0 : 1.0,
});
bruno-garcia commented 2 weeks ago

Thanks for your reply, makes sense. As a work around I suggest using the hook @jas-kas suggested, and drop anything that has level:warning beforeErrorSampling: https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/understanding-sessions/#ignore-certain-errors-for-error-sampling

We'll consider changes on the default behavior