-
Notifications
You must be signed in to change notification settings - Fork 1
chore: 에러 모니터링 환경 구축을 위한 Sentry 도입 #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- `@sentry/nextjs` 패키지 설치 및 초기 설정 파일(client/server/edge config) 생성 - `error.tsx` 및 `global-error.tsx`에 Sentry 캡처 로직 연동 (런타임 에러 추적) - Axios Response Interceptor에 API 에러 자동 수집 로직 추가 - 개발 환경(`development`)에서의 불필요한 트래킹 비활성화 설정 추가
둘러보기Sentry 오류 모니터링 및 계측 기능을 Next.js 웹 애플리케이션에 통합합니다. Sentry 의존성을 추가하고, 클라이언트/서버/엣지 구성 파일을 생성하며, 글로벌 오류 처리 컴포넌트와 Axios 인터셉터를 통해 오류 캡처를 구현합니다. 변경 사항
예상 코드 리뷰 노력🎯 3 (중간) | ⏱️ ~25분 관련 이슈
관련 PR
제안 레이블
토끼의 축하 시
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🧹 Nitpick comments (4)
apps/web/sentry.server.config.ts (1)
7-21: 환경 변수 NEXT_PUBLIC_SENTRY_DSN 설정을 문서화하세요.Sentry 초기화에 필요한
NEXT_PUBLIC_SENTRY_DSN환경 변수가 설정되지 않으면 오류가 발생할 수 있습니다. README나 환경 변수 문서에 필수 설정을 추가하는 것이 좋습니다.환경 변수 설정 문서 작성을 도와드릴까요?
apps/web/instrumentation-client.ts (1)
23-26: Session Replay 샘플링 비율을 트래픽에 따라 조정하세요.
replaysSessionSampleRate: 0.1(10%)과replaysOnErrorSampleRate: 1.0(100%) 설정은 적절해 보이지만, 트래픽이 많은 경우 세션 리플레이 데이터 전송량이 클 수 있습니다. 프로덕션 배포 후 모니터링하여 필요시 조정하세요.apps/web/instrumentation.ts (1)
3-11: 동적 import 실패에 대한 에러 핸들링 추가를 권장합니다.현재 구현은 정상적인 케이스에서는 잘 동작하지만, 다음 사항들을 고려해보세요:
- 동적 import가 실패할 경우 에러가 전파되어 애플리케이션 시작이 중단될 수 있습니다.
NEXT_RUNTIME이 예상치 못한 값이거나 undefined인 경우 아무 설정도 로드되지 않습니다.🔎 에러 핸들링을 추가한 개선안
export async function register() { - if (process.env.NEXT_RUNTIME === 'nodejs') { - await import('./sentry.server.config') - } - - if (process.env.NEXT_RUNTIME === 'edge') { - await import('./sentry.edge.config') - } + try { + if (process.env.NEXT_RUNTIME === 'nodejs') { + await import('./sentry.server.config') + } else if (process.env.NEXT_RUNTIME === 'edge') { + await import('./sentry.edge.config') + } + } catch (error) { + console.error('Failed to load Sentry configuration:', error) + } }apps/web/sentry.edge.config.ts (1)
8-11: DSN 환경 변수 누락 시 경고 처리를 고려해보세요.현재 구현은
NEXT_PUBLIC_SENTRY_DSN이 설정되지 않아도 에러 없이 진행됩니다. Sentry는 내부적으로 경고를 출력하지만, 프로덕션 배포 전 누락을 명시적으로 확인하는 것이 좋습니다.🔎 DSN 검증 추가 예시
+if (process.env.NODE_ENV === 'production' && !process.env.NEXT_PUBLIC_SENTRY_DSN) { + console.warn('NEXT_PUBLIC_SENTRY_DSN is not set. Sentry will not be initialized.') +} + Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV === 'production',
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
apps/web/.gitignoreapps/web/app/_lib/axiosInstance.tsapps/web/app/error.tsxapps/web/app/global-error.tsxapps/web/instrumentation-client.tsapps/web/instrumentation.tsapps/web/next.config.tsapps/web/package.jsonapps/web/sentry.edge.config.tsapps/web/sentry.server.config.tsturbo.json
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/instrumentation-client.ts (1)
apps/web/app/places/search/page.tsx (1)
id(25-27)
🔇 Additional comments (14)
apps/web/app/_lib/axiosInstance.ts (2)
6-6: LGTM!Next.js 프로젝트에 적합한 Sentry 패키지를 사용하고 있으며, import 구문이 올바릅니다.
38-40: 에러 필터링 전략 명확화 필요.TODO 코멘트에서 400대 에러 전체를 제외할지 검토 중이신 것으로 보입니다. 현재는 401만 제외하고 있는데, 다음 사항을 고려하여 전략을 결정하시는 것을 권장합니다:
- 400 Bad Request: 클라이언트 입력 검증 실패 - 일반적으로 정상적인 플로우이므로 제외 고려
- 403 Forbidden: 권한 부족 - 모니터링 필요할 수 있음
- 404 Not Found: 존재하지 않는 리소스 - 빈도에 따라 제외 고려
- 422 Unprocessable Entity: 비즈니스 로직 검증 실패 - 일반적으로 정상적인 플로우
- 429 Too Many Requests: Rate limiting - 모니터링 필요
서버 에러(5xx)는 반드시 모니터링하되, 클라이언트 에러(4xx)는 선별적으로 로깅하는 것이 일반적입니다.
🔎 제안: 5xx 에러만 캡처하도록 수정
- // Todo: 상태 코드 400 전체 제외할지 말지 데이터를 보고 정하기 - // error.response.status >= 500 && - // error.response.status < 600 - if (error.response?.status !== 401) { + // 서버 에러(5xx)만 Sentry에 전송 + const status = error.response?.status + if (status && status >= 500 && status < 600) { Sentry.captureException(error, { extra: { url: originalRequest?.url, method: originalRequest?.method, - status: error.response?.status, - data: error.response?.data, + status, }, }) }운영 후 데이터를 확인하여 필요한 경우 특정 4xx 에러(예: 403)를 추가로 포함하는 방식으로 조정하실 수 있습니다.
apps/web/.gitignore (1)
36-37: LGTM!Sentry 빌드 플러그인이 생성하는 환경 파일을 올바르게 제외하고 있습니다.
turbo.json (1)
4-4: LGTM!
NEXT_RUNTIME과CI환경 변수 추가는 Sentry의 런타임별 설정 로딩과 빌드 로그 제어를 위해 필요합니다.apps/web/app/error.tsx (2)
18-20: LGTM!
useEffect를 사용한 에러 캡처 패턴이 올바르게 구현되었습니다. React 렌더링 중 발생한 에러를 Sentry에 전송합니다.
31-41: LGTM!재시도 버튼과 홈 이동 링크를 추가하여 사용자 경험이 개선되었습니다.
apps/web/instrumentation-client.ts (1)
33-33: LGTM!
onRouterTransitionStart내보내기는 라우터 전환 추적에 유용합니다.apps/web/next.config.ts (3)
70-106: LGTM!Sentry 통합 설정이 잘 구성되어 있습니다.
tunnelRoute를 통한 광고 차단 우회, CI 환경별 로깅 제어, 소스맵 업로드 최적화 등이 적절히 설정되었습니다.
74-76: Sentry organization과 project 이름을 확인하세요.하드코딩된
org: "ss-vp"와project: "javascript-nextjs"값이 실제 Sentry 설정과 일치하는지 확인이 필요합니다.Sentry 대시보드에서 organization과 project 이름을 확인하거나, 환경 변수로 관리하는 것을 고려하세요:
org: process.env.SENTRY_ORG || "ss-vp", project: process.env.SENTRY_PROJECT || "javascript-nextjs",
91-91: 미들웨어가/monitoring경로를 처리하지 않으므로 충돌 위험이 없습니다.
middleware.ts의 matcher 설정이/likes,/profile,/requests,/events/lucky-draw,/events/gifticon경로만 포함하고 있으므로 Sentry 터널 경로/monitoring은 안전하게 작동합니다.Likely an incorrect or invalid review comment.
apps/web/app/global-error.tsx (2)
14-16: LGTM!최상위 에러 경계에서 Sentry로 예외를 캡처하는 패턴이 올바르게 구현되었습니다.
19-37: LGTM!
global-error.tsx는 완전한 HTML 구조를 포함해야 하며, 이 요구사항을 올바르게 충족하고 있습니다. 전역 에러 처리에 적합한 UI와 새로고침 기능을 제공합니다.apps/web/package.json (1)
24-24: 호환성 확인 완료 - 우려사항 없음@sentry/nextjs v10은 프로젝트의 Next.js 15.4.10과 완벽하게 호환됩니다. @sentry/nextjs v10은 Next.js 13.2.0 이상을 요구하며, 현재 설정된 버전은 모든 요구사항을 충족합니다.
apps/web/instrumentation.ts (1)
13-13: LGTM!Next.js instrumentation API의
onRequestErrorhook을 Sentry의captureRequestError와 올바르게 연결했습니다.
| if (error.response?.status !== 401) { | ||
| Sentry.captureException(error, { | ||
| extra: { | ||
| url: originalRequest?.url, | ||
| method: originalRequest?.method, | ||
| status: error.response?.status, | ||
| data: error.response?.data, | ||
| }, | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
민감 정보 유출 위험: response data 로깅 제거 또는 필터링 필요.
error.response?.data를 Sentry에 전송하면 다음과 같은 심각한 보안 및 개인정보 보호 문제가 발생할 수 있습니다:
- 개인정보(PII) 유출: 사용자 이메일, 전화번호, 주소 등이 API 응답에 포함될 수 있음
- 보안 정보 노출: 인증 토큰, 세션 ID, API 키 등이 에러 응답에 포함될 수 있음
- 규정 준수 위반: GDPR, 개인정보보호법 위반 가능성
Sentry는 외부 모니터링 서비스이므로, 민감한 데이터가 외부로 전송되지 않도록 주의해야 합니다.
🔎 권장 해결 방법
방법 1 (권장): response data 필드 완전 제거
if (error.response?.status !== 401) {
Sentry.captureException(error, {
extra: {
url: originalRequest?.url,
method: originalRequest?.method,
status: error.response?.status,
- data: error.response?.data,
},
})
}방법 2: 민감 정보 필터링 후 로깅
+ const sanitizeErrorData = (data: any) => {
+ if (!data) return undefined
+ const sanitized = { ...data }
+ // 민감 필드 제거
+ const sensitiveFields = ['password', 'token', 'accessToken', 'refreshToken', 'email', 'phone', 'address']
+ sensitiveFields.forEach(field => delete sanitized[field])
+ return sanitized
+ }
+
if (error.response?.status !== 401) {
Sentry.captureException(error, {
extra: {
url: originalRequest?.url,
method: originalRequest?.method,
status: error.response?.status,
- data: error.response?.data,
+ data: sanitizeErrorData(error.response?.data),
},
})
}또한 Sentry 설정에서 beforeSend 훅을 사용하여 전역적으로 민감 정보를 필터링할 수도 있습니다.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (error.response?.status !== 401) { | |
| Sentry.captureException(error, { | |
| extra: { | |
| url: originalRequest?.url, | |
| method: originalRequest?.method, | |
| status: error.response?.status, | |
| data: error.response?.data, | |
| }, | |
| }) | |
| } | |
| if (error.response?.status !== 401) { | |
| Sentry.captureException(error, { | |
| extra: { | |
| url: originalRequest?.url, | |
| method: originalRequest?.method, | |
| status: error.response?.status, | |
| }, | |
| }) | |
| } |
🤖 Prompt for AI Agents
In apps/web/app/_lib/axiosInstance.ts around lines 41 to 50, the current Sentry
capture includes error.response?.data which can leak PII or secrets; remove
sending the full response body and instead either omit error.response.data
entirely or sanitize it before sending (e.g., whitelist only non-sensitive
fields like status and headers, or send a truncated/summary string), and update
the Sentry.extra payload to include only safe values (url, method, status, and a
sanitized/omitted data field) or rely on Sentry's beforeSend global filter to
scrub any remaining sensitive fields.
| integrations: [Sentry.replayIntegration()], | ||
|
|
||
| // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
| tracesSampleRate: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로덕션 환경에서 tracesSampleRate를 낮추세요.
서버 설정과 마찬가지로 클라이언트의 tracesSampleRate: 1(100% 샘플링)은 프로덕션 환경에서 성능과 비용 문제를 야기할 수 있습니다.
🔎 권장 수정사항
- tracesSampleRate: 1,
+ tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tracesSampleRate: 1, | |
| tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1, |
🤖 Prompt for AI Agents
In apps/web/instrumentation-client.ts around line 16, the client currently sets
tracesSampleRate: 1 which will sample 100% of transactions and can harm
performance and cost in production; change this to use an environment-driven
value (e.g., process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE or a small
numeric default like 0.05–0.2) and only enable 100% in development, or implement
tracesSampler to programmatically control sampling based on environment and
request/context.
|
|
||
| // Enable sending user PII (Personally Identifiable Information) | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii | ||
| sendDefaultPii: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
fd "instrumentation-client" --type fRepository: knu-matzip/Matzip-Client
Length of output: 102
🏁 Script executed:
cat -n apps/web/instrumentation-client.tsRepository: knu-matzip/Matzip-Client
Length of output: 1566
🏁 Script executed:
find . -type f -name "*instrumentation*" | head -20Repository: knu-matzip/Matzip-Client
Length of output: 134
🏁 Script executed:
fd "sentry" --type f -e py -e ts -e js | grep -E "(server|backend|instrumentation)" | head -20Repository: knu-matzip/Matzip-Client
Length of output: 100
🏁 Script executed:
find . -type f \( -name "PRIVACY*" -o -name "privacy*" -o -name "DATA_PROTECTION*" -o -name "*policy*" \) | head -10Repository: knu-matzip/Matzip-Client
Length of output: 50
🏁 Script executed:
cat -n apps/web/instrumentation.tsRepository: knu-matzip/Matzip-Client
Length of output: 480
🏁 Script executed:
cat -n apps/web/sentry.server.config.tsRepository: knu-matzip/Matzip-Client
Length of output: 971
🏁 Script executed:
cat -n README.md 2>/dev/null | head -50Repository: knu-matzip/Matzip-Client
Length of output: 2561
🏁 Script executed:
find . -type f \( -name "README*" -o -name "CHANGELOG*" \) -exec grep -l "privacy\|PII\|Sentry\|data" {} \;Repository: knu-matzip/Matzip-Client
Length of output: 50
Sentry sendDefaultPii 설정의 개인정보 보호 정책 검토 필요
sendDefaultPii: true 설정은 클라이언트와 서버 모두에서 사용자 PII(IP 주소, 쿠키, 사용자 컨텍스트 등)를 Sentry 서드파티 서비스로 전송합니다. 이 설정이 개인정보 보호 정책, 이용약관, 그리고 필요한 경우 사용자 동의와 일치하는지 확인하세요.
🤖 Prompt for AI Agents
In apps/web/instrumentation-client.ts around line 30, the Sentry option
sendDefaultPii is set to true which will send user PII to a third party; change
this to false by default and implement one of the following fixes: (1) require
explicit user consent before enabling sendDefaultPii (store consent flag and
enable Sentry only after consent), (2) gate the setting behind a server-side or
build-time env var (e.g., SENTRY_SEND_PII=true) and document it, or (3) keep it
true only after confirming legal/privacy review and add client/server-side
scrubbing to remove sensitive fields; also add a comment and tests/QA steps
showing where consent/env is checked and update privacy docs accordingly.
| // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
| tracesSampleRate: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로덕션 환경에서 tracesSampleRate를 낮춰야 합니다.
tracesSampleRate: 1은 모든 트랜잭션(100%)을 샘플링하므로 프로덕션 환경에서 다음과 같은 문제가 발생할 수 있습니다:
- Sentry 사용 비용이 크게 증가
- 애플리케이션 성능 오버헤드 발생
- 대용량 트래픽 시 Sentry 할당량 초과 가능
일반적으로 프로덕션에서는 0.1 (10%) 이하로 설정하는 것을 권장합니다.
🔎 권장 설정
- // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
- tracesSampleRate: 1,
+ // Adjust this value based on your traffic volume and budget
+ tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | |
| tracesSampleRate: 1, | |
| // Adjust this value based on your traffic volume and budget | |
| tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1, |
🤖 Prompt for AI Agents
In apps/web/sentry.edge.config.ts around lines 13-14, tracesSampleRate is
hard-coded to 1 which will sample 100% of transactions in production; change
this to a lower default (e.g., 0.1) and wire it to an environment variable
(e.g., SENTRY_TRACES_SAMPLE_RATE) so production can use a small rate, and
consider replacing the fixed value with tracesSampler for dynamic sampling logic
based on environment, user, or transaction characteristics.
| // Enable sending user PII (Personally Identifiable Information) | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii | ||
| sendDefaultPii: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cd apps/web && find . -name "sentry.edge.config.ts" -o -name "sentry*.config.ts" | head -20Repository: knu-matzip/Matzip-Client
Length of output: 117
🏁 Script executed:
cat -n apps/web/sentry.edge.config.tsRepository: knu-matzip/Matzip-Client
Length of output: 1133
🏁 Script executed:
# Search for any other Sentry configuration files or beforeSend callbacks
rg -l "beforeSend|Sentry.init" --type ts --type js | head -20Repository: knu-matzip/Matzip-Client
Length of output: 166
🏁 Script executed:
# Check if there are any privacy-related policies or documentation
find . -name "*privacy*" -o -name "*gdpr*" -o -name "*policy*" 2>/dev/null | grep -v node_modules | head -20Repository: knu-matzip/Matzip-Client
Length of output: 50
🏁 Script executed:
cat -n apps/web/sentry.server.config.tsRepository: knu-matzip/Matzip-Client
Length of output: 971
🏁 Script executed:
cat -n apps/web/instrumentation-client.tsRepository: knu-matzip/Matzip-Client
Length of output: 1566
🏁 Script executed:
# Search more broadly for beforeSend or data filtering in Sentry configs
rg "beforeSend|afterSend|integrations" apps/web/ --type ts --type js -A 3 -B 1Repository: knu-matzip/Matzip-Client
Length of output: 521
🏁 Script executed:
# Check if there's a package.json to see Sentry version
cat apps/web/package.json | grep -A 2 -B 2 "@sentry"Repository: knu-matzip/Matzip-Client
Length of output: 240
sendDefaultPii 설정에 대한 개인정보 보호 및 준수 사항 검토 필요
sendDefaultPii: true 설정이 세 곳에 모두 적용되어 있습니다:
apps/web/sentry.edge.config.ts(line 21)apps/web/sentry.server.config.ts(line 20)apps/web/instrumentation-client.ts(line 30)
이 설정은 사용자의 IP 주소, 사용자명, 이메일, 쿠키 등 개인식별정보(PII)를 Sentry로 전송합니다. 다음 사항들을 확인해주세요:
- 개인정보처리방침에서 외부 모니터링 서비스로의 PII 전송을 명시하고 있는가?
- GDPR, 개인정보보호법 등 관련 법규 준수 여부
- 사용자 동의 절차가 필요한지 확인
민감한 정보 노출을 방지하기 위해 각 설정 파일에서 beforeSend 콜백을 통한 데이터 필터링 또는 sendDefaultPii: false로 변경하여 불필요한 PII 전송을 중단하는 것을 권장합니다.
🤖 Prompt for AI Agents
In apps/web/sentry.edge.config.ts around lines 19 to 21, the config currently
sets sendDefaultPii: true which will send user-identifying data to Sentry;
update this to protect PII by either setting sendDefaultPii: false or
implementing a beforeSend callback that strips/filters IPs, usernames, emails,
cookies and other sensitive fields before events are sent, and mirror the same
change in the other two files (apps/web/sentry.server.config.ts and
apps/web/instrumentation-client.ts); ensure any change is accompanied by a note
to confirm privacy policy disclosure and consent flow with legal/product.
| enabled: process.env.NODE_ENV === 'production', | ||
|
|
||
| // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
| tracesSampleRate: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로덕션 환경에서 tracesSampleRate를 낮추세요.
tracesSampleRate: 1은 모든 트랜잭션을 추적합니다(100% 샘플링). 프로덕션 환경에서는 성능 오버헤드와 Sentry 비용이 크게 증가할 수 있습니다. 일반적으로 프로덕션에서는 0.1(10%) 이하로 설정하는 것이 권장됩니다.
🔎 권장 수정사항
- tracesSampleRate: 1,
+ // Adjust based on your traffic - 0.1 = 10% of transactions
+ tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tracesSampleRate: 1, | |
| // Adjust based on your traffic - 0.1 = 10% of transactions | |
| tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1, |
🤖 Prompt for AI Agents
In apps/web/sentry.server.config.ts around line 13, tracesSampleRate is set to 1
(100% sampling) which is too high for production; change it to a lower default
for production (e.g., 0.1 or lower) and implement environment-aware
configuration so development can keep high sampling while production reads a
SENTRY_TRACES_SAMPLE_RATE env var (with a safe fallback like 0.1 or 0.05) to
avoid excessive performance overhead and costs.
|
|
||
| // Enable sending user PII (Personally Identifiable Information) | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii | ||
| sendDefaultPii: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Examine the target file
cat -n apps/web/sentry.server.config.tsRepository: knu-matzip/Matzip-Client
Length of output: 971
🏁 Script executed:
# Search for any beforeSend or other privacy-related configuration
rg -i "beforesend|filterpii|denyurls|allowurls|privacy" apps/web/ --type ts --type js -A 2 -B 2Repository: knu-matzip/Matzip-Client
Length of output: 50
🏁 Script executed:
# Look for privacy policy or GDPR-related documentation
fd -i "privacy\|gdpr\|ccpa\|compliance" apps/web/ -o 2>/dev/nullRepository: knu-matzip/Matzip-Client
Length of output: 50
🏁 Script executed:
# Check Sentry's documentation context - search for any comments or documentation in the codebase
rg -i "sentry" apps/web/sentry.server.config.ts -A 5 -B 5Repository: knu-matzip/Matzip-Client
Length of output: 824
Sentry 설정에서 PII 전송에 대한 개인정보 보호 검토가 필요합니다.
sendDefaultPii: true는 사용자의 개인 식별 정보(IP 주소, 이메일, 사용자명 등)를 Sentry로 전송하도록 설정되어 있습니다. 현재 코드에는 beforeSend 콜백이나 기타 PII 필터링 메커니즘이 없으므로, GDPR, CCPA 등 개인정보 보호 규정 준수 여부를 법무팀 또는 개인정보 보호 담당자와 반드시 검토해야 합니다.
권장사항:
- 개인정보 보호 정책과의 정합성 확인
beforeSend콜백을 통한 PII 데이터 필터링 구현- 필요시
sendDefaultPii: false로 설정
🤖 Prompt for AI Agents
In apps/web/sentry.server.config.ts around line 20, sendDefaultPii: true
currently forwards user PII (IP, email, username) to Sentry; consult
legal/privacy and either set sendDefaultPii: false or implement a beforeSend
callback that inspects and removes/sanitizes PII fields (IP, user.email,
user.username, request headers, cookies, etc.) before sending events, add a
short comment documenting the privacy decision and which fields are scrubbed,
and ensure the change is approved by the privacy team.
#️⃣연관된 이슈
📝작업 내용
런타임 에러를 실시간으로 추적하기 위해 에러 모니터링 도구인 Sentry를 도입했습니다.
1. Sentry SDK 설치 및 초기 설정
@sentry/nextjs패키지를 설치하고,npx @sentry/wizard를 통해 Next.js 프로젝트에 맞는 초기 설정 파일(sentry.server.config.ts, sentry.edge.config.ts등)을 생성했습니다.2. 에러 캡처 범위 설정 (Error Boundary & Axios)
런타임 에러 (
error.tsx, global-error.tsx):React 렌더링 도중 발생하는 에러를 포착하여 Sentry로 전송하도록
useEffect내에Sentry.captureException을 추가했습니다.API 에러 (
axiosInstance.ts):API 요청 실패 시 자동으로 에러를 수집하기 위해 Response Interceptor에 Sentry 연동 로직을 추가했습니다.
(현재 401에러만 제외했지만, 이후 400 에러 코드 전체를 제외할지 데이터를 보고 결정 예정입니다)
3. 환경 분리 (Development vs Production)
로컬 개발 환경에서의 불필요한 에러 전송을 방지하기 위해,
enabled: process.env.NODE_ENV === 'production'설정을 추가하여 배포 환경에서만 Sentry가 활성화되도록 설정했습니다.스크린샷 (선택)
💬리뷰 요구사항(선택)
Summary by CodeRabbit
릴리스 노트
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.