TypeScript Sentry
When to Use This Skill
| Use this skill when... |
Use another approach when... |
| Adding error monitoring to a project |
Setting up logging (use a logger library) |
| Instrumenting performance spans |
Monitoring infrastructure metrics (use Prometheus/Grafana) |
| Setting up cron job monitoring |
Setting up uptime monitoring (use Pingdom/UptimeRobot) |
| Configuring source maps for Sentry |
Debugging errors locally (use debugger) |
| Adding structured logging to Sentry |
Configuring project-level Sentry compliance (use /configure:sentry) |
| Setting up profiling, replay, or enrichment helpers |
Managing Sentry project settings in the dashboard |
| Implementing error/transaction filtering |
Creating Sentry alerting rules |
Core Expertise
Sentry provides error monitoring and performance tracking:
- Automatic error capture with stack traces
- Performance monitoring with distributed tracing
- Cron job monitoring for scheduled tasks
- Source map integration for readable TypeScript traces
- Rich context with tags, breadcrumbs, and user data
- Structured logging forwarded to Sentry (
enableLogs)
- CPU/JS profiling (Node.js + browser)
- Session replay with privacy controls
- User feedback widget
- Enrichment helpers (custom contexts, breadcrumb categories, fingerprinting)
Installation
Bun
bun add @sentry/bun
Node.js
bun add @sentry/node
Next.js
bun add @sentry/nextjs @sentry/profiling-node
React/Browser
bun add @sentry/react
# or
bun add @sentry/browser
Error Capturing
captureException
try {
await riskyOperation();
} catch (error) {
Sentry.captureException(error);
throw error; // Re-throw if needed
}
With Context
Sentry.captureException(error, {
tags: {
feature: "checkout",
paymentProvider: "stripe",
},
extra: {
orderId: order.id,
userId: user.id,
cartItems: cart.items.length,
},
level: "error", // fatal, error, warning, info, debug
});
captureMessage
// Simple message
Sentry.captureMessage("User completed onboarding");
// With level
Sentry.captureMessage("Rate limit approaching", "warning");
// With context
Sentry.captureMessage("Payment failed", {
level: "error",
tags: { gateway: "stripe" },
extra: { errorCode: "card_declined" },
});
Agentic Optimizations
| Context |
Command |
| Install Bun |
bun add @sentry/bun |
| Install Node |
bun add @sentry/node |
| Install Next.js |
bun add @sentry/nextjs @sentry/profiling-node |
| Install React |
bun add @sentry/react |
| Install CLI |
bun add -D @sentry/cli |
| Upload maps |
npx sentry-cli sourcemaps inject ./dist && npx sentry-cli sourcemaps upload ./dist |
| Setup wizard |
npx @sentry/wizard@latest -i sourcemaps |
| Test capture |
Sentry.captureMessage("Test from dev") |
Quick Reference
Capture Methods
| Method |
Purpose |
captureException(error) |
Capture error with stack trace |
captureMessage(msg) |
Capture text message |
captureCheckIn(opts) |
Cron job check-in |
addBreadcrumb(crumb) |
Add navigation/action trail |
Context Methods
| Method |
Purpose |
setTag(key, value) |
Add filterable tag |
setExtra(key, value) |
Add debug data |
setUser(user) |
Set user context |
withScope(callback) |
Scoped context |
Performance Methods
| Method |
Purpose |
startSpan(opts, callback) |
Create performance span |
withMonitor(slug, callback) |
Monitor cron job |
Severity Levels
| Level |
Use Case |
fatal |
App crash, unrecoverable |
error |
Error requiring attention |
warning |
Potential issue |
info |
Informational |
debug |
Debugging only |
Configuration Options
| Option |
Description |
dsn |
Project data source name |
environment |
Environment name (production, staging) |
release |
Application version |
tracesSampleRate |
Transaction sample rate (0.0-1.0) |
tracesSampler |
Dynamic sampling function |
sendDefaultPii |
Capture IP/headers |
integrations |
SDK integrations array |
enableLogs |
Forward structured logs to Sentry |
profileSessionSampleRate |
Profiling sample rate (0.0-1.0) |
profileLifecycle |
"trace" profiles every traced request |
replaysSessionSampleRate |
Session replay sample rate |
replaysOnErrorSampleRate |
Replay capture rate on errors |
ignoreErrors |
Array of error patterns to suppress |
beforeSend |
Filter/modify events before sending |
beforeSendTransaction |
Filter transactions before sending |
beforeSendLog |
Filter structured logs before sending |
For detailed examples, advanced patterns, and best practices, see REFERENCE.md.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: typescript-sentry3description: Error monitoring and performance tracking with Sentry SDK - error capture, breadcrumbs, performance spans, cron monitoring, source maps, structured logging, profiling, and enrichment helpers for Bun/Node.js/Next.js. Use when this capability is needed.4---56# TypeScript Sentry78## When to Use This Skill910| Use this skill when... | Use another approach when... |11|------------------------|------------------------------|12| Adding error monitoring to a project | Setting up logging (use a logger library) |13| Instrumenting performance spans | Monitoring infrastructure metrics (use Prometheus/Grafana) |14| Setting up cron job monitoring | Setting up uptime monitoring (use Pingdom/UptimeRobot) |15| Configuring source maps for Sentry | Debugging errors locally (use debugger) |16| Adding structured logging to Sentry | Configuring project-level Sentry compliance (use `/configure:sentry`) |17| Setting up profiling, replay, or enrichment helpers | Managing Sentry project settings in the dashboard |18| Implementing error/transaction filtering | Creating Sentry alerting rules |1920## Core Expertise2122Sentry provides error monitoring and performance tracking:23- Automatic error capture with stack traces24- Performance monitoring with distributed tracing25- Cron job monitoring for scheduled tasks26- Source map integration for readable TypeScript traces27- Rich context with tags, breadcrumbs, and user data28- Structured logging forwarded to Sentry (`enableLogs`)29- CPU/JS profiling (Node.js + browser)30- Session replay with privacy controls31- User feedback widget32- Enrichment helpers (custom contexts, breadcrumb categories, fingerprinting)3334## Installation3536### Bun3738```bash39bun add @sentry/bun40```4142### Node.js4344```bash45bun add @sentry/node46```4748### Next.js4950```bash51bun add @sentry/nextjs @sentry/profiling-node52```5354### React/Browser5556```bash57bun add @sentry/react58# or59bun add @sentry/browser60```6162## Error Capturing6364### captureException6566```typescript67try {68 await riskyOperation();69} catch (error) {70 Sentry.captureException(error);71 throw error; // Re-throw if needed72}73```7475### With Context7677```typescript78Sentry.captureException(error, {79 tags: {80 feature: "checkout",81 paymentProvider: "stripe",82 },83 extra: {84 orderId: order.id,85 userId: user.id,86 cartItems: cart.items.length,87 },88 level: "error", // fatal, error, warning, info, debug89});90```9192### captureMessage9394```typescript95// Simple message96Sentry.captureMessage("User completed onboarding");9798// With level99Sentry.captureMessage("Rate limit approaching", "warning");100101// With context102Sentry.captureMessage("Payment failed", {103 level: "error",104 tags: { gateway: "stripe" },105 extra: { errorCode: "card_declined" },106});107```108109## Agentic Optimizations110111| Context | Command |112|---------|---------|113| Install Bun | `bun add @sentry/bun` |114| Install Node | `bun add @sentry/node` |115| Install Next.js | `bun add @sentry/nextjs @sentry/profiling-node` |116| Install React | `bun add @sentry/react` |117| Install CLI | `bun add -D @sentry/cli` |118| Upload maps | `npx sentry-cli sourcemaps inject ./dist && npx sentry-cli sourcemaps upload ./dist` |119| Setup wizard | `npx @sentry/wizard@latest -i sourcemaps` |120| Test capture | `Sentry.captureMessage("Test from dev")` |121122## Quick Reference123124### Capture Methods125126| Method | Purpose |127|--------|---------|128| `captureException(error)` | Capture error with stack trace |129| `captureMessage(msg)` | Capture text message |130| `captureCheckIn(opts)` | Cron job check-in |131| `addBreadcrumb(crumb)` | Add navigation/action trail |132133### Context Methods134135| Method | Purpose |136|--------|---------|137| `setTag(key, value)` | Add filterable tag |138| `setExtra(key, value)` | Add debug data |139| `setUser(user)` | Set user context |140| `withScope(callback)` | Scoped context |141142### Performance Methods143144| Method | Purpose |145|--------|---------|146| `startSpan(opts, callback)` | Create performance span |147| `withMonitor(slug, callback)` | Monitor cron job |148149### Severity Levels150151| Level | Use Case |152|-------|----------|153| `fatal` | App crash, unrecoverable |154| `error` | Error requiring attention |155| `warning` | Potential issue |156| `info` | Informational |157| `debug` | Debugging only |158159### Configuration Options160161| Option | Description |162|--------|-------------|163| `dsn` | Project data source name |164| `environment` | Environment name (production, staging) |165| `release` | Application version |166| `tracesSampleRate` | Transaction sample rate (0.0-1.0) |167| `tracesSampler` | Dynamic sampling function |168| `sendDefaultPii` | Capture IP/headers |169| `integrations` | SDK integrations array |170| `enableLogs` | Forward structured logs to Sentry |171| `profileSessionSampleRate` | Profiling sample rate (0.0-1.0) |172| `profileLifecycle` | `"trace"` profiles every traced request |173| `replaysSessionSampleRate` | Session replay sample rate |174| `replaysOnErrorSampleRate` | Replay capture rate on errors |175| `ignoreErrors` | Array of error patterns to suppress |176| `beforeSend` | Filter/modify events before sending |177| `beforeSendTransaction` | Filter transactions before sending |178| `beforeSendLog` | Filter structured logs before sending |179180For detailed examples, advanced patterns, and best practices, see [REFERENCE.md](REFERENCE.md).181182---183> Converted and distributed by [TomeVault](https://tomevault.io/claim/laurigates) — claim your Tome and manage your conversions.184<!-- tomevault:4.0:skill_md:2026-04-11 -->