sentry by brianlovin/claude-config
npx skills add https://github.com/brianlovin/claude-config --skill sentry使用 Sentry 进行错误监控和性能追踪的指南。
在 try/catch 代码块中使用 Sentry.captureException(error):
try {
await riskyOperation();
} catch (error) {
Sentry.captureException(error);
throw error;
}
为有意义的操作创建跨度,例如按钮点击、API 调用和函数调用。
function handleClick() {
Sentry.startSpan(
{ op: "ui.click", name: "提交表单" },
(span) => {
span.setAttribute("formId", formId);
submitForm();
}
);
}
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();
}
);
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Sentry 初始化文件:
sentry.client.config.ts - 客户端sentry.server.config.ts - 服务端sentry.edge.config.ts - 边缘运行时使用 import * as Sentry from "@sentry/nextjs" 导入 - 无需在其他文件中初始化。
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
enableLogs: true,
});
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
integrations: [
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
],
});
使用 logger.fmt 处理包含变量的模板字面量:
const { logger } = Sentry;
logger.trace("开始连接", { database: "users" });
logger.debug(logger.fmt`缓存未命中:${userId}`);
logger.info("已更新个人资料", { profileId: 345 });
logger.warn("达到速率限制", { endpoint: "/api/data" });
logger.error("支付失败", { orderId: "order_123" });
logger.fatal("连接池耗尽", { activeConnections: 100 });
每周安装量
78
代码仓库
GitHub 星标数
304
首次出现
2026年1月29日
安全审计
安装于
claude-code65
opencode56
gemini-cli53
cursor53
codex53
github-copilot52
Guidelines for using Sentry for error monitoring and performance tracing.
Use Sentry.captureException(error) in try/catch blocks:
try {
await riskyOperation();
} catch (error) {
Sentry.captureException(error);
throw error;
}
Create spans for meaningful actions like button clicks, API calls, and function calls.
function handleClick() {
Sentry.startSpan(
{ op: "ui.click", name: "Submit Form" },
(span) => {
span.setAttribute("formId", formId);
submitForm();
}
);
}
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();
}
);
}
Sentry initialization files:
sentry.client.config.ts - Client-sidesentry.server.config.ts - Server-sidesentry.edge.config.ts - Edge runtimeImport with import * as Sentry from "@sentry/nextjs" - no need to initialize in other files.
import * as Sentry from "@sentry/nextjs";
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
enableLogs: true,
});
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
integrations: [
Sentry.consoleLoggingIntegration({ levels: ["log", "warn", "error"] }),
],
});
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 });
Weekly Installs
78
Repository
GitHub Stars
304
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
claude-code65
opencode56
gemini-cli53
cursor53
codex53
github-copilot52
Dogfood - Vercel Labs 自动化 Web 应用探索与问题报告工具
18,700 周安装