-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Sentry 에러 모니터링 도입 #296
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2e66ad3
feat: web Sentry 에러 모니터링 도입
iOdiO89 75fa347
feat: app Sentry 에러 모니터링 도입
iOdiO89 522f5da
feat: web/app sentry 에러 로깅 규약 추가
iOdiO89 87f9e53
test: 에러 검증용 테스트 페이지 생성
iOdiO89 e1e7f9e
fix: SENTRY_AUTH_TOKEN turbo passThroughEnv 추가 (소스맵 업로드)
iOdiO89 a91eb19
feat: Session Replay 마스킹 완화 (이메일만 마스킹, 나머지 노출)
iOdiO89 c25ab1d
feat: API 에러 리포트 제목을 'API {status} {method} {path}' 형식으로 개선
iOdiO89 735fa79
Revert "test: 에러 검증용 테스트 페이지 생성"
iOdiO89 4486a94
fix: 소셜 로그인 5xx 응답 JSON 파싱 실패 시 Sentry 수집 누락 수정
iOdiO89 ca122f0
fix: 로그아웃 시 Sentry 유저 컨텍스트 해제
iOdiO89 7972711
fix: Session Replay 타이핑 입력창만 마스킹 (maskAllInputs)
iOdiO89 db26985
Merge branch 'dev' into chore/298-sentry
iOdiO89 7ac6161
fix: 소셜 로그인 2xx 응답 본문 파싱 실패도 Sentry 수집
iOdiO89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,32 @@ | ||
| import { getMessaging, setBackgroundMessageHandler } from '@react-native-firebase/messaging'; | ||
| import * as Sentry from '@sentry/react-native'; | ||
| import 'expo-router/entry'; | ||
|
|
||
| import { captureError } from '@/utils/captureError'; | ||
| import { setAppBadgeCount } from '@/utils/pushNotification'; | ||
|
|
||
| /** foreground 메인 + background headless 둘 다 여기서 초기화 (쉐어 익스텐션 제외) */ | ||
| const stage = process.env.EXPO_PUBLIC_STAGE; | ||
|
|
||
| Sentry.init({ | ||
| dsn: process.env.EXPO_PUBLIC_SENTRY_DSN, | ||
| environment: stage, | ||
| enabled: stage === 'production' || stage === 'staging', | ||
| /** Performance(Tracing)는 초기엔 off */ | ||
| tracesSampleRate: 0, | ||
| /** PII 기본 마스킹 (Session Replay 는 web 만, 앱은 에러/크래시만) */ | ||
| sendDefaultPii: false, | ||
| }); | ||
|
|
||
| /** 백그라운드 FCM 메시지 핸들러 */ | ||
| setBackgroundMessageHandler(getMessaging(), async remoteMessage => { | ||
| console.warn('[FCM] Background message:', remoteMessage.messageId ?? 'unknown'); | ||
| const unreadCount = remoteMessage.data?.unreadCount; | ||
| if (unreadCount !== undefined) { | ||
| await setAppBadgeCount(Number(unreadCount)); | ||
| try { | ||
| console.warn('[FCM] Background message:', remoteMessage.messageId ?? 'unknown'); | ||
| const unreadCount = remoteMessage.data?.unreadCount; | ||
| if (unreadCount !== undefined) { | ||
| await setAppBadgeCount(Number(unreadCount)); | ||
| } | ||
| } catch (error) { | ||
| captureError(error, { tags: { source: 'fcm-background' } }); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import * as Sentry from '@sentry/react-native'; | ||
|
|
||
| type CaptureErrorContextT = { | ||
| /** 검색/그룹핑용 태그 (예: { source: 'webview' }) */ | ||
| tags?: Record<string, string>; | ||
| /** 디버깅용 부가 정보 (요청 URL, status 등) */ | ||
| extra?: Record<string, unknown>; | ||
| }; | ||
|
|
||
| /** 잡은(caught) 에러를 Sentry에 수동 리포트 — 태그/컨텍스트를 일관되게 부착 */ | ||
| export const captureError = (error: unknown, context?: CaptureErrorContextT) => { | ||
| Sentry.captureException(error, { | ||
| tags: context?.tags, | ||
| extra: context?.extra, | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import * as Sentry from '@sentry/nextjs'; | ||
|
|
||
| /** production/staging 에서만 수집 (dev/local 비활성) */ | ||
| const stage = process.env.NEXT_PUBLIC_STAGE; | ||
| const enabled = stage === 'production' || stage === 'staging'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
| environment: stage, | ||
| enabled, | ||
| ...(process.env.NEXT_PUBLIC_WEB_VERSION ? { release: process.env.NEXT_PUBLIC_WEB_VERSION } : {}), | ||
| /** Performance(Tracing)는 초기엔 off */ | ||
| tracesSampleRate: 0, | ||
| /** Session Replay — 에러 발생 세션만 녹화 */ | ||
| replaysSessionSampleRate: 0, | ||
| replaysOnErrorSampleRate: 1.0, | ||
| integrations: [ | ||
| Sentry.replayIntegration({ | ||
| /** 렌더된 콘텐츠·이미지는 노출(디버깅용), 유저가 타이핑하는 입력창만 마스킹 */ | ||
| maskAllText: false, | ||
| blockAllMedia: false, | ||
| maskAllInputs: true, | ||
| mask: ['[data-sentry-mask]'], | ||
| }), | ||
| ], | ||
| /** PII 기본 마스킹 */ | ||
| sendDefaultPii: false, | ||
| /** 브라우저 확장·네트워크 취소 등 우리 코드와 무관한 노이즈 제외 */ | ||
| ignoreErrors: [ | ||
| 'Network Error', | ||
| 'Failed to fetch', | ||
| 'Load failed', | ||
| 'AbortError', | ||
| 'The operation was aborted', | ||
| 'ResizeObserver loop limit exceeded', | ||
| 'ResizeObserver loop completed with undelivered notifications', | ||
| 'Non-Error promise rejection captured', | ||
| ], | ||
| }); | ||
|
|
||
| export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import * as Sentry from '@sentry/nextjs'; | ||
|
|
||
| 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'); | ||
| } | ||
|
|
||
| export const onRequestError = Sentry.captureRequestError; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import * as Sentry from '@sentry/nextjs'; | ||
|
|
||
| /** 배포 환경(production/staging/dev). Sentry 는 production/staging 에서만 수집 (dev·로컬 비활성) */ | ||
| const stage = process.env.NEXT_PUBLIC_STAGE; | ||
| const enabled = stage === 'production' || stage === 'staging'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
| environment: stage, | ||
| enabled, | ||
| ...(process.env.NEXT_PUBLIC_WEB_VERSION ? { release: process.env.NEXT_PUBLIC_WEB_VERSION } : {}), | ||
| tracesSampleRate: 0, | ||
| sendDefaultPii: false, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import * as Sentry from '@sentry/nextjs'; | ||
|
|
||
| /** 배포 환경(production/staging/dev). Sentry 는 production/staging 에서만 수집 (dev·로컬 비활성) */ | ||
| const stage = process.env.NEXT_PUBLIC_STAGE; | ||
| const enabled = stage === 'production' || stage === 'staging'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
| environment: stage, | ||
| enabled, | ||
| ...(process.env.NEXT_PUBLIC_WEB_VERSION ? { release: process.env.NEXT_PUBLIC_WEB_VERSION } : {}), | ||
| tracesSampleRate: 0, | ||
| sendDefaultPii: false, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.