Conversation
Expose isBotUserAgent from the browser tracing integration and use it in the Next.js wrapper so bot user agents also skip the Next.js-specific router instrumentation path. This is the smallest change to validate the fix. Longer term, we probably want a more general mechanism for integrations to skip their own setup and make that skip decision easy to downstream through wrappers and variants. Co-Authored-By: GPT-5.4 <noreply@anthropic.com>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Cloudflare
Core
Deps
Other
Bug Fixes 🐛Deno
Other
Internal Changes 🔧Ci
Deps
Other
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Pull request overview
This PR addresses bot-rendering issues in Next.js by ensuring bot user agents (e.g. Googlebot) don’t trigger Next.js-specific router instrumentation (notably the router polling timer), by reusing a shared bot user-agent predicate from the browser tracing integration.
Changes:
- Export
isBotUserAgent()from the Browser Tracing integration (and re-export it via@sentry/browserbundles). - Use
isBotUserAgent()in the Next.js Browser Tracing wrapper to skip Next.js router instrumentation for bots. - Add a Next.js unit regression test to ensure Googlebot doesn’t start the router polling interval.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/nextjs/src/client/browserTracingIntegration.ts | Skips Next.js router instrumentation in afterAllSetup for bot user agents. |
| packages/nextjs/test/clientSdk.test.ts | Adds regression test asserting no setInterval polling starts for Googlebot. |
| packages/browser/src/tracing/browserTracingIntegration.ts | Makes bot UA detection helper public (isBotUserAgent) and uses it internally. |
| packages/browser/src/index.ts | Re-exports isBotUserAgent from the browser package entrypoint. |
| packages/browser/src/index.bundle.tracing.ts | Re-exports isBotUserAgent in tracing bundle. |
| packages/browser/src/index.bundle.tracing.replay.ts | Re-exports isBotUserAgent in tracing+replay bundle. |
| packages/browser/src/index.bundle.tracing.replay.logs.metrics.ts | Re-exports isBotUserAgent in tracing+replay+logs+metrics bundle. |
| packages/browser/src/index.bundle.tracing.replay.feedback.ts | Re-exports isBotUserAgent in tracing+replay+feedback bundle. |
| packages/browser/src/index.bundle.tracing.replay.feedback.logs.metrics.ts | Re-exports isBotUserAgent in tracing+replay+feedback+logs+metrics bundle. |
| packages/browser/src/index.bundle.tracing.logs.metrics.ts | Re-exports isBotUserAgent in tracing+logs+metrics bundle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| init({ | ||
| dsn: TEST_DSN, | ||
| tracesSampleRate: 1.0, | ||
| }); | ||
|
|
||
| expect(setIntervalSpy).not.toHaveBeenCalled(); |
size-limit report 📦
|
chargome
left a comment
There was a problem hiding this comment.
Thanks for looking into this. A band-aid for next, but let's see if this solves the user's issue
…20263) Exposes `isBotUserAgent()` from the browser tracing integration to use it in the Next.js browser tracing wrapper so bot user agents also skip Next.js-specific router instrumentation which adds its own interval timer. This is intentionally the smallest change to test whether this fixes the Googlebot rendering issue. Longer term, we probably want a more general mechanism for integrations to skip their own setup, with a skip decision that can be downstreamed easily through wrappers and integration variants instead of checking the bot predicate ad hoc in each package. closes #19670 Co-authored-by: GPT-5.4 <noreply@anthropic.com>
Exposes
isBotUserAgent()from the browser tracing integration to use it in the Next.js browser tracing wrapper so bot user agents also skip Next.js-specific router instrumentation which adds its own interval timer.This is intentionally the smallest change to test whether this fixes the Googlebot rendering issue.
Longer term, we probably want a more general mechanism for integrations to skip their own setup, with a skip decision that can be downstreamed easily through wrappers and integration variants instead of checking the bot predicate ad hoc in each package.
closes #19670