sentry-react-native-setup by getsentry/sentry-agent-skills
npx skills add https://github.com/getsentry/sentry-agent-skills --skill sentry-react-native-setup使用官方向导 CLI 在 React Native 项目中安装并配置 Sentry。
重要提示: 下方的配置选项和代码示例仅供参考。在实施前,请务必查阅 docs.sentry.io 进行核实,因为 API 和默认值可能已发生变化。
npx @sentry/wizard@latest -i reactNative
| 任务 | 描述 |
|---|---|
| 安装 SDK | 添加 @sentry/react-native 包 |
| Metro 配置 | 在 metro.config.js 中添加 @sentry/react-native/metro |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| Expo 配置 | 在 app.json 中添加 @sentry/react-native/expo |
| Android 设置 | 启用用于生成源映射的 Gradle 构建步骤 |
| iOS 设置 | 包装 Xcode 构建阶段,添加调试符号上传 |
| Pod 安装 | 为 iOS 运行 pod install |
| 凭证存储 | 存储在 ios/sentry.properties、android/sentry.properties、env.local 中 |
| 初始化代码 | 在 App.tsx 或 _layout.tsx 中配置 Sentry |
如果不使用向导,请在应用入口点添加以下代码:
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
sendDefaultPii: true,
// 追踪
tracesSampleRate: 1.0,
// 日志
enableLogs: true,
// 性能分析
profilesSampleRate: 1.0,
// 会话回放
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
integrations: [Sentry.mobileReplayIntegration()],
});
export default Sentry.wrap(App);
对于 Expo 项目,请遵循 Expo 专属设置指南:
npx @sentry/wizard@latest -i reactNative
适用于托管式(managed)和裸(bare)Expo 项目。
| 选项 | 描述 | 默认值 |
|---|---|---|
dsn | Sentry DSN | 必填 |
sendDefaultPii | 是否包含用户数据 | false |
tracesSampleRate | 被追踪事务的百分比 | 0 |
profilesSampleRate | 被分析追踪的百分比 | 0 |
enableLogs | 是否将日志发送到 Sentry | false |
replaysOnErrorSampleRate | 发生错误的会话中被回放的百分比 | 0 |
replaysSessionSampleRate | 所有会话中被回放的百分比 | 0 |
| 文件 | 用途 |
|---|---|
App.js / _layout.tsx | Sentry 初始化 |
metro.config.js | Metro 打包器配置 |
app.json | Expo 配置(如果是 Expo 项目) |
ios/sentry.properties | iOS 构建凭证 |
android/sentry.properties | Android 构建凭证 |
env.local | 环境变量 |
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
添加测试错误:
throw new Error("My first Sentry error!");
或使用测试按钮:
<Button title="Test Sentry" onPress={() => { throw new Error("Test"); }} />
当向导配置完成后,源映射会在构建过程中自动上传:
| 问题 | 解决方案 |
|---|---|
| 向导失败 | 尝试手动设置,检查 Node 版本 |
| iOS 构建失败 | 运行 cd ios && pod install |
| 源映射未上传 | 验证 sentry.properties 文件是否包含认证令牌 |
| Expo 错误 | 确保使用兼容的 Expo SDK 版本 |
| 应用未包装 | 添加 export default Sentry.wrap(App) |
每周安装量
126
代码仓库
GitHub 星标数
19
首次出现
Jan 21, 2026
安全审计
安装于
opencode107
codex105
gemini-cli101
claude-code101
cursor92
github-copilot92
Install and configure Sentry in React Native projects using the official wizard CLI.
Important: The configuration options and code samples below are examples. Always verify against docs.sentry.io before implementing, as APIs and defaults may have changed.
npx @sentry/wizard@latest -i reactNative
| Task | Description |
|---|---|
| Install SDK | Adds @sentry/react-native package |
| Metro config | Adds @sentry/react-native/metro to metro.config.js |
| Expo config | Adds @sentry/react-native/expo to app.json |
| Android setup | Enables Gradle build step for source maps |
| iOS setup | Wraps Xcode build phase, adds debug symbol upload |
| Pod install | Runs pod install for iOS |
| Credentials | Stores in ios/sentry.properties, android/sentry.properties, env.local |
| Init code | Configures Sentry in App.tsx or _layout.tsx |
If not using wizard, add to your app entry point:
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
sendDefaultPii: true,
// Tracing
tracesSampleRate: 1.0,
// Logs
enableLogs: true,
// Profiling
profilesSampleRate: 1.0,
// Session Replay
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
integrations: [Sentry.mobileReplayIntegration()],
});
export default Sentry.wrap(App);
For Expo, follow the Expo-specific setup:
npx @sentry/wizard@latest -i reactNative
Works for both managed and bare Expo projects.
| Option | Description | Default |
|---|---|---|
dsn | Sentry DSN | Required |
sendDefaultPii | Include user data | false |
tracesSampleRate | % of transactions traced | 0 |
profilesSampleRate | % of traces profiled |
| File | Purpose |
|---|---|
App.js / _layout.tsx | Sentry initialization |
metro.config.js | Metro bundler config |
app.json | Expo config (if Expo) |
ios/sentry.properties | iOS build credentials |
android/sentry.properties | Android build credentials |
env.local |
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
Add test error:
throw new Error("My first Sentry error!");
Or use a test button:
<Button title="Test Sentry" onPress={() => { throw new Error("Test"); }} />
Source maps are automatically uploaded during build when wizard configures:
| Issue | Solution |
|---|---|
| Wizard fails | Try manual setup, check Node version |
| iOS build fails | Run cd ios && pod install |
| Source maps not uploading | Verify sentry.properties files have auth token |
| Expo errors | Ensure using compatible Expo SDK version |
| App not wrapped | Add export default Sentry.wrap(App) |
Weekly Installs
126
Repository
GitHub Stars
19
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykPass
Installed on
opencode107
codex105
gemini-cli101
claude-code101
cursor92
github-copilot92
Convex性能审计指南 - 诊断修复Convex应用性能问题与优化方案
14,200 周安装
第一性原理框架(FPF)提出假设工作流:AI辅助生成与验证竞争性假设
218 周安装
e2e-tests-studio:基于Playwright的端到端行为测试框架,专注验证产品功能而非UI状态
274 周安装
Lobe Chat 环境变量配置指南:添加用户设置服务端环境变量
243 周安装
线性任务规划器(协调器)ln-300-task-coordinator:AI驱动的任务分解与自动化协调工具
198 周安装
项目核心文档自动创建器 - 基于AI的架构、需求、技术栈文档生成工具
201 周安装
Agent Teams 编排手册:多智能体并行协作与任务管理指南
180 周安装
0enableLogs | Send logs to Sentry | false |
replaysOnErrorSampleRate | % of error sessions replayed | 0 |
replaysSessionSampleRate | % of all sessions replayed | 0 |
| Environment variables |