Agent skill
using-sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
Install this agent skill to your Project
npx add-skill https://github.com/andrelandgraf/fullstackrecipes/tree/main/.agents/skills/using-sentry
SKILL.md
Working with Sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
Implement Working with Sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
See:
- Resource:
using-sentryin Fullstack Recipes - URL: https://fullstackrecipes.com/recipes/using-sentry
Capturing Exceptions
Manually capture errors that are handled but should be tracked:
import * as Sentry from "@sentry/nextjs";
try {
await riskyOperation();
} catch (err) {
Sentry.captureException(err);
// Handle the error gracefully...
}
Adding Context
Attach user and custom context to errors:
import * as Sentry from "@sentry/nextjs";
// Set user context (persists for session)
Sentry.setUser({
id: session.user.id,
email: session.user.email,
});
// Add custom context to exceptions
Sentry.captureException(err, {
tags: {
feature: "checkout",
plan: "pro",
},
extra: {
orderId: "order_123",
items: cart.items,
},
});
Performance Tracing
Create spans for meaningful operations:
import * as Sentry from "@sentry/nextjs";
// Wrap async operations
const result = await Sentry.startSpan(
{
op: "http.client",
name: "GET /api/users",
},
async () => {
const response = await fetch("/api/users");
return response.json();
},
);
// Wrap sync operations
Sentry.startSpan(
{
op: "ui.click",
name: "Submit Button Click",
},
(span) => {
span.setAttribute("form", "checkout");
processSubmit();
},
);
Using the Sentry Logger
Sentry provides structured logging that appears in the Logs tab:
import * as Sentry from "@sentry/nextjs";
const { logger } = Sentry;
logger.info("Payment processed", { orderId: "123", amount: 99.99 });
logger.warn("Rate limit approaching", { current: 90, max: 100 });
logger.error("Payment failed", { orderId: "123", reason: "declined" });
Breadcrumbs
Add breadcrumbs to provide context for errors:
import * as Sentry from "@sentry/nextjs";
// Automatically captured: console logs, fetch requests, UI clicks
// Manual breadcrumbs for custom events:
Sentry.addBreadcrumb({
category: "auth",
message: "User signed in",
level: "info",
});
Clearing User Context
Clear user data on sign out:
import * as Sentry from "@sentry/nextjs";
async function signOut() {
Sentry.setUser(null);
await authClient.signOut();
}
References
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
shiki-code-blocks
Syntax highlight code blocks with Shiki. Supports server-side rendering in RSC and automatic light/dark theme switching.
better-auth-emails
Add email verification, password reset, and account management emails to Better Auth using Resend.
ai-sdk-setup
Install the Vercel AI SDK with AI Elements components. Build a streaming chat interface with the useChat hook.
code-style-setup
Configure Prettier for code formatting and TypeScript for typechecking. Includes VSCode settings and EditorConfig for consistent code style. Skips ESLint/Biome to avoid config complexity.
using-nuqs
Manage React state in URL query parameters with nuqs. Covers Suspense boundaries, parsers, clearing state, and deep-linkable dialogs.
chat-naming
Generate descriptive chat titles from the first message using a fast LLM. Runs as a background workflow step after the main response to avoid delaying the experience.
Didn't find tool you were looking for?