feat: Add setup skills for React, Python, Ruby, and React Native

This commit is contained in:
Cody De Arkland
2026-01-13 23:15:36 -08:00
parent d1bef7ec55
commit 3b4f20114b
5 changed files with 589 additions and 0 deletions
+8
View File
@@ -9,6 +9,10 @@ Official agent skills for integrating Sentry into your projects. These skills pr
| Skill | Description | Platforms | Docs |
|-------|-------------|-----------|------|
| `sentry-nextjs-wizard` | Setup Sentry in Next.js using the wizard CLI | Next.js | [Next.js Guide](https://docs.sentry.io/platforms/javascript/guides/nextjs/) |
| `sentry-react-wizard` | Setup Sentry in React apps | React | [React Guide](https://docs.sentry.io/platforms/javascript/guides/react/) |
| `sentry-react-native-wizard` | Setup Sentry in React Native using the wizard CLI | React Native, Expo | [React Native Guide](https://docs.sentry.io/platforms/react-native/) |
| `sentry-python-wizard` | Setup Sentry in Python apps (Django, Flask, FastAPI) | Python | [Python Guide](https://docs.sentry.io/platforms/python/) |
| `sentry-ruby-wizard` | Setup Sentry in Ruby apps (Rails) | Ruby | [Ruby Guide](https://docs.sentry.io/platforms/ruby/) |
| `sentry-setup-tracing` | Setup tracing, transactions, spans, and performance monitoring | JS, Python, Ruby | [Tracing](https://docs.sentry.io/platforms/javascript/tracing/) |
| `sentry-setup-logging` | Setup structured logging and integrate Pino/Winston/Loguru | JS, Python, Ruby | [Logs](https://docs.sentry.io/platforms/javascript/logs/) |
| `sentry-setup-metrics` | Setup custom metrics (counters, gauges, distributions) | JS, Python | [Metrics](https://docs.sentry.io/platforms/javascript/metrics/) |
@@ -257,6 +261,10 @@ Once installed, your AI assistant will automatically discover the skills. Simply
| What to Say | Skill Used |
|-------------|------------|
| "Set up Sentry in my Next.js app" | `sentry-nextjs-wizard` |
| "Add Sentry to my React app" | `sentry-react-wizard` |
| "Set up Sentry in React Native" | `sentry-react-native-wizard` |
| "Add Sentry to my Python/Django/Flask app" | `sentry-python-wizard` |
| "Set up Sentry in my Ruby/Rails app" | `sentry-ruby-wizard` |
| "Add performance monitoring to my app" | `sentry-setup-tracing` |
| "Enable Sentry logging" | `sentry-setup-logging` |
| "Track custom metrics with Sentry" | `sentry-setup-metrics` |
+166
View File
@@ -0,0 +1,166 @@
---
name: sentry-python-wizard
description: Setup Sentry in Python apps. Use when asked to add Sentry to Python, install sentry-sdk, or configure error monitoring for Python applications, Django, Flask, FastAPI.
---
# Sentry Python Setup
Install and configure Sentry in Python projects.
## Invoke This Skill When
- User asks to "add Sentry to Python" or "install Sentry" in a Python app
- User wants error monitoring, logging, or tracing in Python
- User mentions "sentry-sdk" or Python frameworks (Django, Flask, FastAPI)
## Install
```bash
pip install sentry-sdk
```
## Configure
Initialize as early as possible in your application:
```python
import sentry_sdk
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
send_default_pii=True,
# Tracing
traces_sample_rate=1.0,
# Profiling
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
# Logs
enable_logs=True,
)
```
### Async Applications
For async apps, initialize inside an async function:
```python
import asyncio
import sentry_sdk
async def main():
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
send_default_pii=True,
traces_sample_rate=1.0,
enable_logs=True,
)
# ... rest of app
asyncio.run(main())
```
## Framework Integrations
### Django
```python
# settings.py
import sentry_sdk
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
send_default_pii=True,
traces_sample_rate=1.0,
enable_logs=True,
)
```
### Flask
```python
from flask import Flask
import sentry_sdk
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
send_default_pii=True,
traces_sample_rate=1.0,
enable_logs=True,
)
app = Flask(__name__)
```
### FastAPI
```python
from fastapi import FastAPI
import sentry_sdk
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
send_default_pii=True,
traces_sample_rate=1.0,
enable_logs=True,
)
app = FastAPI()
```
## Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `send_default_pii` | Include user data | `False` |
| `traces_sample_rate` | % of transactions traced | `0` |
| `profile_session_sample_rate` | % of sessions profiled | `0` |
| `enable_logs` | Send logs to Sentry | `False` |
| `environment` | Environment name | Auto-detected |
| `release` | Release version | Auto-detected |
## Environment Variables
```bash
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```
Or use in code:
```python
import os
import sentry_sdk
sentry_sdk.init(
dsn=os.environ.get("SENTRY_DSN"),
# ...
)
```
## Verification
```python
# Intentional error to test
division_by_zero = 1 / 0
```
Or capture manually:
```python
sentry_sdk.capture_message("Test message from Python")
```
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Errors not appearing | Ensure `init()` is called early, check DSN |
| No traces | Set `traces_sample_rate` > 0 |
| IPython errors not captured | Run from file, not interactive shell |
| Async errors missing | Initialize inside async function |
+138
View File
@@ -0,0 +1,138 @@
---
name: sentry-react-native-wizard
description: Setup Sentry in React Native using the wizard CLI. Use when asked to add Sentry to React Native, install @sentry/react-native, or configure error monitoring for React Native or Expo apps.
---
# Sentry React Native Wizard
Install and configure Sentry in React Native projects using the official wizard CLI.
## Invoke This Skill When
- User asks to "add Sentry to React Native" or "install Sentry" in a React Native app
- User wants error monitoring, logging, or tracing in React Native or Expo
- User mentions "@sentry/react-native" or mobile error tracking
## Wizard Setup (Recommended)
```bash
npx @sentry/wizard@latest -i reactNative
```
### What the Wizard Does
| 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` |
## Manual Configuration
If not using wizard, add to your app entry point:
```javascript
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()],
});
```
### Wrap Your App
```javascript
export default Sentry.wrap(App);
```
## Expo Projects
For Expo, follow the [Expo-specific setup](https://docs.sentry.io/platforms/react-native/manual-setup/expo/):
```bash
npx @sentry/wizard@latest -i reactNative
```
Works for both managed and bare Expo projects.
## Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `sendDefaultPii` | Include user data | `false` |
| `tracesSampleRate` | % of transactions traced | `0` |
| `profilesSampleRate` | % of traces profiled | `0` |
| `enableLogs` | Send logs to Sentry | `false` |
| `replaysOnErrorSampleRate` | % of error sessions replayed | `0` |
| `replaysSessionSampleRate` | % of all sessions replayed | `0` |
## Files Created/Modified
| 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` | Environment variables |
## Environment Variables
```bash
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```
## Verification
Add test error:
```javascript
throw new Error("My first Sentry error!");
```
Or use a test button:
```javascript
<Button title="Test Sentry" onPress={() => { throw new Error("Test"); }} />
```
## Source Maps
Source maps are automatically uploaded during build when wizard configures:
- Android: Gradle plugin
- iOS: Xcode build phase
## Troubleshooting
| 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)` |
+143
View File
@@ -0,0 +1,143 @@
---
name: sentry-react-wizard
description: Setup Sentry in React apps. Use when asked to add Sentry to React, install @sentry/react, or configure error monitoring for React applications.
---
# Sentry React Setup
Install and configure Sentry in React projects.
## Invoke This Skill When
- User asks to "add Sentry to React" or "install Sentry" in a React app
- User wants error monitoring, logging, or tracing in React
- User mentions "@sentry/react" or React error boundaries
## Install
```bash
npm install @sentry/react --save
```
## Configure
Create `src/instrument.js` (must be imported first in your app):
```javascript
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
sendDefaultPii: true,
// Tracing
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
tracePropagationTargets: [/^\//, /^https:\/\/yourserver\.io\/api/],
// Session Replay
integrations: [Sentry.replayIntegration()],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
// Logs
enableLogs: true,
});
```
### Import First in Entry Point
```javascript
// src/index.js or src/main.jsx
import "./instrument"; // Must be first!
import App from "./App";
import { createRoot } from "react-dom/client";
const root = createRoot(document.getElementById("app"));
root.render(<App />);
```
## Error Handling
### React 19+
Use error hooks with `createRoot`:
```javascript
import { createRoot } from "react-dom/client";
import * as Sentry from "@sentry/react";
const root = createRoot(document.getElementById("app"), {
onUncaughtError: Sentry.reactErrorHandler(),
onCaughtError: Sentry.reactErrorHandler(),
onRecoverableError: Sentry.reactErrorHandler(),
});
```
### React <19
Use ErrorBoundary component:
```javascript
import * as Sentry from "@sentry/react";
<Sentry.ErrorBoundary fallback={<p>An error occurred</p>}>
<MyComponent />
</Sentry.ErrorBoundary>
```
## React Router Integration
| Router Version | Integration |
|---------------|-------------|
| v7 (non-framework) | `Sentry.reactRouterV7BrowserTracingIntegration` |
| v6 | `Sentry.reactRouterV6BrowserTracingIntegration` |
| v4/v5 | `Sentry.reactRouterV5BrowserTracingIntegration` |
## Redux Integration (Optional)
```javascript
import * as Sentry from "@sentry/react";
import { configureStore } from "@reduxjs/toolkit";
const store = configureStore({
reducer,
enhancers: (getDefaultEnhancers) =>
getDefaultEnhancers().concat(Sentry.createReduxEnhancer()),
});
```
## Source Maps
Upload source maps for readable stack traces:
```bash
npx @sentry/wizard@latest -i sourcemaps
```
## Environment Variables
```bash
REACT_APP_SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```
## Verification
Add test button to trigger error:
```javascript
<button onClick={() => { throw new Error("Sentry Test Error"); }}>
Test Sentry
</button>
```
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Errors not captured | Ensure `instrument.js` is imported first |
| Source maps not working | Run sourcemaps wizard, verify auth token |
| React Router spans missing | Add correct router integration for your version |
+134
View File
@@ -0,0 +1,134 @@
---
name: sentry-ruby-wizard
description: Setup Sentry in Ruby apps. Use when asked to add Sentry to Ruby, install sentry-ruby gem, or configure error monitoring for Ruby applications or Rails.
---
# Sentry Ruby Setup
Install and configure Sentry in Ruby projects.
## Invoke This Skill When
- User asks to "add Sentry to Ruby" or "install Sentry" in a Ruby app
- User wants error monitoring, logging, or tracing in Ruby
- User mentions "sentry-ruby" gem or Ruby on Rails
## Requirements
- Ruby 2.4+ or recent JRuby versions
## Install
Add to `Gemfile`:
```ruby
gem "sentry-ruby"
# For profiling, also add:
gem "stackprof"
```
Then run:
```bash
bundle install
```
## Configure
Initialize as early as possible:
```ruby
require "sentry-ruby"
Sentry.init do |config|
config.dsn = "YOUR_SENTRY_DSN"
config.send_default_pii = true
# Breadcrumbs from logs
config.breadcrumbs_logger = [:sentry_logger, :http_logger]
# Tracing
config.traces_sample_rate = 1.0
# Profiling (requires stackprof gem)
config.profiles_sample_rate = 1.0
# Logs
config.enable_logs = true
end
```
## Rails Integration
For Rails, add to `config/initializers/sentry.rb`:
```ruby
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.send_default_pii = true
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
config.traces_sample_rate = 1.0
config.profiles_sample_rate = 1.0
config.enable_logs = true
end
```
### Rails-specific Gems
```ruby
# Gemfile
gem "sentry-ruby"
gem "sentry-rails" # Rails integration
gem "sentry-sidekiq" # If using Sidekiq
gem "sentry-delayed_job" # If using Delayed Job
gem "sentry-resque" # If using Resque
```
## Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `send_default_pii` | Include user data | `false` |
| `traces_sample_rate` | % of transactions traced | `0` |
| `profiles_sample_rate` | % of traces profiled | `0` |
| `enable_logs` | Send logs to Sentry | `false` |
| `environment` | Environment name | Auto-detected |
| `release` | Release version | Auto-detected |
## Breadcrumb Loggers
| Logger | Description |
|--------|-------------|
| `:sentry_logger` | Sentry's own logger |
| `:http_logger` | HTTP request breadcrumbs |
| `:active_support_logger` | Rails ActiveSupport (Rails only) |
## Environment Variables
```bash
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```
## Verification
```ruby
# Capture test message
Sentry.capture_message("Test message from Ruby")
# Or trigger intentional error
1 / 0
```
## Troubleshooting
| Issue | Solution |
|-------|----------|
| Errors not appearing | Ensure `Sentry.init` called early, check DSN |
| No traces | Set `traces_sample_rate` > 0 |
| No profiles | Add `stackprof` gem, set `profiles_sample_rate` |
| Rails errors missing | Use `sentry-rails` gem instead of `sentry-ruby` |