PluginBench
Skill
Pass
Audit score 90

sentry

brianlovin/agent-config

Sentry error monitoring and performance tracing for Next.js applications.

What is sentry?

Integrates Sentry into Next.js apps to capture exceptions, trace performance, and log structured events. Use this when you need production error tracking, performance insights, and centralized logging across client, server, and edge runtimes.

  • Capture and report exceptions with Sentry.captureException() in try/catch blocks
  • Create performance spans for UI actions, API calls, and function execution
  • Configure Sentry for client-side, server-side, and edge runtime environments
  • Log structured events with multiple severity levels (trace, debug, info, warn, error, fatal)
  • Track form submissions, button clicks, and API requests with custom attributes

How to install sentry

npx skills add https://github.com/brianlovin/agent-config --skill sentry
Prerequisites
  • Sentry account and project DSN
  • Next.js application with @sentry/nextjs package installed
  • Environment variable NEXT_PUBLIC_SENTRY_DSN configured
Claude Code
Cursor
Windsurf
Cline

How to use sentry

  1. 1.Create sentry.client.config.ts, sentry.server.config.ts, and sentry.edge.config.ts files in your project root
  2. 2.Initialize Sentry in each config file with your DSN and desired integrations
  3. 3.Wrap risky operations in try/catch blocks and call Sentry.captureException(error)
  4. 4.Use Sentry.startSpan() to create performance spans around UI actions and API calls
  5. 5.Use Sentry.logger methods to emit structured logs at appropriate severity levels

Use cases

Good for
  • Monitor production errors and stack traces in a Next.js application
  • Measure performance of critical user interactions like form submissions
  • Track API call latency and failures across client and server
  • Aggregate structured logs from different runtime environments for debugging
  • Identify performance bottlenecks in UI actions and data fetching
Who it's for
  • Next.js developers building production applications
  • Teams needing centralized error monitoring and alerting
  • Performance-conscious developers tracking user-facing latency
  • Full-stack engineers managing both client and server-side observability

sentry FAQ

Do I need to initialize Sentry in every file?

No. Import Sentry in other files with `import * as Sentry from "@sentry/nextjs"` after initializing in the config files.

How do I track API call performance?

Wrap your fetch call in Sentry.startSpan() with op: "http.client" and include the endpoint name.

What's the difference between the three config files?

sentry.client.config.ts handles browser-side errors, sentry.server.config.ts handles Node.js backend, and sentry.edge.config.ts handles Vercel Edge Runtime.

Can I log without throwing an error?

Yes, use Sentry.logger methods (trace, debug, info, warn, error, fatal) for structured logging without exceptions.

How do I add custom context to errors?

Use span.setAttribute() when creating spans, or pass an object with context data to logger methods.

Full instructions (SKILL.md)

Source of truth, from brianlovin/agent-config.


name: sentry description: Sentry error monitoring and performance tracing patterns for Next.js applications.

Sentry Integration

Guidelines for using Sentry for error monitoring and performance tracing.

Exception Catching

Use Sentry.captureException(error) in try/catch blocks:

try {
  await riskyOperation();
} catch (error) {
  Sentry.captureException(error);
  throw error;
}

Performance Tracing

Create spans for meaningful actions like button clicks, API calls, and function calls.

UI Actions

function handleClick() {
  Sentry.startSpan(
    { op: "ui.click", name: "Submit Form" },
    (span) => {
      span.setAttribute("formId", formId);
      submitForm();
    }
  );
}

API Calls

async function fetchData(id) {
  return Sentry.startSpan(
    { op: "http.client", name: `GET /api/items/${id}` },
    async () => {
      const response = await fetch(`/api/items/${id}`);
      return response.json();
    }
  );
}

Configuration (Next.js)

Sentry initialization files:

  • sentry.client.config.ts - Client-side
  • sentry.server.config.ts - Server-side
  • sentry.edge.config.ts - Edge runtime

Import with import * as Sentry from "@sentry/nextjs" - no need to initialize in other files.

Basic Setup

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

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  enableLogs: true,
});

With Console Logging

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  integrations: [
    Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
  ],
});

Structured Logging

Use logger.fmt for template literals with variables:

const { logger } = Sentry;

logger.trace("Starting connection", { database: "users" });
logger.debug(logger.fmt`Cache miss for: ${userId}`);
logger.info("Updated profile", { profileId: 345 });
logger.warn("Rate limit reached", { endpoint: "/api/data" });
logger.error("Payment failed", { orderId: "order_123" });
logger.fatal("Connection pool exhausted", { activeConnections: 100 });