Communitygithub.com

錯誤追蹤整合工具

整合 Sentry、Rollbar 等錯誤追蹤服務至應用程式中,包含錯誤邊界、上下文與麵包屑功能,利於生產環境除錯與監控。

錯誤追蹤整合工具 是什麼?

此技能提供一個全面性的錯誤追蹤整合方案,能快速將 Sentry、Rollbar、Bugsnag 等服務導入前端(React、Vue、Angular)與後端(Node.js、Python、Ruby)框架。除了基礎的安裝配置與錯誤邊界設置,更涵蓋上下文標記、用戶行為麵包屑、敏感資料過濾、生產環境 Source Map 上傳以及警報規則設定等進階功能。支援多種平台與語言,並附有現成的整合範本,開發者無需從零撰寫繁瑣的錯誤處理程式碼,即可擁有專業級的生產環境錯誤監控與效能分析能力。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/error-tracking-integrator

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

錯誤追蹤整合工具 是做什麼的?

將錯誤追蹤服務整合至應用程式中,以提升生產環境的除錯與監控能力。

使用時機

  • 使用者要求錯誤監控或追蹤
  • 設定生產環境的錯誤日誌
  • 使用者提及「Sentry」、「錯誤追蹤」、「崩潰回報」或「生產環境除錯」

使用說明

1. 偵測框架

辨識應用程式框架:

  • React、Vue、Angular(前端)
  • Express、Fastify(Node.js 後端)
  • Django、Flask(Python)
  • Rails(Ruby)

2. 選擇錯誤追蹤服務

熱門服務:

  • Sentry:最受歡迎,功能完整
  • Rollbar:適合後端
  • Bugsnag:跨平台
  • Airbrake:以 Ruby 為焦點
  • LogRocket:階段回放 + 錯誤

3. 安裝與配置

Sentry(React 範例):

npm install @sentry/react
import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: process.env.REACT_APP_SENTRY_DSN,
  environment: process.env.NODE_ENV,
  tracesSampleRate: 1.0,
  integrations: [
    new Sentry.BrowserTracing(),
    new Sentry.Replay()
  ],
});

Sentry(Node.js/Express):

const Sentry = require("@sentry/node");

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.NODE_ENV,
  tracesSampleRate: 1.0,
});

// 請求處理器(第一個中介軟體)
app.use(Sentry.Handlers.requestHandler());

// 錯誤處理器(在所有路由之後,錯誤中介軟體之前)
app.use(Sentry.Handlers.errorHandler());

4. 加入錯誤邊界(React)

import { ErrorBoundary } from '@sentry/react';

function App() {
  return (
    <ErrorBoundary fallback={<ErrorFallback />}>
      <YourApp />
    </ErrorBoundary>
  );
}

5. 加入上下文

使用者上下文:

Sentry.setUser({
  id: user.id,
  email: user.email,
  username: user.username
});

標籤:

Sentry.setTag("page_locale", "en-US");
Sentry.setTag("feature_flag", "new_ui");

上下文:

Sentry.setContext("order", {
  id: order.id,
  total: order.total,
  items: order.items.length
});

6. 麵包屑

追蹤導致錯誤的使用者操作:

Sentry.addBreadcrumb({
  category: "auth",
  message: "User logged in",
  level: "info"
});

Sentry.addBreadcrumb({
  category: "ui",
  message: "Button clicked",
  data: { buttonId: "submit-form" }
});

7. 手動錯誤捕捉

try {
  riskyOperation();
} catch (error) {
  Sentry.captureException(error, {
    tags: { section: "payment" },
    level: "error",
    extra: { orderId: order.id }
  });
}

8. 過濾敏感資料

清除個人識別資訊(PII):

Sentry.init({
  beforeSend(event, hint) {
    // 若包含敏感資料則不發送
    if (event.request?.data?.password) {
      delete event.request.data.password;
    }
    return event;
  },
  ignoreErrors: [
    // 忽略瀏覽器擴充功能錯誤
    /extensions\//i,
    /^Non-Error promise rejection/,
  ]
});

9. Source Maps(生產環境)

啟用 Source Map 以獲得可讀的堆疊追蹤:

Webpack:

// webpack.config.js
module.exports = {
  devtool: 'source-map',
  plugins: [
    new SentryWebpackPlugin({
      org: "your-org",
      project: "your-project",
      authToken: process.env.SENTRY_AUTH_TOKEN,
      include: "./dist",
    }),
  ],
};

10. 警報設定

設定下列項目的警報:

  • 新問題
  • 迴歸(已解決的問題再次發生)
  • 錯誤率飆升
  • 重大錯誤(支付、驗證失敗)

11. 效能監控

加入交易追蹤:

const transaction = Sentry.startTransaction({
  name: "processOrder",
  op: "task"
});

try {
  await processOrder();
} finally {
  transaction.finish();
}

12. 最佳實踐

  • 環境區隔:開發/暫存/生產使用不同的專案
  • 版本追蹤:用發行版本標記錯誤
  • 取樣率:錯誤 100%,效能降低取樣率
  • 團隊通知:Slack/電子郵件整合
  • 問題指派:自動指派給程式碼負責人
  • 錯誤分組:自訂指紋辨識以獲得更好的分組
  • 不記錄敏感資料:個人識別資訊、密碼、令牌

支援檔案

  • templates/sentry-react.js:React 整合範本
  • templates/sentry-node.js:Node.js 整合範本
  • templates/sentry-python.py:Python 整合範本

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相關技能