-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Module '"@sentry/nextjs"' has no exported member 'BrowserTracing'. #4569
Comments
Similar issue here using the nextjs package (v6.18.2):
And I get the following typescript error that
typescript is looking in the server index instead of client index. Though after building, webpack seems to locate the right index:
|
Yes, this is a known issue, and does indeed come from a lack of microsoft/TypeScript#29128 being solved. (I'm honestly surprised this isn't a more widespread problem.) One option is to split the SDK and force all imports to come from Definitely open to better ideas if anyone has them! |
@lobsterkatie until the TypeScript issue is reopened/resolved, some options that come to mind:
class _WhateverIntegration { ... }
export const WhateverIntegration: typeof _WhateverIntegration | undefined to force developers to acknowledge that they're working with an integration that doesn't always exist.
import '@sentry/nextjs/browser'
import * as Sentry from '@sentry/nextjs'
Sentry.init({
integrations: [new Sentry.BrowserTracing()]
}) Where declare namespace NodeJS {
interface Process {
context: 'browser'
}
} Then the export could be defined as: export type BrowserOnly<T> = NodeJS.Process['context'] extends 'browser' ? T : undefined
class _Whatever {}
export const Whatever: BrowserOnly<typeof _Whatever> Of those, 1 would probably be the easiest, both for maintainers and users. |
Is this still not solved? Version 7 and the same problem in nextjs package. |
The simplest way I found in order to avoid having to explicitly ignore the errors and still have type completion was to add the package import { BrowserTracing } from '@sentry/tracing'
// ...
Sentry.init({
// ...
integrations: [new BrowserTracing({
// ...
})]
}) |
I am also experiencing a similar issue.
The build is eventually passing but the error page is broken (it doesn't find withSentryServerSideErrorGetInitialProps in real-time) I see that they are exported directly under @sentry/nextjs (from ./config/wrappers) and they are actually recognized when I am running the nextjs dev server (nx) but not on production using the build Any idea why does it happening and how can it be fixed? |
@adishua Can you share your _error page? |
Yes.
The result of it is a white screen (instead of the standard error page) with the following errors on the browser console:
|
@adishua I think I know what is going on. |
yes.. the auto instrument didn't work for me, I had to wrap the getServerSideProps in order to see the errors, then I implemented the rest of the data-fetching wrappers. |
Ok, thanks for letting us know about this. I actually want to fix this soon by making the Next.js SDK fully isomorphic. For now what you can try is to wrap your getInitialProps another time and only wrap the original one with At some point soon-ish we will do this in the wrapper itself. |
I'll try that. Thanks |
It didn't help. I got the same error with the following implementation
(I also tried to import the function dynamically but that didn't help) |
Hello 👋
I just updated to Sentry 6.17.7 and saw that
BrowserTracing
has since been directly exported through@sentry/nextjs
so I went to update mysentry.client.config.ts
file:But TypeScript is complaining about the
import
, sayingIt seems TypeScript is looking in the server index file, rather than the client. I'm not sure there's a good way around this at the moment, aside from ignoring this error or also exporting
BrowserTracing
from the server file. I did come across microsoft/TypeScript#29128 which seems like what we'd need here.The text was updated successfully, but these errors were encountered: