master-project
CHAPTER 40 / 50
읽기 약 2분
FUNCTION
모니터링: Sentry + GA4 + Clarity
핵심 개념
에러 추적·사용자 분석·세션 녹화·커스텀 이벤트 — 사용자 행동·이슈 가시성.
본문
Sentry (에러 추적)
pnpm add @sentry/nextjs
pnpm exec @sentry/wizard@latest -i nextjs// sentry.client.config.ts
import * as Sentry from '@sentry/nextjs'
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.1, // 10% 트랜잭션 샘플
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
integrations: [Sentry.replayIntegration()],
})// Server에서 명시적 capture
import * as Sentry from '@sentry/nextjs'
try {
await dangerousOp()
} catch (err) {
Sentry.captureException(err, {
tags: { component: 'ai-generation' },
user: { id: userId },
})
throw err
}GA4 (Google Analytics)
// src/app/layout.tsx
import Script from 'next/script'
const GA_ID = process.env.NEXT_PUBLIC_GA_ID
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
strategy="afterInteractive"
/>
<Script id="ga" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}', { page_path: window.location.pathname });
`}
</Script>// 커스텀 이벤트
declare global { interface Window { gtag: (...args: any[]) => void } }
export function trackEvent(name: string, params?: Record<string, any>) {
window.gtag?.('event', name, params)
}
// 사용
trackEvent('ai_generation', { template: 'instagram', tokens: 200 })
trackEvent('subscription_started', { plan: 'pro', value: 19 })Microsoft Clarity (세션 녹화)
const CLARITY_ID = process.env.NEXT_PUBLIC_CLARITY_ID
<Script id="clarity" strategy="afterInteractive">
{`
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "${CLARITY_ID}");
`}
</Script>[Clarity 사용]
- 세션 녹화 (사용자 화면 보기)
- 히트맵·스크롤맵
- Rage click·Dead click 감지
- 무료 무제한PostHog (제품 분석 + 기능 플래그)
pnpm add posthog-js// src/components/posthog-provider.tsx
'use client'
import posthog from 'posthog-js'
import { PostHogProvider } from 'posthog-js/react'
import { useEffect } from 'react'
if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: 'https://us.i.posthog.com',
capture_pageview: false, // 수동
})
}
export function PHProvider({ children }: { children: React.ReactNode }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
}// 이벤트 + 사용자 식별
posthog.identify(userId, { email, plan })
posthog.capture('ai_generation', { template, tokens })
// Funnel: 가입 → 생성 → 결제
// Retention: D1 D7 D30
// 자동 인사이트핵심 KPI 추적
[가입 funnel]
visit → signup → first_generation → subscription
70% → 5% → 60% → 5%
[제품 funnel]
generate_clicked → generation_done → copy_clicked → shared
[결제]
subscription_started, subscription_canceled, plan_upgraded알림 (Sentry → Slack)
Sentry → Settings → Integrations → Slack
- Project alerts: 100+ events/hour → Slack
- Crash rate > 1% → Slack다음 챕터
CH.41 "CI/CD: GitHub Actions → 자동 배포".
AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude
무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6
내 마스터 프로젝트의 모니터링 부분을 분석해서 실전 적용 + 개선 우선순위 3가지를 알려줘.
ChatGPT
무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro
모니터링 관련 모범 사례·안티패턴 5개를 비교 분석해서 실전 적용를 위한 추천 방안을 알려줘.
Gemini
무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro
내 프로젝트 전체에서 모니터링 최적화 가능 위치와 리스크를 보고해줘.
Grok
무료: Grok 4.1 / SuperGrok $30/mo
2026년 한국 1인 개발자 시장의 모니터링 트렌드와 차별화 포인트를 정리해줘.
⭐ 이것만 기억하세요
모니터링: Sentry + GA4 + Clarity는 이 3가지만 확실히 잡으세요
1.Sentry (에러) + GA4 (트래픽) + Clarity (세션) + PostHog (제품) = 4중 모니터링
2.핵심 funnel 자동 추적 → 데이터 기반 개선
3.다음 챕터에서 CI/CD 파이프라인
공유하기
진행도 40 / 50