Skip to content

Problems with @sentry/utils after we switched from @sentry/browser to @sentry/gatsby #6011

Closed
@aaron5670

Description

@aaron5670

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/gatsby

SDK Version

7.16.0

Framework Version

React 17.0.2

Link to Sentry event

No response

Steps to Reproduce

We switched from the latest version of @sentry/browser to @sentry/gatsby and got the following error:

Error in function eval in ./node_modules/@sentry/utils/esm/instrument.js:134
image

We didn't change any configuration, we only switched from Sentry SDK (@sentry/browser to @sentry/gatsby).

We use the following Sentry dependencies:

{
    "@sentry/gatsby": "^7.16.0",
    "@sentry/integrations": "^7.16.0",
    "@sentry/tracing": "^7.16.0",
    "@sentry/types": "^7.16.0",
}

This is how our gatsby-browser.js file looks:

import { init } from '@sentry/gatsby';
import { BrowserTracing } from '@sentry/tracing';
import { Dedupe, ExtraErrorData } from '@sentry/integrations';

/**
 * Called when the Gatsby browser runtime first starts.
 */
export const onClientEntry = async () => {
  /**
   * Available Options: https://docs.sentry.io/error-reporting/configuration/?platform=browser
   */
  init({
    dsn: process.env.GATSBY_SENTRY_DSN,
    release: __DYNAMIC_RELEASE_STRING__, // eslint-disable-line
    environment: process.env.GATSBY_ACTIVE_ENV,
    debug: process.env.GATSBY_SENTRY_DEBUG_MODE === 'true',
    maxBreadcrumbs: 50,
    autoSessionTracking: true,

    // You can log events to Sentry, even locally in development env, but you need to opt-in for it.
    enabled: process.env.GATSBY_ACTIVE_ENV === 'production' || process.env.GATSBY_SENTRY_DEBUG_MODE === 'true',

    normalizeDepth: 6,
    integrations: [
      new Dedupe(),
      new ExtraErrorData(),

      // This enables automatic instrumentation (highly recommended), but is not
      // necessary for purely manual usage
      new BrowserTracing({
        tracingOrigins: ['localhost', 'domain-a.nl', 'domain-b.be', /^\//],
      }),
    ],
    ignoreErrors: [
      'ResizeObserver loop limit exceeded',
      'CookieControl', // CookieBot related errors
      'webkitPresentationMode',
      'iFrameResizer',
      'iframe-resizer-react',
      'ChunkLoadError',
      'Pastease',
    ],
    denyUrls: [
      /accutics\.net/,
      /cookiebot\.com/,
      /doubeclick\.net/,
      /facebook\.net/,
      /google\.com/,
      /google-analytics\.com/,
      /googleadservices\.com/,
      /hotjar\.com/,
      /mopinion\.com/,
      /omappapi\.com/,
      /opmnstr\.com/,
      /zdassets\.com/,
      /zendesk\.com/,
      /zopim\.com/,
      /cdn\.optimizely\.com/,
    ],
    beforeSend: (event) => {
      if (['production', 'staging'].includes(process.env.GATSBY_ACTIVE_ENV)) {
        // Debug messages will be shown for staging and production only
        // if GATSBY_SENTRY_DEBUG_MODE env var set to 'true'.
        // Fatal, error, warning and info messages will always be shown.
        return event.level !== 'debug' || process.env.GATSBY_SENTRY_DEBUG_MODE === 'true' ? event : null;
      }

      return null;
    },
    beforeBreadcrumb: (breadcrumb) => {
      // All related to Hot Module Reloading locally, so no need to have it.
      if (breadcrumb.category === 'xhr' && breadcrumb.data && /socket.io\/\?EIO/.test(breadcrumb.data.url)) {
        return null;
      }

      if (breadcrumb.category === 'console' && /\[HMR\]/.test(breadcrumb.message)) {
        return null;
      }

      return breadcrumb;
    },
    // Stacktrace is always attached during errors.
    // If you want to see it also for debug, warning and info messages, set the GATSBY_SENTRY_DEBUG_MODE to 'true'
    attachStacktrace: process.env.GATSBY_SENTRY_DEBUG_MODE === 'true',

    // Set tracesSampleRate to 1.0 to capture 100%
    // of transactions for performance monitoring.
    // We recommend adjusting this value in production
    tracesSampleRate: 0.02,
  });
};

Expected Result

The integration has always worked properly with the package @sentry/browser, but after switching to @sentry/gatsby we get the following error message.

Actual Result

We switched from the latest version of @sentry/browser to @sentry/gatsby and got the following error:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions