sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Lots of TypeErrors using Sentry Replay integration

Open dd-jonas opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] 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.109.0

Framework Version

18.2.0

Link to Sentry event

https://creative-shelter.sentry.io/issues/5131060670/?project=6640281rer=issue-stream&statsPeriod=30d&stream_index=2

SDK Setup

Sentry.init({
  dsn: import.meta.env.PROD ? SENTRY_DSN : '',
  environment: import.meta.env.VITE_VERCEL_ENV,
  normalizeDepth: 10,
  integrations: [Sentry.replayIntegration({ maskAllText: false, networkDetailAllowUrls: [API_URL] }), Sentry.metrics.metricsAggregatorIntegration()],
  replaysSessionSampleRate: 1.0,
  replaysOnErrorSampleRate: 1.0,
});

The metrics integration has been recently added. This error has been occurring from before it was added.

Steps to Reproduce

  1. Init Sentry as shown above
  2. Observe the TypeError appearing in Sentry

Not sure what the specific trigger is

Expected Result

No such TypeErrors occurring

Actual Result

TypeError: Cannot read properties of undefined (reading 'replace')

This is an error that is triggered internally by Sentry Tracing, according to the stack trace. It happens in @sentry-internal/tracing/esm/browser/web-vitals/lib/initMetric.js on line 30:

if (navEntry) {
    if (WINDOW.document.prerendering || getActivationStart() > 0) {
      navigationType = 'prerender';
    } else {
      navigationType = navEntry.type.replace(/_/g, '-') ;
    }
  }

I'm not using the Tracing integration, but I notice the Replay integration calls some functionally of it (initMetric('LCP');).

dd-jonas avatar Apr 03 '24 06:04 dd-jonas

Hey, thanks for opening this. I think this was fixed in web-vitals here: https://github.com/GoogleChrome/web-vitals/pull/290 we probably need to update web vitals! We'll look into this.

mydea avatar Apr 03 '24 07:04 mydea

We've updated web-vitals both on v7 & v8, could you give it a try if this is fixed for you?

mydea avatar May 15 '24 14:05 mydea

@mydea I have updated to v8 last week and haven't seen the issue anymore. Thanks!

dd-jonas avatar May 21 '24 07:05 dd-jonas