-
-
Notifications
You must be signed in to change notification settings - Fork 30
[skill-drift] update(sentry-react-sdk): document React Router v8 support and compatibility APIs #212
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
base: main
Are you sure you want to change the base?
[skill-drift] update(sentry-react-sdk): document React Router v8 support and compatibility APIs #212
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| name: sentry-react-sdk | ||
| description: Full Sentry SDK setup for React. Use when asked to "add Sentry to React", "install @sentry/react", or configure error monitoring, tracing, session replay, profiling, or logging for React applications. Supports React 16+, React Router v5-v7 non-framework mode, TanStack Router, Redux, Vite, and webpack. | ||
| description: Full Sentry SDK setup for React. Use when asked to "add Sentry to React", "install @sentry/react", or configure error monitoring, tracing, session replay, profiling, or logging for React applications. Supports React 16+, React Router v5-v8 non-framework mode, TanStack Router, Redux, Vite, and webpack. | ||
| license: Apache-2.0 | ||
| category: sdk-setup | ||
| parent: sentry-sdk-setup | ||
|
|
@@ -18,7 +18,7 @@ Opinionated wizard that scans your React project and guides you through complete | |
| - User asks to "add Sentry to React" or "set up Sentry" in a React app | ||
| - User wants error monitoring, tracing, session replay, profiling, or logging in React | ||
| - User mentions `@sentry/react`, React Sentry SDK, or Sentry error boundaries | ||
| - User wants to monitor React Router v5/v6/v7 non-framework navigation, Redux state, or component performance | ||
| - User wants to monitor React Router v5/v6/v7/v8 non-framework navigation, Redux state, or component performance | ||
|
|
||
| If project is React Router **Framework mode** using `@sentry/react-router`, use `sentry-react-router-framework-sdk` instead of this skill. | ||
|
|
||
|
|
@@ -64,7 +64,7 @@ cat ../go.mod ../requirements.txt ../Gemfile ../pom.xml 2>/dev/null | head -3 | |
| | React <19? | Use `Sentry.ErrorBoundary` | | ||
| | `@sentry/react` already present? | Skip install, go straight to feature config | | ||
| | React Router Framework mode indicators (`@sentry/react-router`, `@react-router/*`)? | Use `sentry-react-router-framework-sdk` | | ||
| | `react-router-dom` v5 / v6 / v7? | Determines which router integration to use | | ||
| | `react-router-dom` v5 / v6 / v7 / v8? | Determines which router integration to use | | ||
| | `@tanstack/react-router`? | Use `tanstackRouterBrowserTracingIntegration()` | | ||
| | Redux in use? | Recommend `createReduxEnhancer()` | | ||
| | Vite detected? | Source maps via `sentryVitePlugin` | | ||
|
|
@@ -98,7 +98,7 @@ Present a concrete recommendation based on what you found. Don't ask open-ended | |
|
|
||
| **React-specific extras:** | ||
| - React 19 detected → set up `reactErrorHandler()` on `createRoot` | ||
| - React Router v5/v6/v7 non-framework detected → configure matching router integration (see Phase 3) | ||
| - React Router v5/v6/v7/v8 non-framework detected → configure matching router integration (see Phase 3) | ||
| - React Router Framework mode detected → switch to `sentry-react-router-framework-sdk` | ||
| - Redux detected → add `createReduxEnhancer()` to Redux store | ||
| - Vite detected → configure `sentryVitePlugin` for source maps (essential for readable stack traces) | ||
|
|
@@ -215,36 +215,33 @@ Configure the matching integration for your router (non-framework mode): | |
|
|
||
| | Router | Integration | Notes | | ||
| |--------|------------|-------| | ||
| | React Router v7 | `reactRouterV7BrowserTracingIntegration` | `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren`, `matchRoutes` from `react-router` | | ||
| | React Router v6 | `reactRouterV6BrowserTracingIntegration` | `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren`, `matchRoutes` from `react-router-dom` | | ||
| | React Router v6/v7/v8 | `reactRouterBrowserTracingIntegration` | **Recommended** — works across v6+; pass hooks from your router package | | ||
| | React Router v7 | `reactRouterV7BrowserTracingIntegration` | Version-specific API (deprecated in favor of compatibility API) | | ||
| | React Router v6 | `reactRouterV6BrowserTracingIntegration` | Version-specific API (deprecated in favor of compatibility API) | | ||
| | React Router v5 | `reactRouterV5BrowserTracingIntegration` | Wrap routes in `withSentryRouting(Route)` | | ||
| | TanStack Router | `tanstackRouterBrowserTracingIntegration(router)` | Pass router instance — no hooks required | | ||
| | No router / custom | `browserTracingIntegration()` | Names transactions by URL path | | ||
|
|
||
| **React Router v6/v7 setup:** | ||
| **React Router v6/v7/v8 setup (recommended — compatibility APIs):** | ||
|
|
||
| ```typescript | ||
| // in instrument.ts integrations array: | ||
| import React from "react"; | ||
| import { | ||
| createRoutesFromChildren, matchRoutes, | ||
| useLocation, useNavigationType, | ||
| } from "react-router-dom"; // or "react-router" for v7 | ||
| } from "react-router-dom"; // or "react-router" for v7/v8 | ||
| import * as Sentry from "@sentry/react"; | ||
| import { reactRouterV6BrowserTracingIntegration } from "@sentry/react"; | ||
| import { createBrowserRouter } from "react-router-dom"; | ||
|
|
||
| // Option A — createBrowserRouter (recommended for v6.4+): | ||
| const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV6(createBrowserRouter); | ||
| // Option A — createBrowserRouter (recommended for v6.4+ / v7+ / v8+): | ||
| const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter); | ||
| const router = sentryCreateBrowserRouter([...routes]); | ||
|
|
||
| // Option B — createBrowserRouter for React Router v7: | ||
| // const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV7(createBrowserRouter); | ||
|
|
||
| // Option C — integration with hooks (v6 without data APIs): | ||
| // Option B — integration with hooks (for useRoutes or Routes component): | ||
| Sentry.init({ | ||
| integrations: [ | ||
| reactRouterV6BrowserTracingIntegration({ | ||
| Sentry.reactRouterBrowserTracingIntegration({ | ||
| useEffect: React.useEffect, | ||
| useLocation, | ||
| useNavigationType, | ||
|
|
@@ -253,6 +250,20 @@ Sentry.init({ | |
| }), | ||
| ], | ||
| }); | ||
|
|
||
| // Option C — wrap useRoutes hook: | ||
| const sentryUseRoutes = Sentry.wrapUseRoutes(useRoutes); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The skill recommends using Suggested FixUpdate Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| // then use sentryUseRoutes in your components | ||
| ``` | ||
|
|
||
| **Version-specific APIs (deprecated, use compatibility APIs above):** | ||
|
|
||
| ```typescript | ||
| // React Router v6 — use wrapCreateBrowserRouterV6 (deprecated): | ||
| // const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV6(createBrowserRouter); | ||
|
|
||
| // React Router v7 — use wrapCreateBrowserRouterV7 (deprecated): | ||
| // const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV7(createBrowserRouter); | ||
| ``` | ||
|
|
||
| **TanStack Router setup:** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The
SKILL.mdfile recommends new APIs, but the referencedtracing.mdfile, which must be followed "exactly," only contains outdated, version-specific APIs, creating a contradiction.Severity: MEDIUM
Suggested Fix
Update the
references/tracing.mdfile to include the new generic compatibility APIs (reactRouterBrowserTracingIntegration,wrapCreateBrowserRouter,wrapUseRoutes). Ensure its guidance is consistent with the primary recommendations inSKILL.md.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.