monitoring-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Monitoring Setup Expert

监控搭建专家

Overview

概述

This skill enables AI assistants to set up comprehensive monitoring for NestJS and Next.js applications, including Sentry for error tracking and Google Analytics for user analytics.
此技能可让AI助手为NestJS和Next.js应用搭建全面的监控体系,包括用于错误追踪的Sentry和用于用户分析的Google Analytics。

When to Use This Skill

何时使用此技能

This skill activates when users:
  • Need to set up error tracking (Sentry)
  • Want to configure Google Analytics
  • Need monitoring for production applications
  • Want to track application errors and user behavior
当用户有以下需求时,将激活此技能:
  • 需要搭建错误追踪系统(Sentry)
  • 想要配置Google Analytics
  • 需要为生产环境应用设置监控
  • 想要追踪应用错误与用户行为

Sentry Setup

Sentry 搭建步骤

NestJS Backend

NestJS 后端

  1. Install:
    npm install @sentry/node @sentry/profiling-node
  2. Initialize in
    main.ts
    before app creation
  3. Configure DSN via
    SENTRY_DSN
    environment variable
  4. Set appropriate sample rates for production
  1. 安装:
    npm install @sentry/node @sentry/profiling-node
  2. 在创建应用前,在
    main.ts
    中初始化
  3. 通过
    SENTRY_DSN
    环境变量配置DSN
  4. 为生产环境设置合适的采样率

Next.js Frontend

Next.js 前端

  1. Install:
    npm install @sentry/nextjs
  2. Run:
    npx @sentry/wizard@latest -i nextjs
  3. Configure client/server/edge configs
  4. Set
    NEXT_PUBLIC_SENTRY_DSN
    for client-side
  1. 安装:
    npm install @sentry/nextjs
  2. 运行:
    npx @sentry/wizard@latest -i nextjs
  3. 配置客户端/服务端/边缘环境的相关设置
  4. 为客户端设置
    NEXT_PUBLIC_SENTRY_DSN

Google Analytics Setup

Google Analytics 搭建步骤

Next.js Setup

Next.js 配置

  1. Add Google Analytics script to root layout
  2. Use
    NEXT_PUBLIC_GA_MEASUREMENT_ID
    (format: G-XXXXXXXXXX)
  3. Create analytics utility functions for event tracking
  4. Set up page view tracking
  1. 将Google Analytics脚本添加到根布局中
  2. 使用
    NEXT_PUBLIC_GA_MEASUREMENT_ID
    (格式:G-XXXXXXXXXX)
  3. 创建用于事件追踪的分析工具函数
  4. 配置页面浏览追踪

Common Events

常见追踪事件

  • User signup/login
  • Purchases/conversions
  • Feature usage
  • Custom business events
  • 用户注册/登录
  • 购买/转化
  • 功能使用情况
  • 自定义业务事件

Best Practices

最佳实践

  • Use different DSNs for dev/prod
  • Set appropriate sample rates
  • Respect user privacy (GDPR/CCPA)
  • Don't track sensitive data
  • Set up alerts for critical errors
  • 为开发/生产环境使用不同的DSN
  • 设置合适的采样率
  • 尊重用户隐私(GDPR/CCPA合规)
  • 不要追踪敏感数据
  • 为严重错误设置告警

Integration

集成

This skill integrates with
/monitoring-setup
command for automated setup workflows.
此技能可与
/monitoring-setup
命令集成,实现自动化搭建流程。