[INIT] Sentry & 디스코드 웹훅 초기 세팅 - #27
Conversation
- @sentry/nextjs 패키지를 의존성에 추가했습니다
- withSentryConfig 적용, 런타임별 Sentry 초기화 설정 및 글로벌 에러 바운더리를 추가했습니다
- NEXT_PUBLIC_SENTRY_DSN 등 Sentry 관련 환경변수를 globalEnv에 등록했습니다
…to init/web/24-sentry-discord-webhook # Conflicts: # apps/timo-web/package.json # pnpm-lock.yaml # turbo.json
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughSentry Next.js 연동을 위해 의존성, 빌드 설정, 런타임 초기화, 전역 오류 화면을 추가했습니다. 클라이언트 라우팅과 서버/엣지 요청 오류가 Sentry로 전달되고, 전역 오류 화면은 재시도 동작을 제공합니다. ChangesSentry 초기화와 오류 캡처
Sequence Diagram(s)sequenceDiagram
participant NextRuntime
participant instrumentation.ts
participant sentry.server.config.ts
participant sentry.edge.config.ts
participant Sentry
NextRuntime->>instrumentation.ts: register()
instrumentation.ts->>sentry.server.config.ts: import when NEXT_RUNTIME=serverjs
instrumentation.ts->>sentry.edge.config.ts: import when NEXT_RUNTIME=edge
sentry.server.config.ts->>Sentry: init with DSN and environment
sentry.edge.config.ts->>Sentry: init with DSN and environment
instrumentation.ts->>Sentry: captureRequestError
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
참고 문서🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
📦 번들 사이즈 리포트🕐 Timo Web
빌드 커밋: |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/timo-web/app/global-error.tsx`:
- Line 17: The global error document root in global-error.tsx renders an <html>
element without a lang attribute, which triggers accessibility/lint issues.
Update the <html> in the global-error component to include an explicit language
code, using the existing document-root render path in global-error.tsx so screen
readers and Next.js linting are satisfied.
In `@apps/timo-web/next.config.js`:
- Line 11: The `silent: !process.env.CI` usage in `next.config.js` triggers
`no-undef` because `process` is not declared as a Node global in the current
ESLint setup. Fix this by adding `process` to the `languageOptions.globals`
override for `**/next.config.js` in the ESLint flat config, or by explicitly
importing `process` from `node:process` in `next.config.js` if that matches the
repo’s style. Use the `next.config.js` file and the ESLint config files
referenced by the current setup to keep the rule consistent.
In `@turbo.json`:
- Around line 4-10: `SENTRY_AUTH_TOKEN` is currently being treated as a hashed
build input via `globalEnv`, but it should be passed through only for Sentry
upload during build. Update the Turborepo config so `tasks.build.passThroughEnv`
includes `SENTRY_AUTH_TOKEN` and remove it from `globalEnv`, then keep
`withSentryConfig` reading it from `process.env.SENTRY_AUTH_TOKEN` so the
`build` task and Sentry upload flow still work without affecting cache keys.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 90c324bd-24ff-45df-b797-b48db7662638
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (8)
apps/timo-web/app/global-error.tsxapps/timo-web/instrumentation-client.tsapps/timo-web/instrumentation.tsapps/timo-web/next.config.jsapps/timo-web/package.jsonapps/timo-web/sentry.edge.config.tsapps/timo-web/sentry.server.config.tsturbo.json
- global-error.tsx html 태그에 lang 속성을 추가했습니다 - next.config.js에 process 전역 변수 선언을 추가했습니다
- withSentryConfig에 SENTRY_AUTH_TOKEN 환경변수를 추가했습니다
- build 태스크에 SENTRY_AUTH_TOKEN을 passThroughEnv로 등록했습니다
kimminna
left a comment
There was a problem hiding this comment.
고생하셨어요!
.env 에 추가해야 할 값들은 노션 페이지 > 웹 > 자료 > .env 페이지에 공유해 주셔용
간단한 코멘트라 바로 어푸 남길게요!
- named export와 별도 default export를 단일 default function 선언으로 통합했습니다
jjangminii
left a comment
There was a problem hiding this comment.
Sentry에 대해 처음 알게 됐는데 잘 정리해주셔서 어떻게 동작할지 기대돼요-! 고생하셨어요 😊
간단한 코멘트 한 가지만 확인 부탁드려요!
yumin-kim2
left a comment
There was a problem hiding this comment.
Sentry 도입 이유부터 파일 구성, 고려한 사항까지 PR 설명이 너무 잘 정리돼 있어서 리뷰하기 편했어요.최고....👍
Discord 연동 삽질 과정도 공유해주셔서 나중에 참고하기 좋을 것 같아요. 수고하셨습니다-!!!✨
- 에러 발생 시 사용자에게 표시할 제목과 안내 문구를 추가했습니다
ISSUE 🔗
close #24
What is this PR? 🔍
apps/timo-web에 Sentry SDK를 연동하고, 에러 발생 시 Discord로 알림이 전송되는 파이프라인을 구축했습니다.Sentry를 도입한 이유
배포 후 유저가 에러를 만나도 개발자가 인지할 방법이 없었습니다. Sentry는 단순한 에러 로그와 달리 누가(유저 환경), 언제, 어디서(파일·라인), 왜(스택 트레이스) 에러가 났는지 한눈에 확인할 수 있어 도입했습니다.
에러 전송 흐름
파일 구성
Next.js는 코드가 실행되는 환경이 브라우저, 서버(Node.js), 엣지로 나뉘기 때문에 각각 초기화 파일을 분리했습니다.
instrumentation-client.tsinstrumentation.tssentry.server.config.tssentry.edge.config.tsapp/global-error.tsxnext.config.js구현 시 고려한 사항
DSN 없으면 초기화하지 않음
DSN 체크 없이
Sentry.init()을 호출하면 DSN이 없는 환경에서 콘솔 경고가 발생합니다. 클라이언트뿐 아니라 서버·엣지 설정에도 동일하게 적용해 일관성을 맞췄습니다.NODE_ENV대신NEXT_PUBLIC_SENTRY_ENVIRONMENT사용NODE_ENV는development/production두 가지만 존재해preview환경을 구분할 수 없습니다. 별도 환경변수로local/preview/production을 세분화했습니다.server와 edge 설정 파일 분리
현재는 두 파일의 코드가 동일하지만, 미들웨어가 추가되면 edge 환경에서 별도 설정이 필요할 수 있어 미리 분리해두었습니다.
Discord 연동 방식
처음에 Legacy Webhooks를 사용했으나 Sentry가 보내는 JSON 포맷과 Discord 웹훅이 받는 포맷이 달라 전송이 실패했습니다. Sentry 공식 Discord Integration + Internal Integration 방식으로 전환해 해결했습니다.
To Reviewers
environment기본값을local로 설정했습니다.production/preview값은 배포 환경변수에서 주입해야 Sentry에서 환경별로 분리됩니다..env.local에서 관리하며 git에 올라가지 않습니다. 팀원 각자 로컬에서.env.local에 DSN을 추가해야 Sentry가 동작합니다.SENTRY_AUTH_TOKEN이 없어 source map 업로드는 현재 동작하지 않습니다. CI/CD 설정 시 함께 추가할 예정입니다.Screenshot 📷
Test Checklist ✔
#웹-에러알림채널 알림 수신 확인pnpm build— 미실행: CI에서 확인 예정SENTRY_AUTH_TOKEN설정 후 별도 확인 예정