T
TanStackβ€’17mo ago
stormy-gold

Has anyone integrated sentry with router?

I'm searching for something like sentry integration for react router but for the TanStack router, has anyone done some integration?
17 Replies
eastern-cyan
eastern-cyanβ€’17mo ago
GitHub.com/TanStack/tanstack.com uses sentry
stormy-gold
stormy-goldOPβ€’17mo ago
Cool, thanks πŸ™‚
reduced-jade
reduced-jadeβ€’16mo ago
I just looked into this and I'm not sure how this tracks errors that are caught by error boundaries? It doesn't use the ErrorBoundary by sentry and it also doesn't use Sentry.captureException. usually, we did that in the onError handler of the ErrorBoundary, but since tanstack-router uses its own CatchBoundary, which we can't customize, I'm not sure how to track these errors.. any idea how that works on the tanstack page @Sean Cassiere ?
eastern-cyan
eastern-cyanβ€’16mo ago
Honestly no clue how it works on the tanstack website, it was recently added by @Tanner Linsley I believe. Reading the Sentry's docs, we could probably use their CaptureConsole integration which captures logs from the console. And since TSR logs everything to the console, this'd probably catch that.
eastern-cyan
eastern-cyanβ€’16mo ago
A un-optimal way of approaching this, could possibly be to wrap the individual pages in the <Sentry.ErrorBoundary> component. https://docs.sentry.io/platforms/javascript/guides/react/features/error-boundary/#options
React Error Boundary | Sentry for React
Learn how the React SDK exports an error boundary component that leverages React component APIs.
wise-white
wise-whiteβ€’16mo ago
They have a PR open for an integration right now. Right? I’ve been buried in Start, and haven’t had time to come up for air.
reduced-jade
reduced-jadeβ€’16mo ago
I think it's not good that we just do console.error on production - I wanted to suggest to move away from this. In query, lots of people were confused about console errors just because a fetch returned 404, and we have the same here with route loaders
wise-white
wise-whiteβ€’16mo ago
πŸ‘ Nuke it
reduced-jade
reduced-jadeβ€’16mo ago
If you wrap a page in your own ErrorBoundary then you won't be able to use errorComponent. Ideally, CatchBoundary could be customized but I hit a wall with this last time I tried I think we should be able to add an onError and defaultOnError property to the router and routes, which can call form our own CatchBoundary. That shoud be enough to add sentry error tracking. I'll try to do this next to removing the manual console.error statements πŸ™‚
reduced-jade
reduced-jadeβ€’16mo ago
stormy-gold
stormy-goldOPβ€’16mo ago
Last time I checked, they didn't have plans to implement it (https://github.com/getsentry/sentry-javascript/issues/7927), but I checked again today and someone started the implementation (https://github.com/getsentry/sentry-javascript/pull/12095) and the person who opens the PR is calling for you πŸ˜…
GitHub
Issues Β· getsentry/sentry-javascript
Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
GitHub
Initial TanStack Router Integration by MicahLyle Β· Pull Request #12...
Before submitting a pull request, please take a look at our Contributing guidelines and verify: If you've added code that should be tested, please add tests. Ensure your code lints and the t...
stormy-gold
stormy-goldOPβ€’16mo ago
I'm seeing that there are forces trying to implement this feature, so I'll follow the updates. Thank you all.
reduced-jade
reduced-jadeβ€’16mo ago
πŸŽ‰
continuing-cyan
continuing-cyanβ€’16mo ago
πŸ‘‹ Worked on this with Luca at React Conf.
correct-apricot
correct-apricotβ€’16mo ago
PR got merged πŸ₯³
like-gold
like-goldβ€’16mo ago
We immediately implemented this. Reallt nice πŸ™‚
wise-white
wise-whiteβ€’16mo ago
So cool! Thanks everyone!

Did you find this page helpful?