Skip to content

NextJS Sentry is using deprecated beforeNavigate instead of beforeStartSpan #11627

Closed

Description

@mpranjic24

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.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.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 16, 2024
  2. mydea commented on Apr 17, 2024

    @mydea
    Member

    Hey, thanks for writing in! Hmm, this seems like a bug to me - we'll look into it!

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 17, 2024
  4. AbhiPrasad commented on Apr 18, 2024

    @AbhiPrasad
    Contributor
  5. mpranjic24 commented on Apr 19, 2024

    @mpranjic24
    Author

    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.

  6. reopened this on Apr 19, 2024
  7. mydea commented on Apr 24, 2024

    @mydea
    Member

    I will look into it, it seems that something is really off there, sorry about that!

  8. mydea commented on Apr 24, 2024

    @mydea
    Member

    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 😅

  9. moved this to Waiting for: Community in GitHub Issues with 👀 2on Apr 24, 2024
  10. mpranjic24 commented on Apr 26, 2024

    @mpranjic24
    Author

    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 👍

  11. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 26, 2024
  12. s1gr1d commented on Apr 29, 2024

    @s1gr1d
    Member

    This seems to be fixed, so I am closing this 👍

  13. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions