Skip to content
Back to skills

Using Sentry

ASecurity

Capture exceptions, add context, create performance spans, and use structured logging with Sentry.

  • 207 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added February 7, 2026
developmentjavascripttypescriptgojavanextjsapifullstackperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add NeverSight/skills_feed --skill using-sentry --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Using Sentry?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Using Sentry
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/neversight-using-sentry/badge)](https://www.skillsdirectory.com/skills/neversight-using-sentry)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: using-sentry
description: Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
---

# 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-sentry` in Fullstack Recipes
- URL: https://fullstackrecipes.com/recipes/using-sentry

---

### Capturing Exceptions

Manually capture errors that are handled but should be tracked:

```typescript
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:

```typescript
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:

```typescript
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:

```typescript
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:

```typescript
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:

```typescript
import * as Sentry from "@sentry/nextjs";

async function signOut() {
  Sentry.setUser(null);
  await authClient.signOut();
}
```

---

## References

- [Sentry Next.js SDK](https://docs.sentry.io/platforms/javascript/guides/nextjs/)
- [Custom Instrumentation](https://docs.sentry.io/platforms/javascript/guides/nextjs/tracing/instrumentation/custom-instrumentation/)

Files in this skill

  • SKILL.md2.9 KB
  • description_cn.txt102 B
  • description_de.txt142 B
  • description_en.txt99 B
  • description_es.txt116 B
  • description_fr.txt140 B
  • description_ja.txt156 B
  • description_ko.txt148 B
  • description_tw.txt102 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.