Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

captureConsoleIntegration cannot be added as integration #11761

Closed
3 tasks done
mgryszko opened this issue Apr 24, 2024 · 4 comments
Closed
3 tasks done

captureConsoleIntegration cannot be added as integration #11761

mgryszko opened this issue Apr 24, 2024 · 4 comments

Comments

@mgryszko
Copy link

mgryszko commented Apr 24, 2024

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

7.112.1

Framework Version

No response

Link to Sentry event

No response

SDK Setup

import { captureConsoleIntegration } from "@sentry/integrations";
import { init as sentryInit } from "@sentry/nextjs";

sentryInit({
  integrations: [captureConsoleIntegration()],
});

Steps to Reproduce

  1. Trying to upgrade from 7.109 to 7.112.1, but captureConsoleIntegration but getting the TypeScript error: TS2322: Type IntegrationFnResult is not assignable to type Integration
  2. I'm following the documentation about CaptureConsole
  3. Following the migration guide from 7.112.1 does
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  integrations: [Sentry.captureConsoleIntegration()],
});

gives the following TypeScript error:

TS2551: Property captureConsoleIntegration does not exist on type

typeof import("/Users/mgryszko/p/airup-one/web/node_modules/@sentry/nextjs/types/index.types")

. Did you mean consoleIntegration?
  1. I'm not sure that consoleIntegration() is the same as captureConsoleIntegration(): it lacks the levels configuration option plus it's not officially documented

Expected Result

Re-export of captureConsoleIntegration or migration guide if it's deprecated.

Actual Result

TypeScript error (see Steps to Reproduce)

@s1gr1d
Copy link
Member

s1gr1d commented Apr 24, 2024

Hello, thanks for writing!

I tested your setup with version 7.109.0 and 7.112.1 and was not able to reproduce the issue. Maybe there is still an old type definition cached somewhere. You could try to delete your node_modules, make sure @sentry/integrations is not installed anymore and install again. Will that fix your issue?

About 4: The consoleIntegration adds console statements inside a Node environment as breadcrumbs, while the captureConsoleIntegration is sending console statements to Sentry as events. We will make it more clear in the documentation and also add it to the Next.js docs, as Next.js can runs inside a Node environment as well. Thanks for noticing!

@mgryszko
Copy link
Author

@s1gr1d I checked your suggestion (deleting node_modules and starting from the clean slate) but it doesn't solve the issue: I'm still getting the same type error. Upgrading to 7.112.2 didn't help neither.

@mydea
Copy link
Member

mydea commented Apr 29, 2024

Hello, can you try to remove @sentry/integrations from your package.json, update @sentry/nextjs to 1.112.1, and updated your import like this:

import { init as sentryInit, captureConsoleIntegration } from "@sentry/nextjs";

sentryInit({
  integrations: [captureConsoleIntegration()],
});

does that work? Since 7.112.0 we re-export these integrations from the main SDK packages, so it should not be necessary to install @sentry/integrations anymore.

@mgryszko
Copy link
Author

mgryszko commented Apr 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants