home / skills / shipshitdev / library / monitoring-setup

This skill helps you configure end-to-end monitoring with Sentry and Google Analytics for NestJS and Next.js apps, enabling error tracking and analytics

npx playbooks add skill shipshitdev/library --skill monitoring-setup

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.7 KB
---
name: monitoring-setup
description: Expert in setting up Sentry error tracking and Google Analytics for NestJS and Next.js applications. Use this skill when users need monitoring, error tracking, or analytics configuration.
---

# 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.

## 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 Setup

### NestJS Backend

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

### Next.js Frontend

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

## Google Analytics Setup

### Next.js Setup

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

### 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

## Integration

This skill integrates with `/monitoring-setup` command for automated setup workflows.

Overview

This skill helps set up Sentry error tracking and Google Analytics for NestJS (backend) and Next.js (frontend) applications. It provides step-by-step configuration, environment variable guidance, and recommended production settings so monitoring can be reliable and privacy-compliant. Use it to get error alerts, performance signals, and user analytics running quickly.

How this skill works

The skill inspects project type and suggests the correct packages and initialization points: Sentry for NestJS in main bootstrap code and Sentry for Next.js with client/server configs. For analytics it injects the Google Analytics snippet or utilities, wires NEXT_PUBLIC_GA_MEASUREMENT_ID, and recommends pageview/event tracking patterns. It also proposes environment separation, sampling rates, and alert rules.

When to use it

  • Setting up error tracking for a NestJS backend
  • Configuring Sentry in a Next.js frontend (client/server/edge)
  • Adding Google Analytics to a Next.js app for pageview and event tracking
  • Preparing production monitoring and alerts before launch
  • Ensuring privacy-compliant data collection and sampling

Best practices

  • Use separate Sentry DSNs for development and production environments
  • Set conservative sample rates in production and raise for diagnostics when needed
  • Expose only client-safe variables (NEXT_PUBLIC_*) and never send sensitive data
  • Implement server-side and client-side error captures for complete coverage
  • Create alerts for critical error rates and performance regressions

Example use cases

  • Add Sentry to NestJS: install @sentry/node, initialize in main.ts before app bootstrap, and read SENTRY_DSN from env
  • Add Sentry to Next.js: run the Sentry Next.js wizard, configure client/server DSNs, and set NEXT_PUBLIC_SENTRY_DSN
  • Add Google Analytics: include GA script in root layout, set NEXT_PUBLIC_GA_MEASUREMENT_ID, and implement pageview tracking
  • Track business events: create analytics helper functions to record signups, purchases, and feature usage
  • Deploy monitoring: configure production alerts and increase sample rates temporarily for troubleshooting

FAQ

Do I need different DSNs for dev and prod?

Yes. Use separate DSNs to avoid polluting production data with development noise and to protect production privacy.

Can I track errors from serverless or edge functions?

Yes. Sentry provides adapters for serverless and edge runtimes; configure the appropriate SDK and initialize it in the function entry points.