Skip to content

Commit c0d7dc2

Browse files
committed
chore: Sentry 클라이언트 노이즈 에러 필터링 추가
클라이언트에서 조치 불가능한 네트워크 에러가 Sentry에 보고되는 것을 방지하기 위해 beforeSend 훅으로 노이즈 에러를 필터링합니다. - Axios: ERR_NETWORK, ECONNABORTED, ERR_CANCELED - fetch/Safari: Load failed, Failed to fetch - Next.js: ChunkLoadError closes #1222
1 parent 44eeab9 commit c0d7dc2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/instrumentation-client.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ Sentry.init({
99
environment,
1010
release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
1111

12+
beforeSend(event, hint) {
13+
const error = hint.originalException;
14+
15+
// Axios 네트워크/타임아웃/취소 에러
16+
if (
17+
error != null
18+
&& typeof error === 'object'
19+
&& 'code' in error
20+
&& (error.code === 'ERR_NETWORK' || error.code === 'ECONNABORTED' || error.code === 'ERR_CANCELED')
21+
) {
22+
return null;
23+
}
24+
25+
// 브라우저 네트워크 에러 (fetch, Safari)
26+
if (error instanceof TypeError && /Load failed|Failed to fetch/.test(error.message)) {
27+
return null;
28+
}
29+
30+
// 배포 후 이전 청크 캐시 요청 실패
31+
if (error instanceof Error && error.name === 'ChunkLoadError') {
32+
return null;
33+
}
34+
35+
return event;
36+
},
37+
1238
integrations: [
1339
Sentry.replayIntegration({
1440
maskAllText: false,

0 commit comments

Comments
 (0)