getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.86k stars 1.55k forks source link

Attempted import error: 'extraErrorDataIntegration' is not exported from '@sentry/nextjs' (imported as 'Sentry'). #12307

Closed Saturate closed 3 months ago

Saturate commented 3 months ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.2.1

Framework Version

14.2.2

Link to Sentry event

No response

SDK Setup

import * as Sentry from '@sentry/nextjs';

export async function register() {
  const shared: Parameters<typeof Sentry.init>[0] = {
    dsn: 'https://...........',

    // Adjust this value in production, or use tracesSampler for greater control
    tracesSampleRate: 1,

    release: process.env.NEXT_PUBLIC_VERSION_TAG,

    // Set readable environment name
    environment: process.env.BUILD_ID?.replace('-build', ''),

    // Setting this option to true will print useful information to the console while you're setting up Sentry.
    debug: false,

    integrations: [Sentry.extraErrorDataIntegration({ depth: 10, captureErrorCause: true })],
  };

  if (process.env.node_env !== 'development') {
    if (process.env.NEXT_RUNTIME === 'nodejs') {
      Sentry.init({
        ...shared,
      });
    }

    if (process.env.NEXT_RUNTIME === 'edge') {
      Sentry.init({
        ...shared,
      });
    }
  }
}

Steps to Reproduce

  1. Run pnpm dev

Expected Result

Being able to use integrations: [Sentry.extraErrorDataIntegration({ depth: 10, captureErrorCause: true })], on server side as well to get better errors.

Actual Result

Errors in console with:

storefront:dev:  ⚠ ./instrumentation.ts
storefront:dev: Attempted import error: 'extraErrorDataIntegration' is not exported from '@sentry/nextjs' (imported as 'Sentry').
storefront:dev:  ✓ Compiled in 1431ms (920 modules)
lforst commented 3 months ago

Hi, thanks for writing in. You are right there is an issue and I opened a PR to fix it. We didn't export everything correctly from the edge side of the SDK. For now, as a work-around, you can add the integration to your Node.js init call instead of the shared options. Let me know if that works!

Saturate commented 3 months ago

That was quick! Thanks :)

AbhiPrasad commented 3 months ago

Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/8.8.0