From andrelandgraf-fullstackrecipes
Capture exceptions, attach user/context, add spans and breadcrumbs, and log via the Sentry SDK. Use when instrumenting errors, performance, or context in app code.
How this skill is triggered — by the user, by Claude, or both
Slash command
/andrelandgraf-fullstackrecipes:sentry-best-practicesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Capture exceptions, add context, trace performance, and log with Sentry.
Capture exceptions, add context, trace performance, and log with Sentry.
Complete these setup recipes first:
Capture errors that are handled but still worth tracking.
import * as Sentry from "@sentry/nextjs";
try {
await riskyOperation();
} catch (err) {
Sentry.captureException(err);
}
setUser persists for the session. Attach tags (indexed, filterable) and extra (arbitrary detail) per exception.
import * as Sentry from "@sentry/nextjs";
Sentry.setUser({ id: session.user.id, email: session.user.email });
Sentry.captureException(err, {
tags: { feature: "checkout", plan: "pro" },
extra: { orderId: "order_123", items: cart.items },
});
Clear the user on sign out.
Sentry.setUser(null);
Wrap meaningful operations in startSpan. The sync form receives the span for attributes.
import * as Sentry from "@sentry/nextjs";
const users = await Sentry.startSpan(
{ op: "http.client", name: "GET /api/users" },
async () => (await fetch("/api/users")).json(),
);
Sentry.startSpan({ op: "ui.click", name: "Submit Button Click" }, (span) => {
span.setAttribute("form", "checkout");
processSubmit();
});
Console logs, fetches, and UI clicks are captured automatically. Add manual breadcrumbs for custom events.
import * as Sentry from "@sentry/nextjs";
Sentry.addBreadcrumb({
category: "auth",
message: "User signed in",
level: "info",
});
Structured logs surface 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" });
npx claudepluginhub joshuarweaver/cascade-code-general-misc-3 --plugin andrelandgraf-fullstackrecipesProvides Sentry SDK patterns for TypeScript/Node and Python: scoped error context, breadcrumbs, beforeSend filtering, custom fingerprinting, user context, and performance spans.
Implements Sentry SDK for error capture, breadcrumbs, performance spans, cron monitoring, source maps, structured logging, profiling, and enrichment in Bun/Node.js/Next.js apps.
Captures Sentry errors with context (user/tags/extra/breadcrumbs), manual exceptions, messages, and React error boundaries for improved debugging.