sentry-react-sdk by getsentry/sentry-for-ai
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-react-sdk一个具有明确导向的向导,它会扫描您的 React 项目并指导您完成完整的 Sentry 设置。
@sentry/react、React Sentry SDK 或 Sentry 错误边界时注意: 下文中的 SDK 版本和 API 反映了撰写本文时最新的 Sentry 文档(
@sentry/react≥8.0.0)。在实施前,请务必根据 docs.sentry.io/platforms/javascript/guides/react/ 进行验证。
在提出任何建议之前,运行以下命令来了解项目情况:
# 检测 React 版本
cat package.json | grep -E '"react"|"react-dom"'
# 检查是否已存在 Sentry
cat package.json | grep '"@sentry/'
# 检测路由
cat package.json | grep -E '"react-router-dom"|"@tanstack/react-router"'
# 检测状态管理
cat package.json | grep -E '"redux"|"@reduxjs/toolkit"'
# 检测构建工具
ls vite.config.ts vite.config.js webpack.config.js craco.config.js 2>/dev/null
cat package.json | grep -E '"vite"|"react-scripts"|"webpack"'
# 检测日志库
cat package.json | grep -E '"pino"|"winston"|"loglevel"'
# 检查相邻目录中是否有配套的后端
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod ../requirements.txt ../Gemfile ../pom.xml 2>/dev/null | head -3
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
需要确定的内容:
| 问题 | 影响 |
|---|---|
| React 19+? | 使用 reactErrorHandler() 钩子模式 |
| React <19? | 使用 Sentry.ErrorBoundary |
@sentry/react 已存在? | 跳过安装,直接进入功能配置 |
react-router-dom v5 / v6 / v7? | 决定使用哪个路由集成 |
@tanstack/react-router? | 使用 tanstackRouterBrowserTracingIntegration() |
| 使用 Redux? | 推荐 createReduxEnhancer() |
| 检测到 Vite? | 通过 sentryVitePlugin 处理源映射 |
CRA (react-scripts)? | 在 CRACO 中通过 @sentry/webpack-plugin 处理源映射 |
| 找到后端目录? | 触发阶段 4 的跨链接建议 |
根据您的发现提出具体建议。不要问开放式问题——直接提出方案:
推荐(核心覆盖范围):
可选(增强可观测性):
Sentry.logger.* 实现结构化日志;当需要结构化日志搜索时推荐推荐逻辑:
| 功能 | 推荐时机... |
|---|---|
| 错误监控 | 始终 — 不可或缺的基线 |
| 追踪 | 对于 React SPA 始终推荐 — 页面加载 + 导航跨度具有高价值 |
| 会话回放 | 面向用户的应用、登录流程或结账页面 |
| 日志记录 | 应用需要结构化日志搜索或日志与追踪关联 |
| 性能剖析 | 性能关键型应用;服务器发送 Document-Policy: js-profiling 标头 |
React 特定附加项:
createRoot 上设置 reactErrorHandler()createReduxEnhancer() 添加到 Redux storesentryVitePlugin 以处理源映射(对可读的堆栈跟踪至关重要)建议:“我建议设置错误监控 + 追踪 + 会话回放。您希望我同时添加日志记录或性能剖析吗?”
npm install @sentry/react --save
src/instrument.tsSentry 必须在任何其他代码运行之前初始化。将 Sentry.init() 放在一个专用的辅助文件中:
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN, // 根据构建工具调整(见下表)
environment: import.meta.env.MODE,
release: import.meta.env.VITE_APP_VERSION, // 在构建时注入
sendDefaultPii: true,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
// 追踪
tracesSampleRate: 1.0, // 在生产环境中降低到 0.1–0.2
tracePropagationTargets: ["localhost", /^https:\/\/yourapi\.io/],
// 会话回放
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
enableLogs: true,
});
按构建工具划分的 DSN 环境变量:
| 构建工具 | 变量名 | 在代码中访问 |
|---|---|---|
| Vite | VITE_SENTRY_DSN | import.meta.env.VITE_SENTRY_DSN |
| Create React App | REACT_APP_SENTRY_DSN | process.env.REACT_APP_SENTRY_DSN |
| 自定义 webpack | SENTRY_DSN | process.env.SENTRY_DSN |
在您的入口文件中,将 instrument.ts 作为第一个导入:
// src/main.tsx (Vite) 或 src/index.tsx (CRA/webpack)
import "./instrument"; // ← 必须是第一个
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>
);
React 19+ — 在 createRoot 上使用 reactErrorHandler():
import { reactErrorHandler } from "@sentry/react";
createRoot(document.getElementById("root")!, {
onUncaughtError: reactErrorHandler(),
onCaughtError: reactErrorHandler(),
onRecoverableError: reactErrorHandler(),
}).render(<App />);
React <19 — 将您的应用包装在 Sentry.ErrorBoundary 中:
import * as Sentry from "@sentry/react";
createRoot(document.getElementById("root")!).render(
<Sentry.ErrorBoundary fallback={<p>Something went wrong</p>} showDialog>
<App />
</Sentry.ErrorBoundary>
);
对于任何需要独立捕获错误的子树(路由部分、小部件等),使用 <Sentry.ErrorBoundary>。
为您的路由配置匹配的集成:
| 路由 | 集成 | 说明 |
|---|---|---|
| React Router v7 | reactRouterV7BrowserTracingIntegration | 使用来自 react-router 的 useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes |
| React Router v6 | reactRouterV6BrowserTracingIntegration | 使用来自 react-router-dom 的 useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes |
| React Router v5 | reactRouterV5BrowserTracingIntegration | 使用 withSentryRouting(Route) 包装路由 |
| TanStack Router | tanstackRouterBrowserTracingIntegration(router) | 传递路由实例 — 无需钩子 |
| 无路由 / 自定义 | browserTracingIntegration() | 按 URL 路径命名事务 |
React Router v6/v7 设置:
// 在 instrument.ts 的 integrations 数组中:
import React from "react";
import {
createRoutesFromChildren, matchRoutes,
useLocation, useNavigationType,
} from "react-router-dom"; // 对于 v7 使用 "react-router"
import * as Sentry from "@sentry/react";
import { reactRouterV6BrowserTracingIntegration } from "@sentry/react";
import { createBrowserRouter } from "react-router-dom";
// 选项 A — createBrowserRouter (推荐用于 v6.4+):
const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV6(createBrowserRouter);
const router = sentryCreateBrowserRouter([...routes]);
// 选项 B — createBrowserRouter for React Router v7:
// const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouterV7(createBrowserRouter);
// 选项 C — 使用钩子的集成 (v6 无数据 API):
Sentry.init({
integrations: [
reactRouterV6BrowserTracingIntegration({
useEffect: React.useEffect,
useLocation,
useNavigationType,
matchRoutes,
createRoutesFromChildren,
}),
],
});
TanStack Router 设置:
import { tanstackRouterBrowserTracingIntegration } from "@sentry/react";
// 传递您的 TanStack 路由实例:
Sentry.init({
integrations: [tanstackRouterBrowserTracingIntegration(router)],
});
import * as Sentry from "@sentry/react";
import { configureStore } from "@reduxjs/toolkit";
const store = configureStore({
reducer: rootReducer,
enhancers: (getDefaultEnhancers) =>
getDefaultEnhancers().concat(Sentry.createReduxEnhancer()),
});
没有源映射,堆栈跟踪将显示压缩后的代码。设置构建插件以自动上传源映射:
Vite (vite.config.ts):
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
build: { sourcemap: "hidden" },
plugins: [
react(),
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});
添加到 .env(切勿提交):
SENTRY_AUTH_TOKEN=sntrys_...
SENTRY_ORG=my-org-slug
SENTRY_PROJECT=my-project-slug
Create React App (通过 CRACO):
npm install @craco/craco @sentry/webpack-plugin --save-dev
// craco.config.js
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
module.exports = {
webpack: {
plugins: {
add: [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
},
},
};
逐个功能进行指导。加载参考文件,按照其步骤操作,在继续之前进行验证:
| 功能 | 参考 | 何时加载 |
|---|---|---|
| 错误监控 | ${SKILL_ROOT}/references/error-monitoring.md | 始终(基线) |
| 追踪 | ${SKILL_ROOT}/references/tracing.md | SPA 导航 / API 调用追踪 |
| 会话回放 | ${SKILL_ROOT}/references/session-replay.md | 面向用户的应用 |
| 日志记录 | ${SKILL_ROOT}/references/logging.md | 结构化日志搜索 / 日志到追踪关联 |
| 性能剖析 | ${SKILL_ROOT}/references/profiling.md | 性能关键型应用 |
| React 功能 | ${SKILL_ROOT}/references/react-features.md | Redux、组件追踪、源映射、集成目录 |
对于每个功能:Read ${SKILL_ROOT}/references/<feature>.md,严格按照步骤操作,验证其是否有效。
Sentry.init() 选项| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
dsn | string | — | 必需。 为空时 SDK 被禁用 |
environment | string | "production" | 例如:"staging", "development" |
release | string | — | 例如:"my-app@1.0.0" 或 git SHA — 将错误链接到发布版本 |
sendDefaultPii | boolean | false | 包含 IP 地址和请求头 |
tracesSampleRate | number | — | 0–1;开发环境用 1.0,生产环境用 0.1–0.2 |
tracesSampler | function | — | 按事务采样;覆盖采样率 |
tracePropagationTargets | `(string | RegExp)[]` | — |
replaysSessionSampleRate | number | — | 记录所有会话的比例 |
replaysOnErrorSampleRate | number | — | 记录错误会话的比例 |
enableLogs | boolean | false | 启用 Sentry.logger.* API |
attachStacktrace | boolean | false | 在 captureMessage() 调用时附加堆栈跟踪 |
maxBreadcrumbs | number | 100 | 每个事件存储的面包屑数量 |
debug | boolean | false | 将 SDK 详细输出到控制台 |
tunnel | string | — | 代理 URL 以绕过广告拦截器 |
| React 版本 | 错误处理方法 | SDK 最低要求 |
|---|---|---|
| React 19+ | 在 createRoot 上使用 reactErrorHandler() | @sentry/react ≥8.0.0 |
| React 16–18 | Sentry.ErrorBoundary 组件 | @sentry/react ≥7.0.0 |
| React 16 | componentDidCatch 类边界 | @sentry/react ≥6.0.0 |
触发测试事件以确认 Sentry 正在接收数据:
// 在应用的任何位置添加一个临时的测试按钮
import * as Sentry from "@sentry/react";
function SentryTest() {
return (
<>
<button onClick={() => { throw new Error("Sentry React test error"); }}>
Test Error
</button>
<button onClick={() => Sentry.captureMessage("Sentry test message", "info")}>
Test Message
</button>
</>
);
}
检查 Sentry 仪表板:
如果没有任何内容出现,请在 Sentry.init() 中设置 debug: true 并检查浏览器控制台。
完成 React 设置后,检查是否有配套的后端缺少 Sentry 覆盖:
ls ../backend ../server ../api ../go ../python 2>/dev/null
cat ../go.mod 2>/dev/null | head -3
cat ../requirements.txt ../pyproject.toml 2>/dev/null | head -3
cat ../Gemfile 2>/dev/null | head -3
cat ../pom.xml 2>/dev/null | grep '<artifactId>' | head -3
如果存在未配置 Sentry 的后端,建议使用匹配的技能:
| 检测到的后端 | 建议技能 |
|---|---|
Go (go.mod) | sentry-go-sdk |
Python (requirements.txt, pyproject.toml) | sentry-python-sdk |
Ruby (Gemfile) | sentry-ruby-sdk |
Java (pom.xml, build.gradle) | 使用 @sentry/java — 参见 docs.sentry.io/platforms/java/ |
| Node.js (Express, Fastify) | 使用 @sentry/node — 参见 docs.sentry.io/platforms/javascript/guides/express/ |
| 问题 | 解决方案 |
|---|---|
| 事件未出现 | 设置 debug: true,检查 DSN,打开浏览器控制台查看 SDK 错误 |
| 源映射不工作 | 在生产模式下构建 (npm run build);验证 SENTRY_AUTH_TOKEN 是否已设置 |
| 堆栈跟踪被压缩 | 源映射未上传 — 检查插件配置和认证令牌 |
instrument.ts 未首先运行 | 验证它是入口文件中在 React/应用导入之前的第一个导入 |
| React 19 错误未捕获 | 确认 reactErrorHandler() 已传递给所有三个 createRoot 选项 |
| React <19 错误未捕获 | 确保 <Sentry.ErrorBoundary> 包装了组件树 |
路由事务命名为 <unknown> | 添加与您路由版本匹配的路由集成 |
tracePropagationTargets 不匹配 | 检查正则表达式转义;默认仅匹配 localhost 和您的 DSN 来源 |
| 会话回放未记录 | 确认 replayIntegration() 在 init 中;检查 replaysSessionSampleRate |
| Redux 操作未出现在面包屑中 | 将 Sentry.createReduxEnhancer() 添加到 store enhancers |
| 广告拦截器丢弃事件 | 设置 tunnel: "/sentry-tunnel" 并添加服务器端中继端点 |
| 回放存储成本高 | 降低 replaysSessionSampleRate;保持 replaysOnErrorSampleRate: 1.0 |
| 性能剖析不工作 | 验证文档响应是否设置了 Document-Policy: js-profiling 标头 |
每周安装数
292
仓库
GitHub 星标数
82
首次出现
2026年2月28日
安全审计
安装于
codex291
gemini-cli287
cursor287
github-copilot286
kimi-cli286
amp286
All Skills > SDK Setup > React SDK
Opinionated wizard that scans your React project and guides you through complete Sentry setup.
@sentry/react, React Sentry SDK, or Sentry error boundariesNote: SDK versions and APIs below reflect current Sentry docs at time of writing (
@sentry/react≥8.0.0). Always verify against docs.sentry.io/platforms/javascript/guides/react/ before implementing.
Run these commands to understand the project before making any recommendations:
# Detect React version
cat package.json | grep -E '"react"|"react-dom"'
# Check for existing Sentry
cat package.json | grep '"@sentry/'
# Detect router
cat package.json | grep -E '"react-router-dom"|"@tanstack/react-router"'
# Detect state management
cat package.json | grep -E '"redux"|"@reduxjs/toolkit"'
# Detect build tool
ls vite.config.ts vite.config.js webpack.config.js craco.config.js 2>/dev/null
cat package.json | grep -E '"vite"|"react-scripts"|"webpack"'
# Detect logging libraries
cat package.json | grep -E '"pino"|"winston"|"loglevel"'
# Check for companion backend in adjacent directories
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod ../requirements.txt ../Gemfile ../pom.xml 2>/dev/null | head -3
What to determine:
| Question | Impact |
|---|---|
| React 19+? | Use reactErrorHandler() hook pattern |
| React <19? | Use Sentry.ErrorBoundary |
@sentry/react already present? | Skip install, go straight to feature config |
react-router-dom v5 / v6 / v7? | Determines which router integration to use |
@tanstack/react-router? | Use tanstackRouterBrowserTracingIntegration() |
Present a concrete recommendation based on what you found. Don't ask open-ended questions — lead with a proposal:
Recommended (core coverage):
Optional (enhanced observability):
Sentry.logger.*; recommend when structured log search is neededRecommendation logic:
| Feature | Recommend when... |
|---|---|
| Error Monitoring | Always — non-negotiable baseline |
| Tracing | Always for React SPAs — page load + navigation spans are high-value |
| Session Replay | User-facing app, login flows, or checkout pages |
| Logging | App needs structured log search or log-to-trace correlation |
| Profiling | Performance-critical app; server sends Document-Policy: js-profiling header |
React-specific extras:
reactErrorHandler() on createRootcreateReduxEnhancer() to Redux storesentryVitePlugin for source maps (essential for readable stack traces)Propose: "I recommend setting up Error Monitoring + Tracing + Session Replay. Want me to also add Logging or Profiling?"
npm install @sentry/react --save
src/instrument.tsSentry must initialize before any other code runs. Put Sentry.init() in a dedicated sidecar file:
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN, // Adjust per build tool (see table below)
environment: import.meta.env.MODE,
release: import.meta.env.VITE_APP_VERSION, // inject at build time
sendDefaultPii: true,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
// Tracing
tracesSampleRate: 1.0, // lower to 0.1–0.2 in production
tracePropagationTargets: ["localhost", /^https:\/\/yourapi\.io/],
// Session Replay
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
enableLogs: true,
});
DSN environment variable by build tool:
| Build Tool | Variable Name | Access in code |
|---|---|---|
| Vite | VITE_SENTRY_DSN | import.meta.env.VITE_SENTRY_DSN |
| Create React App | REACT_APP_SENTRY_DSN | process.env.REACT_APP_SENTRY_DSN |
| Custom webpack | SENTRY_DSN | process.env.SENTRY_DSN |
Import instrument.ts as the very first import in your entry file:
// src/main.tsx (Vite) or src/index.tsx (CRA/webpack)
import "./instrument"; // ← MUST be first
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>
);
React 19+ — use reactErrorHandler() on createRoot:
import { reactErrorHandler } from "@sentry/react";
createRoot(document.getElementById("root")!, {
onUncaughtError: reactErrorHandler(),
onCaughtError: reactErrorHandler(),
onRecoverableError: reactErrorHandler(),
}).render(<App />);
React <19 — wrap your app in Sentry.ErrorBoundary:
import * as Sentry from "@sentry/react";
createRoot(document.getElementById("root")!).render(
<Sentry.ErrorBoundary fallback={<p>Something went wrong</p>} showDialog>
<App />
</Sentry.ErrorBoundary>
);
Use <Sentry.ErrorBoundary> for any sub-tree that should catch errors independently (route sections, widgets, etc.).
Configure the matching integration for your router:
| Router | Integration | Notes |
|---|---|---|
| React Router v7 | reactRouterV7BrowserTracingIntegration | useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes from react-router |
| React Router v6 | reactRouterV6BrowserTracingIntegration |
React Router v6/v7 setup:
// in instrument.ts integrations array:
import React from "react";
import {
createRoutesFromChildren, matchRoutes,
useLocation, useNavigationType,
} from "react-router-dom"; // or "react-router" for v7
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);
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):
Sentry.init({
integrations: [
reactRouterV6BrowserTracingIntegration({
useEffect: React.useEffect,
useLocation,
useNavigationType,
matchRoutes,
createRoutesFromChildren,
}),
],
});
TanStack Router setup:
import { tanstackRouterBrowserTracingIntegration } from "@sentry/react";
// Pass your TanStack router instance:
Sentry.init({
integrations: [tanstackRouterBrowserTracingIntegration(router)],
});
import * as Sentry from "@sentry/react";
import { configureStore } from "@reduxjs/toolkit";
const store = configureStore({
reducer: rootReducer,
enhancers: (getDefaultEnhancers) =>
getDefaultEnhancers().concat(Sentry.createReduxEnhancer()),
});
Without source maps, stack traces show minified code. Set up the build plugin to upload source maps automatically:
Vite (vite.config.ts):
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { sentryVitePlugin } from "@sentry/vite-plugin";
export default defineConfig({
build: { sourcemap: "hidden" },
plugins: [
react(),
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
});
Add to .env (never commit):
SENTRY_AUTH_TOKEN=sntrys_...
SENTRY_ORG=my-org-slug
SENTRY_PROJECT=my-project-slug
Create React App (via CRACO):
npm install @craco/craco @sentry/webpack-plugin --save-dev
// craco.config.js
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
module.exports = {
webpack: {
plugins: {
add: [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
},
},
};
Walk through features one at a time. Load the reference file, follow its steps, verify before moving on:
| Feature | Reference | Load when... |
|---|---|---|
| Error Monitoring | ${SKILL_ROOT}/references/error-monitoring.md | Always (baseline) |
| Tracing | ${SKILL_ROOT}/references/tracing.md | SPA navigation / API call tracing |
| Session Replay | ${SKILL_ROOT}/references/session-replay.md | User-facing app |
| Logging | ${SKILL_ROOT}/references/logging.md | Structured log search / log-to-trace |
| Profiling | ${SKILL_ROOT}/references/profiling.md |
For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.
Sentry.init() Options| Option | Type | Default | Notes |
|---|---|---|---|
dsn | string | — | Required. SDK disabled when empty |
environment | string | "production" | e.g., "staging", "development" |
| React Version | Error handling approach | SDK minimum |
|---|---|---|
| React 19+ | reactErrorHandler() on createRoot | @sentry/react ≥8.0.0 |
| React 16–18 | Sentry.ErrorBoundary component | @sentry/react ≥7.0.0 |
| React 16 | componentDidCatch class boundaries | @sentry/react ≥6.0.0 |
Trigger test events to confirm Sentry is receiving data:
// Add a temporary test button anywhere in your app
import * as Sentry from "@sentry/react";
function SentryTest() {
return (
<>
<button onClick={() => { throw new Error("Sentry React test error"); }}>
Test Error
</button>
<button onClick={() => Sentry.captureMessage("Sentry test message", "info")}>
Test Message
</button>
</>
);
}
Check the Sentry dashboard:
Set debug: true in Sentry.init() and check the browser console if nothing appears.
After completing React setup, check for a companion backend missing Sentry coverage:
ls ../backend ../server ../api ../go ../python 2>/dev/null
cat ../go.mod 2>/dev/null | head -3
cat ../requirements.txt ../pyproject.toml 2>/dev/null | head -3
cat ../Gemfile 2>/dev/null | head -3
cat ../pom.xml 2>/dev/null | grep '<artifactId>' | head -3
If a backend exists without Sentry configured, suggest the matching skill:
| Backend detected | Suggest skill |
|---|---|
Go (go.mod) | sentry-go-sdk |
Python (requirements.txt, pyproject.toml) | sentry-python-sdk |
Ruby (Gemfile) | sentry-ruby-sdk |
Java (pom.xml, ) |
| Issue | Solution |
|---|---|
| Events not appearing | Set debug: true, check DSN, open browser console for SDK errors |
| Source maps not working | Build in production mode (npm run build); verify SENTRY_AUTH_TOKEN is set |
| Minified stack traces | Source maps not uploading — check plugin config and auth token |
instrument.ts not running first | Verify it's the first import in entry file before React/app imports |
| React 19 errors not captured | Confirm reactErrorHandler() is passed to all three createRoot options |
Weekly Installs
292
Repository
GitHub Stars
82
First Seen
Feb 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex291
gemini-cli287
cursor287
github-copilot286
kimi-cli286
amp286
Electron应用自动化指南:使用agent-browser通过CDP实现桌面应用自动化
11,600 周安装
| Redux in use? | Recommend createReduxEnhancer() |
| Vite detected? | Source maps via sentryVitePlugin |
CRA (react-scripts)? | Source maps via @sentry/webpack-plugin in CRACO |
| Backend directory found? | Trigger Phase 4 cross-link suggestion |
useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes from react-router-dom |
| 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 |
| Performance-critical app |
| React Features | ${SKILL_ROOT}/references/react-features.md | Redux, component tracking, source maps, integrations catalog |
release | string | — | e.g., "my-app@1.0.0" or git SHA — links errors to releases |
sendDefaultPii | boolean | false | Includes IP addresses and request headers |
tracesSampleRate | number | — | 0–1; 1.0 in dev, 0.1–0.2 in prod |
tracesSampler | function | — | Per-transaction sampling; overrides rate |
tracePropagationTargets | `(string | RegExp)[]` | — |
replaysSessionSampleRate | number | — | Fraction of all sessions recorded |
replaysOnErrorSampleRate | number | — | Fraction of error sessions recorded |
enableLogs | boolean | false | Enable Sentry.logger.* API |
attachStacktrace | boolean | false | Stack traces on captureMessage() calls |
maxBreadcrumbs | number | 100 | Breadcrumbs stored per event |
debug | boolean | false | Verbose SDK output to console |
tunnel | string | — | Proxy URL to bypass ad blockers |
build.gradleUse @sentry/java — see docs.sentry.io/platforms/java/ |
| Node.js (Express, Fastify) | Use @sentry/node — see docs.sentry.io/platforms/javascript/guides/express/ |
| React <19 errors not captured | Ensure <Sentry.ErrorBoundary> wraps the component tree |
Router transactions named <unknown> | Add router integration matching your router version |
tracePropagationTargets not matching | Check regex escaping; default is localhost and your DSN origin only |
| Session replay not recording | Confirm replayIntegration() is in init; check replaysSessionSampleRate |
| Redux actions not in breadcrumbs | Add Sentry.createReduxEnhancer() to store enhancers |
| Ad blockers dropping events | Set tunnel: "/sentry-tunnel" and add server-side relay endpoint |
| High replay storage costs | Lower replaysSessionSampleRate; keep replaysOnErrorSampleRate: 1.0 |
| Profiling not working | Verify Document-Policy: js-profiling header is set on document responses |