Skip to content

Conversation

six-standard
Copy link
Member

@six-standard six-standard commented Apr 22, 2025

🔥 변경 사항

센트리에 소스맵이 업로드되지 않던 이슈를 해결하였습니다.
빌드 직후의 업로드를 위해 깃 액션 파일을 일부 수정하였습니다.

🏷 관련 이슈

  • 관련 이슈: #173

📸 스크린샷 (UI 변경 시 필수)

X

📌 체크리스트

  • 기능이 정상적으로 동작하는지 테스트 완료
  • 코드 스타일 가이드 준수 여부 확인
  • 관련 문서 업데이트 완료 (필요 시)

Summary by CodeRabbit

  • 신규 기능

    • Sentry 오류 추적 도구가 프로덕션 환경에서만 활성화되도록 설정되었습니다.
    • 프로덕션 빌드 시 브라우저 소스맵이 자동으로 생성되고 관리됩니다.
  • 버그 수정

    • Sentry 관련 샘플링 비율 및 릴리즈 버전이 고정되어 환경에 상관없이 일관된 동작을 보장합니다.
    • 소스맵 업로드 후 자동 삭제 기능이 추가되어 빌드 용량 최적화가 이루어집니다.
  • 문서화

    • Sentry 설정에 대한 주석이 한글로 추가 및 보완되었습니다.
  • 스타일

    • 일부 설정 배열 및 옵션이 코드 내에서 더 간결하게 정렬되었습니다.

Copy link

Copy link

coderabbitai bot commented Apr 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

이번 변경에서는 Sentry 설정이 전반적으로 개편되고, Next.js의 소스맵 및 Webpack 관련 설정이 개선되었습니다. Sentry 관련 설정에서는 각 환경별로 Sentry 활성화 여부를 명확히 하였고, release 버전을 고정값으로 지정했으며, 샘플링 비율 및 기타 여러 옵션이 일관적으로 변경되었습니다. 또한 Next.js의 production 소스맵 생성이 활성화되고, Webpack의 devtool 설정이 빌드 환경에 따라 동적으로 지정되도록 수정되었습니다. Sentry 업로드 및 로깅 관련 옵션도 세분화되어 적용되었습니다.

Changes

파일(들) 변경 요약
next.config.mjs productionBrowserSourceMapstrue로 설정, hideSourceMaps 제거, Webpack devtool을 환경에 따라 동적 지정, Sentry 설정 전면 개편 및 한국어 주석 추가, 여러 Sentry 옵션(예: authToken, sourcemaps.deleteSourcemapsAfterUpload, hideSourceMaps, silent, disableLogger) 추가 및 수정
sentry.client.config.ts, sentry.edge.config.ts, sentry.server.config.ts Sentry release'production'으로 고정, tracesSampleRate를 상수로 지정, production 환경에서만 Sentry 활성화하는 enabled 플래그 도입, integrations 배열 단일 라인으로 재포맷, 설정 단순화 및 일관성 강화

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NextApp
    participant Sentry

    User->>NextApp: 요청
    NextApp-->>Sentry: (production 환경 & enabled=true) 오류/트레이스 전송 (release='production', tracesSampleRate 고정)
    NextApp-->>User: 응답
Loading

Suggested labels

enhancement

Suggested reviewers

  • Jihyun3478
  • Nuung

Poem

🐇
소스맵이 빛나네, 프로덕션 밤에
Sentry 깃발 아래, 오류는 잠재네
release는 고정, 샘플링도 정직
환경 따라 켜고 끄는 센스까지
코드 토끼 춤추네, 로그와 함께!
🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

next.config.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

ReferenceError: globals is not defined
at file:///eslint.config.mjs?mtime=1745297382000:17:12
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:483:26)
at async loadFlatConfigFile (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/flat-eslint.js:303:21)
at async calculateConfigArray (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/flat-eslint.js:382:28)
at async FlatESLint.lintFiles (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/flat-eslint.js:762:25)
at async Object.execute (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js:421:23)
at async main (/node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js:152:22)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db378ae and a9f8a63.

📒 Files selected for processing (1)
  • next.config.mjs (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/docker-publish.yaml (1)

25-25: 글로벌 설치 대신 pnpm dlx 사용을 고려해주세요.

현재 npm install -g @sentry/cli로 Sentry CLI를 글로벌 설치하고 있는데, CI 속도를 위해 로컬로 설치하거나 pnpm dlx @sentry/cli를 활용하는 것이 좋습니다.

  • 글로벌 설치가 캐시되지 않아 워크플로우가 매번 동일 패키지를 다시 설치할 수 있습니다.
  • 특정 버전을 고정하려면 @sentry/cli@버전 형식으로 명시하세요.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46d4b9d and 7191e13.

📒 Files selected for processing (5)
  • .github/workflows/docker-publish.yaml (2 hunks)
  • next.config.mjs (1 hunks)
  • sentry.client.config.ts (2 hunks)
  • sentry.edge.config.ts (1 hunks)
  • sentry.server.config.ts (1 hunks)
🔇 Additional comments (11)
next.config.mjs (3)

7-7: 프로덕션 환경에서 브라우저 소스맵 비활성화 설정 추가

프로덕션 환경에서 브라우저 소스맵을 비활성화하는 productionBrowserSourceMaps: false 설정을 추가했습니다. 이는 Sentry에 소스맵을 직접 업로드하는 방식으로 전환하기 위한 적절한 설정입니다.


11-11: SVG 로더 설정 형식 변경

SVG 로더 설정을 한 줄로 압축했습니다. 기능적으로는 동일하지만 가독성이 향상되었습니다.


13-16: 환경별 소스맵 생성 전략 구현

개발 모드가 아닐 때 환경에 따라 다른 소스맵 생성 전략을 사용하도록 설정했습니다:

  • 프로덕션 환경: hidden-source-map (별도 파일로 소스맵 생성)
  • 기타 환경: inline-source-map (번들에 소스맵 포함)

이 설정은 Sentry와 함께 사용할 때 적절하며, 프로덕션에서는 소스맵을 숨기면서도 Sentry가 읽을 수 있도록 하는 접근 방식입니다.

sentry.edge.config.ts (2)

13-13: 트레이스 샘플링 비율 고정

기존 환경별 조건부 샘플링 비율에서 고정값 0.05로 변경했습니다. 이는 모든 환경에서 일관된 샘플링을 제공합니다.


17-17: 프로덕션 환경에서만 Sentry 활성화

enabled: process.env.NODE_ENV === 'production' 플래그를 추가하여 프로덕션 환경에서만 Sentry가 활성화되도록 설정했습니다. 이는 개발 및 테스트 환경에서 불필요한 오류 보고를 방지하는 좋은 방법입니다.

sentry.server.config.ts (2)

12-12: 서버 트레이스 샘플링 비율 고정

서버 측 트레이스 샘플링 비율을 0.1로 고정하여 클라이언트 및 엣지 구성과 일관된 접근 방식을 유지했습니다.


16-16: 프로덕션 환경에서만 서버 Sentry 활성화

enabled: process.env.NODE_ENV === 'production' 플래그를 추가하여 클라이언트 및 엣지 구성과 동일한 방식으로 프로덕션 환경에서만 서버 Sentry를 활성화하도록 설정했습니다.

sentry.client.config.ts (3)

12-12: 통합 배열 형식 개선

Sentry 통합 배열 형식을 단일 라인으로 정리하여 가독성을 향상시켰습니다.


15-15: 클라이언트 트레이스 샘플링 비율 고정

클라이언트 측 트레이스 샘플링 비율을 조건부 표현식에서 고정값 0.1로 변경했습니다. 이는 서버 측 구성과 일치하며 일관된 모니터링을 제공합니다.


27-27: 프로덕션 환경에서만 클라이언트 Sentry 활성화

enabled: process.env.NODE_ENV === 'production' 플래그를 추가하여 서버 및 엣지 구성과 일관되게 프로덕션 환경에서만 클라이언트 Sentry를 활성화하도록 설정했습니다.

.github/workflows/docker-publish.yaml (1)

51-53: Sentry Org/Project 설정값 검증 요청

SENTRY_ORG: velog-dashboard2, SENTRY_PROJECT: vd-fe가 실제 Sentry 대시보드의 조직 및 프로젝트 슬러그와 일치하는지 다시 확인해주세요.

@six-standard six-standard added the bug Something isn't working label Apr 22, 2025
@six-standard six-standard self-assigned this Apr 22, 2025
Copy link
Member

@Nuung Nuung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크게 이견없습니다. 2 가지 정도 제안 사항이 있어요.

  1. 코드 레빗이 찝어준 바와 같이 릴리즈에 버저닝을 해야 디버깅할때 "언제" 배포 해서 "어느 때" 나온 이슈인제 추적하기 용이할 것 같아요.
  2. 더욱이 기준님, notion task 를 꼭 채워주세요. 기준님 아니면 다른 분들이 해당 내용에 대한 F/U 이 매우 힘듭니다. 특히 이런 task 는 다른 F/W 나 language 와 공유되는 부분이 아니라 철저하게 nextjs 에서만, 더욱이 nextjs 의 sentry 에서만 적용되는 부분이라서요!

너무 고생많으셨어요. 소스맵이 파악이 안되는 정확한 이유는 무엇이라고 봐야할까요?

Copy link

@ooheunda ooheunda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 잘 봤습니다.
제가 FE쪽은 아주 생소해서 GPT의 도움을 받으며 리뷰했는데요. 소스맵이라는 것도 신기한데, 외부 모니터링 솔루션에 전송하는 과정에서 난독화된 코드를 어떻게 처리할 수 있는지를 알게 되어서 좋았습니다!

코드래빗과 현우님이 코멘트 남겨주셔서, 해당 부분 반영되면 다시 보고 Approve 드릴게요!
이슈 해결하시느라 고생하셨습니다! 👍 🔥

Copy link

@Jihyun3478 Jihyun3478 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋았던 점

  • 소스맵이 등록되더라도 실제 오류 트레이스에 적용되지 않는 경우가 발생할 수 있군요! 코드 바뀐 부분 천천히 따라가면서 오류 해결 과정을 엿볼 수 있어서 좋았습니다! 고생하셨습니다!!🔥

PS. 피드백 반영되면 다시 살펴보겠습니다!!

@six-standard
Copy link
Member Author

six-standard commented Apr 25, 2025

크게 이견없습니다. 2 가지 정도 제안 사항이 있어요.

  1. 코드 레빗이 찝어준 바와 같이 릴리즈에 버저닝을 해야 디버깅할때 "언제" 배포 해서 "어느 때" 나온 이슈인제 추적하기 용이할 것 같아요.
  2. 더욱이 기준님, notion task 를 꼭 채워주세요. 기준님 아니면 다른 분들이 해당 내용에 대한 F/U 이 매우 힘듭니다. 특히 이런 task 는 다른 F/W 나 language 와 공유되는 부분이 아니라 철저하게 nextjs 에서만, 더욱이 nextjs 의 sentry 에서만 적용되는 부분이라서요!

너무 고생많으셨어요. 소스맵이 파악이 안되는 정확한 이유는 무엇이라고 봐야할까요?

혹시나 싶어 계속 조사해보니, 센트리 옵션 객체의 일부 속성값에 문제가 있어 정상 동작이 안 되는 경우가 있다는 말이 있어 해당 내용 반영하였습니다.
해당 내용 반영 후 로컬 빌드 진행하니 정상적으로 소스맵이 업로드되는 것 같네요..

옵션 파일의 내용을 상세히 확인하지 못한 제 불찰일 듯 합니다.

우선 수정된 내용 마무리하고 빠르게 커밋하겠습니다!

  • 추가로 버저닝도 적용해볼 생각이 있었으나, 자동으로 현재 날짜 + 시간 기반의 이름이 붙는 걸 보고 일단은 놔두기로 했습니다.
    애초에 버저닝의 기준 중에서 날짜 + 시간이 가장 정확한 것 같기도 하네요

옵션값을 수정하니 @sentry/nextjs 자체 소스맵 기능을 통해 정상적으로 소스맵이 업로드되는 것을 확인하였습니다!
@six-standard six-standard requested a review from Nuung April 25, 2025 00:40
Copy link
Member

@Nuung Nuung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이욜 너무 고생 많았어요 ㅋㅋㅋ 저는 이런 디테일 작업 할때 너무 짜증나더라구요 :) 머지드갑시다!!

@six-standard six-standard merged commit 8a7369a into main Apr 26, 2025
1 check was pending
@six-standard six-standard deleted the refactor/apply-sentry-sourcemap branch April 26, 2025 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants