sentry-javascript
sentry-javascript copied to clipboard
NextJS Sentry is using deprecated `beforeNavigate` instead of `beforeStartSpan`
Is there an existing issue for this?
- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [X] I have reviewed the documentation https://docs.sentry.io/
- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.110.0
Framework Version
13.2.4
Link to Sentry event
No response
SDK Setup
Sentry.init({
dsn: __YOUR_DSN__,
tracesSampleRate: 0.1,
environment: __YOUR_ENV__,
integrations: [
Sentry.browserTracingIntegration({
beforeStartSpan: (context) => {
console.log(context);
return {
...context,
name: getTransactionName(context),
};
},
}),
],
});
Steps to Reproduce
Used configuration from above in sentry.client.config.ts by following the documentation.
Expected Result
Function beforeStartSpan should be called and a log should appear in console when it's called.
Actual Result
Function beforeStartSpan is never called. I suspect it's caused by the weird fixBrowserTracingIntegration method that converts the most recent browser tracing integration to the deprecated one.
What's more, using beforeNavigate actually works, but produces TypeScript errors since it's not defined in BrowserTracingOptions.
This is contrary to what the documentation says.
Hey, thanks for writing in! Hmm, this seems like a bug to me - we'll look into it!
Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/7.111.0 - please upgrade and give it a try!
Unfortunately it doesn't seem to work, @AbhiPrasad. Nothing gets logged. On a side note, before the fix I could make it work with:
// @ts-expect-error: ignore TypeScript
beforeNavigate(options: { name: string }) {
...
}
That actually produced some console logs and in Chrome network view I could see that the transaction name got updated.
Now, it seems that it doesn't work at all.
I will look into it, it seems that something is really off there, sorry about that!
So we've just released v7.112.2, where we hopefully actually have a full fix for your problem - sorry about the confusion! Gonna leave this open this time until I've got confirmation that the issue is actually solved 😅
So we've just released v7.112.2, where we hopefully actually have a full fix for your problem - sorry about the confusion! Gonna leave this open this time until I've got confirmation that the issue is actually solved 😅
From what I can see, beforeStartSpan indeed gets called now 👍
Also, in the big "envelope/..." request I can see that the transaction property got changed in 2 places 👍
This seems to be fixed, so I am closing this 👍