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

CaptureConsole (and other integrations) specify an incorrect import name #1015

Closed
kumar303 opened this issue May 24, 2019 · 9 comments
Closed

Comments

@kumar303
Copy link

The CaptureConsole integration documentation specifies an "import name" of Sentry.Integration.CaptureConsole. I'm not sure what this even means but there's no way it can be correct. My best guess at what it meant was this:

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

Sentry.init({
  dsn: '...',
  integrations: [
    new Sentry.Integration.CaptureConsole({ levels: ['error'] })
  ],
});

This results in the following TypeScript error:

src/configureApplication.tsx:32:33 - error TS2339: Property 'Integration' does not exist on type 'typeof import("/Users/kumar/dev/addons-code-manager/node_modules/@sentry/browser/dist/index")'.

32       integrations: [new Sentry.Integration.CaptureConsole({ levels: ['error'] })],
                                   ~~~~~~~~~~~

The proper way to import and configure it is:

import * as Sentry from '@sentry/browser';
import { CaptureConsole } from '@sentry/integrations';

Sentry.init({
  dsn: '...',
  integrations: [new CaptureConsole({ levels: ['error'] })],
});

All other integrations seem to be documented with "import names" in this manner.

@ajl100b
Copy link

ajl100b commented Jul 17, 2019

32 integrations: [new Sentry.Integration.CaptureConsole({ levels: ['error'] })],

should be Sentry.Integrations.CaptureConsole note the s in integrations

@GaramNick
Copy link

In Angular 6 I'm getting a signature mismatch error on integrations.

import * as Sentry from '@sentry/browser';
import { CaptureConsole } from '@sentry/integrations';
Sentry.init({
	environment: 'xxx'
	release: '1.0',
	dsn: 'xxx',
	integrations: [new CaptureConsole({levels: ['error'],})],
});
Type 'CaptureConsole[]' is not assignable to type 'Integration[] | ((integrations: Integration[]) => Integration[])'.
  Type 'CaptureConsole[]' is not assignable to type 'Integration[]'.
    Type 'CaptureConsole' is not assignable to type 'Integration'.
      Types of property 'setupOnce' are incompatible.
        Type '(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub) => void' is not assignable to type '(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub) => void'.
          Types of parameters '_' and 'addGlobalEventProcessor' are incompatible.
            Types of parameters 'callback' and 'callback' are incompatible.
              Type 'import("CODE/node_modules/@sentry/integrations/node_modules/@sentry/types/dist/eventprocessor").EventProcessor' is not assignable to type 'import("CODE/node_modules/@sentry/types/dist/eventprocessor").EventProcessor'.
                Types of parameters 'event' and 'event' are incompatible.
                  Type 'import("CODE/node_modules/@sentry/types/dist/event").Event' is not assignable to type 'import("CODE/node_modules/@sentry/integrations/node_modules/@sentry/types/dist/event").Event'.
                    Types of property 'type' are incompatible.
                      Type '"none"' is not assignable to type '"transaction"'.ts(2322)
options.d.ts(33, 5): The expected type comes from property 'integrations' which is declared here on type 'BrowserOptions'

@AngularDevMrs
Copy link

Still facing the same issue in Angular 8

@fr1sk
Copy link

fr1sk commented Feb 7, 2020

Got the same issue in NestJS using @sentry/node
Workaround is to ignore types with as any. Not the cleanest tho, but it works 🤷🏻‍♂️

  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    integrations: [
      new CaptureConsole({
        levels: ['error', 'warn']
      }) as any
    ]
  });

@ykshatroff
Copy link

Same thing for me, the documentation was very confusing.
Actually there seems to be no integrations module installed if you just install @sentry/node, so I had to npm install @sentry/integrations as well to make it work.
Then both

const { CaptureConsole } = require("@sentry/integrations");

and

Sentry.Integrations.CaptureConsole

appeared.

@manjeetyadv
Copy link

This will surely work in the case of Nodejs or anything:-

const CaptureConsole = require('@sentry/integrations').CaptureConsole;
Sentry.init({ dsn: "...", integrations: [new CaptureConsole({ levels: ['error'] })], });

@blyszcz
Copy link

blyszcz commented Dec 16, 2020

Sentry team, why don't you update the docs? They are old and people have to look into GitHub issues to integrate such a primary thing

@kjellski
Copy link

I think the problem here is that you've got a version mismatch between the @sentry package and the @sentry/integrations.
Once I've installed @sentry/integrations I got the same error, but upgrading the other @sentry packages to the same version fixed it :)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2021

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Accepted, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants