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

Pageloads traces aren't being captured by sentry/nextjs #12914

Closed
3 tasks done
purplecandy opened this issue Jul 15, 2024 · 2 comments · Fixed by #12933
Closed
3 tasks done

Pageloads traces aren't being captured by sentry/nextjs #12914

purplecandy opened this issue Jul 15, 2024 · 2 comments · Fixed by #12933
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@purplecandy
Copy link

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

8.17.0

Framework Version

Next 13.5.6 (Pages Router)

Link to Sentry event

No response

SDK Setup/Reproduction Example

Sentry.init({
    dsn: SENTRY_DSN,
    integrations: [
      Sentry.browserTracingIntegration({
        instrumentNavigation: true,
        instrumentPageLoad: true,
        enableInp: true,
        enableLongTask: true,
      }),
      Sentry.breadcrumbsIntegration({
        console: false,
      }),
    ],
    tracesSampleRate: 0.15,
    beforeSend: (event, hints) => {
      const location = window?.location?.href
      const area = getAreaFromUrl(location)
      if (!event.tags) return event
      event.tags.area = area

      return event
    },
  })

Steps to Reproduce

  1. Enter the URL of the page in the browser or refresh any page
  2. Once the page is done loading and the idle timeout is over - sentry should capture a page load event with Web Vitals

Expected Result

Sentry should track page load operations with web vitals.

Actual Result

Sentry only tracks navigation operations and leaves out page loads and web vitals reports.

@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Jul 15, 2024
@andreiborza andreiborza self-assigned this Jul 15, 2024
@andreiborza
Copy link
Member

Hello, thanks for writing in.
Could you please post a reproduction repo or a stackblitz to make sure we're on the same page?

To narrow down the issue, please set debug: true and tracesSampleRate: 1.0 in both sentry.client.config.ts and sentry.server.config.ts and set disableLogger to false inside next.config.js. Run your app and paste logs you get in the console. You should see a transaction id for the pageload in your log. Additionally, could please you verify in the network tab that the request payload for the envelope api call contains the transaction id of the pageload?

I've tried this out locally and I was able to get pageload spans, albeit sporadically. That's something we need to look into.

@andreiborza
Copy link
Member

@purplecandy could you also please add

  beforeSendTransaction(event, hint) {
    event.spans?.forEach((span) =>
        console.log(`Duration for span ${span.description}: ${span.timestamp! - span.start_timestamp}`)
    );

    return event;
  },

to your sentry.client.config.ts Sentry.init call and paste console output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants