Skip to content

Sentry Replays counting muted Errors or something off #4908

Open
@varunraghu3112

Description

@varunraghu3112

What React Native libraries do you use?

React Navigation

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.5.0

How does your development environment look like?

I have blacklisted a few errors in ignoreErrors/beforeSend being captured in Sentry, and they are not being reported as errors — which is expected.

However, it seems that these blacklisted errors are still being treated as recordings in Sentry Replays but errors are 0 in the replay. I’ve configured the following settings for a specific release:
	•	replaysOnErrorSampleRate: 0.2
	•	replaysSessionSampleRate: 0

Despite this, I’m still seeing replays without any captured errors, which is unnecessarily increasing our replay usage.



Sentry.init()

Sentry.init({
  dsn: 'xxxx',
  release: `x.x`,
  dist: `${versionCode}`,
  beforeSend(event, hint) {
    // since ignoreErrors doesnt seem to ignore 'Non-Error exception captured with keys: code, error, message, payload'
    // adding custom handling block to filter out Non-Error type exception

    const nonErrorPatterns = sentryNonErrorPatterns || [
      'Non-Error exception captured',
      'Object captured as exception with keys: code, error, message, payload',
      'Unable to resolve host'
    ];

    const isNonErrorException = nonErrorPatterns.some(
      (pattern) =>
        event.exception.values[0]?.value?.includes(pattern) || hint.originalException?.message?.includes(pattern)
    );

    if (isNonErrorException) {
      // ignore these kind of issues
      return null;
    }
    // check if the originalException is object and add the data as extras to the Sentry Event
    if (
      typeof hint.originalException === 'object' &&
      hint.originalException != null &&
      'key' in hint.originalException
    ) {
      event.extra = {
        ...event.extra,
        ...hint.originalException
      };
    }
    return event;
  },
  replaysSessionSampleRate: '0',
  replaysOnErrorSampleRate: '0.2',
  beforeSend(event, hint) {
  },
  enableAutoSessionTracking: true,
  environment: __DEV__ ? 'development' : logEnabled ? 'qa' : 'production',
  ignoreErrors: [
    'Non-Error exception captured with keys: code, error, message, payload',
    'Non-Error exception captured',
    'Non-Error exception captured with keys',
    'Non-Error exception captured with keys:'
  ],
  tracesSampleRate: performaceSample,
  sampleRate,
  integrations: [
    new NativeManager.ReactNativeTracing({
      tracingOrigins: [NativeManager.baseUrl],
      routingInstrumentation
    }), // It follows correct methods
    NativeManager.mobileReplayIntegration({
      maskAllImages: false,
      maskAllVectors: false,
      maskAllText: false
    }) // It follows correct methods
  ]
});

Steps to Reproduce

Add some checks in beforeSend those replays comes under replaysOnErrorSampleRate

Expected Result

If an error is suppressed in beforeSend, it should not be counted as an error and should not fall under the replaysOnErrorSampleRate bucket.

Actual Result

For the specific version, replays are being shown without any errors, even though I set replaysOnErrorSampleRate to 0.2 and replaysSessionSampleRate to 0

Image

Metadata

Metadata

Type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @gaprl@lucas-zimerman@krystofwoldrich@varunraghu3112

      Issue actions

        Sentry Replays counting muted Errors or something off · Issue #4908 · getsentry/sentry-react-native