Skip to content

NextJS Sentry is using deprecated beforeNavigate instead of beforeStartSpan #11627

Closed
@mpranjic24

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions