sentry-errors
Sentry error tracking + performance monitoring for Next.js App Router. Detection-first: adapts if already installed; otherwise installs fresh. Covers client +…
от nghiahsgs★ 31 звезда на GitHub
Установить sentry-errors в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
sentry-errors — Error Tracking
Step 0 — Detect existing setup
# installed?
grep -l '@sentry/nextjs' package.json 2>/dev/null
# env keys?
grep -E 'SENTRY_DSN|NEXT_PUBLIC_SENTRY_DSN|SENTRY_AUTH_TOKEN' .env.local .env.example 2>/dev/null
# config files?
ls sentry.client.config.* sentry.server.config.* sentry.edge.config.* 2>/dev/null
If installed + configured → read existing, skip install. Apply additional patterns only. If installed but misconfigured → fix the gap (often: source map upload missing in CI). If nothing → new setup, Step 1.
Step 1 — Install + wizard (new)
npx @sentry/wizard@latest -i nextjs
The wizard:
- Creates
sentry.{client,server,edge}.config.ts - Patches
next.config.mjsto wrap withwithSentryConfig - Prompts for DSN + optional auth token
- Adds
.sentryclirc(gitignore this)
If user declines to run wizard (wants manual): continue to Step 2.
Step 2 — Manual install
npm install @sentry/nextjs
sentry.client.config.ts:
import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.0,
replaysOnErrorSampleRate: 1.0,
integrations: [Sentry.replayIntegration()],
beforeSend(event, hint) {
// scrub PII from client-side events
if (event.request?.cookies) delete event.request.cookies
return event
},
})
sentry.server.config.ts:
import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 0.1,
})
sentry.edge.config.ts:
import * as Sentry from '@sentry/nextjs'
Sentry.init({ dsn: process.env.SENTRY_DSN, tracesSampleRate: 0.1 })
Patch next.config.mjs:
import { withSentryConfig } from '@sentry/nextjs'
const nextConfig = { /* ... */ }
export default withSentryConfig(nextConfig, {
org: 'your-org',
project: 'your-project',
silent: !process.env.CI, // silent in dev
widenClientFileUpload: true,
hideSourceMaps: true,
disableLogger: true,
})
Step 3 — Env vars
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/xxx # public — safe to ship
SENTRY_DSN=https://[email protected]/xxx # server — usually same as public, but keep as server var
SENTRY_AUTH_TOKEN=sntrys_... # CI only, for source map upload
SENTRY_ORG=your-org
SENTRY_PROJECT=your-project
Get DSN: Sentry dashboard → Settings → Projects → (your project) → Client Keys.
Get auth token: User Settings → Auth Tokens → Create with project:write scope.
Step 4 — Manual capture patterns
Log an error with context
import * as Sentry from '@sentry/nextjs'
try {
await riskyThing()
} catch (err) {
Sentry.captureException(err, {
tags: { section: 'checkout' },
extra: { orderId: order.id, user: user.id },
})
throw err // re-throw if caller needs to know
}
Set user context (after login)
Sentry.setUser({ id: user.id, email: user.email })
// clear on logout:
Sentry.setUser(null)
Breadcrumbs
Sentry.addBreadcrumb({ category: 'cart', message: 'item added', level: 'info' })
Sentry-wrapped Route Handler
import * as Sentry from '@sentry/nextjs'
export const POST = Sentry.wrapApiHandlerWithSentry(async (req) => {
// ... your handler
return Response.json({ ok: true })
}, '/api/your-route')
(Note: for App Router route handlers, use wrapRouteHandlerWithSentry.)
Step 5 — Source map upload in CI
For readable stack traces in production, upload source maps during build. The wizard adds this to next.config.mjs automatically via withSentryConfig.
In CI (GitHub Actions), ensure SENTRY_AUTH_TOKEN is in secrets. Build step:
- name: Build
run: npm run build
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: your-org
SENTRY_PROJECT: your-project
Verify upload: in Sentry dashboard, recent deploys should show "source maps uploaded".
Step 6 — PII scrubbing (important for VN compliance)
Default Sentry Data Scrubber catches passwords, tokens, CC numbers. Add project-specific rules:
Dashboard → Settings → Security & Privacy → Data Scrubbing → add fields:
email,phone,address,cccd,cmnd(VN ID numbers)
Or in code via beforeSend:
beforeSend(event) {
if (event.user?.email) event.user.email = event.user.email.replace(/(.).*@/, '$1***@')
return event
}
Step 7 — Alert rules
Dashboard → Alerts → Create Alert. Recommended:
- Error spike:
>20 events in 1 min→ Slack/email immediately - Regression:
Issue seen before in prod resolved, now unresolved→ email - Crash free users < 99% (mobile projects)
Step 8 — Test the integration
// app/test-sentry/route.ts (delete after testing)
export function GET() {
throw new Error('Sentry smoke test — ignore')
}
Hit /test-sentry, then check Sentry dashboard — issue should appear within 30s.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Read - 02
Write - 03
Edit - 04
Bash - 05
Grep
FAQ
Что делает скилл sentry-errors?
Sentry error tracking + performance monitoring for Next.js App Router. Detection-first: adapts if already installed; otherwise installs fresh. Covers client + server + edge runtime, source map upload, and PII scrubbing. Trigger phrases (EN + VN): "sentry", "error tracking", "monitor loi", "theo doi loi", "crash reporting", "cai sentry", "app loi khong biet".
Как установить скилл sentry-errors?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sentry-errors запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…