Skip to content

Conversation

@inventarSarah
Copy link
Collaborator

DESCRIBE YOUR PR

Updated the React Router v6 and v7 documentation:

  • reduced the amount of alerts
  • reduced the amount of text at the top of the page to help users get to the first code snippet more quickly
    • I did this by merging the content that was originally at the top into the sections below; this also allows us to rely on the code snippets provided to give needed information (e.g. we don't need to list the imports as they are included in the code)

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

EXTRA RESOURCES

@vercel
Copy link

vercel bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2025 11:13am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2025 11:13am
develop-docs ⬜️ Ignored (Inspect) Visit Preview Apr 1, 2025 11:13am

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🤙

- Using `wrapCreateBrowserRouterV6` or `wrapCreateMemoryRouterV6`

</Alert>
_React Router v6 support is included in the `@sentry/react` package since version `7`._
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_React Router v6 support is included in the `@sentry/react` package since version `7`._

IMHO we can drop this, we are on v9 now 😅

description: "Learn about Sentry's React Router v6 integration."
sidebar_order: 20
---

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to lead with something like this:

Suggested change
You can instrument your React Router v6 setup with Sentry. Depending on how you use react-router, slightly different setups are needed:
<TableOfContents ignoreIds={["custom-error-boundary", "next-steps"]} />
Additionally, make sure to [Setup a Custom Error Boundary](#custom-error-boundary) to ensure rendering errors are captured to Sentry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and something similar for react-router v7 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mydea Good point! I updated the start of the page with an adapted version of your suggestion.

Sadly, the TableOfContents component does not work with our structure as it seems to be created to work with the SDK options pages, and our structure here is quite different -> I created an issue #13159 so we can consider upgrading the functionality of this component

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed here #13171 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the toc is now included - looks good!

need error boundaries to handle errors in event handlers.
</Alert>

To send errors to Sentry while using a custom error boundary, use the `Sentry.captureException` method:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to any change in this PR but generally: We should clarify here, because it is not clear to me: What If I am not using a custom error boundary, what should I do then? Should I add one to capture errors, or not? cc @lforst & @AbhiPrasad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for react router you need to add one, otherwise component-related errors get swallowed by the router itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, so let's reword this (can be a different PR as well) to make it clear you def should add this, not just if you're using a custom boundary!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a sentence to the first paragraph in this section (v6 and v7 pages) -- hope this is what you meant (if not, let's chat later today @mydea :) )

@codecov
Copy link

codecov bot commented Mar 31, 2025

Bundle Report

Changes will decrease total bundle size by 15 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.61MB -9 bytes (-0.0%) ⬇️
sentry-docs-client-array-push 9.45MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 868.67kB -0.0%
static/chunks/8931-*.js -3 bytes 397.42kB -0.0%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
server/middleware-*.js -5.55kB 1.0kB -84.74%
static/-*.js (New) 578 bytes 578 bytes 100.0% 🚀
static/-*.js (New) 77 bytes 77 bytes 100.0% 🚀
static/4H_mQVYD1xFY-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/4H_mQVYD1xFY-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.58MB -0.0%
../instrumentation.js -3 bytes 911.63kB -0.0%
9523.js -3 bytes 887.68kB -0.0%

Now, Sentry should generate `pageload`/`navigation` transactions with parameterized transaction names (for example, `/teams/:teamid/user/:userid`), where applicable. This is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.

### Custom Error Boundaries
## Usage With Custom Error Boundaries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Usage With Custom Error Boundaries
## Set Up A Custom Error Boundary

IMHO I would rephrase this like this, as everybody should follow this step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this on v6 and v7 pages

Comment on lines 161 to 164
<Alert>
Note, that this only applies to render method and lifecycle errors since React
doesn't need error boundaries to handle errors in event handlers.
This only applies to render method and lifecycle errors since React doesn't
need error boundaries to handle errors in event handlers.
</Alert>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this section helpful? What does it tell me? 😅 I should set this up anyhow to get all errors, I'd say?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this whole alert here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it vor v6 and v7 👍

Now, Sentry should generate `pageload`/`navigation` transactions with parameterized transaction names (for example, `/teams/:teamid/user/:userid`), where applicable. This is only needed at the top level of your app, unlike React Router v4/v5, which required wrapping every `<Route />` you wanted parametrized.

### Custom Error Boundaries
## Usage With Custom Error Boundaries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above?

In production, these errors won't surface unless captured manually. If you **don't** have a custom error boundary in place, `react-router` will create a default one that "swallows" all errors.\
Hence, to capture these errors with Sentry in production, we strongly recommend to implement a custom error boundary.

<Alert>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, do we need this alert?

@inventarSarah inventarSarah merged commit 78869b0 into master Apr 1, 2025
11 checks passed
@inventarSarah inventarSarah deleted the smi/react/router-clean-up branch April 1, 2025 14:18
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants