Skip to content

[CHORE] 알림 관련 로그 추가#514

Open
rngrhn4114 wants to merge 4 commits intodevelopfrom
chore/notification-log
Open

[CHORE] 알림 관련 로그 추가#514
rngrhn4114 wants to merge 4 commits intodevelopfrom
chore/notification-log

Conversation

@rngrhn4114
Copy link
Member

@rngrhn4114 rngrhn4114 commented Feb 4, 2026

✅ 체크리스트

  • 코드에 any가 사용되지 않았습니다
  • 스토리북에 추가했습니다 (해당 시)
  • 이슈와 커밋이 명확히 연결되어 있습니다

🔗 관련 이슈

📌 작업 목적

  • 알림 관련 로그 추가

🔨 주요 작업 내용

  • page_view
  • notification_click
  • notification_read
  • alarm_icon_click

🧪 테스트 방법

  • page_view: 알림 목록 화면 진입 시 로그
  • notification_click: 알림 목록 아이템 클릭 시 로그
  • notification_read: 아직 읽지 않은 알림 아이템 클릭 시 로그
  • alarm_icon_click: 홈 화면에서 알림 아이콘 클릭 시 로그

✔️ 설치 라이브러리

📷 실행 영상 또는 스크린샷

💬 논의할 점

🙋🏻 참고 자료

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 알림 항목에 알림 타입(notificationType) 정보 추가
  • Chores

    • 알림 종(벨) 아이콘 클릭 시 클릭 이벤트 기록(미읽음 여부 포함)
    • 알림 페이지 조회를 페이지당 1회 기록
    • 알림 항목 클릭 시 알림 타입 정보를 포함한 클릭 이벤트 기록
    • 알림을 읽음 처리할 때 읽음 이벤트 기록

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
surf-admin Ready Ready Preview, Comment Feb 18, 2026 11:19pm
surf-web Ready Ready Preview, Comment Feb 18, 2026 11:19pm

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

이 PR은 알림 관련 분석 추적을 추가하고 알림 데이터/컴포넌트 인터페이스를 확장합니다. 홈 페이지의 알람 아이콘 클릭에서 ALARM_ICON_CLICK 이벤트를 전송하도록 했고, 알림 페이지에 PAGE_VIEW, NOTIFICATION_CLICK, NOTIFICATION_READ 이벤트를 추가했습니다. 또한 notification DTO 매퍼에 notificationType 필드를 추가하고 이를 NotificationItem/NotificationList Props 및 클릭 핸들러 시그니처로 전파했습니다. 분석용 유틸리티 trackNotificationEvent와 이벤트 상수 NOTIFICATION_EVENTS가 새로 도입되었습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 PR의 주요 변경사항인 알림 관련 로그 추가를 명확하게 설명하고 있습니다.
Linked Issues check ✅ Passed PR이 #513의 모든 TODO 항목(page_view, notification_click, notification_read, alarm_icon_click)을 구현하고 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #513의 알림 로깅 구현에 직접적으로 연관되어 있으며 범위를 벗어난 변경사항이 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/notification-log

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Fix all issues with AI agents
In `@apps/web/src/app-pages/notification/ui/NotificationPage.tsx`:
- Around line 87-88: The tracking currently sends notification_id as
`noti_${id}` in the trackNotificationEvent call
(NOTIFICATION_EVENTS.NOTIFICATION_READ), which diverges from the server's
numeric id; change the tracked payload to send the numeric id (notification_id:
id) to match API/server logs, and update any other occurrences (e.g., other
events, admin app, shared packages) to the same numeric-id convention; if you
opt for a different canonical format instead, document and apply that format
consistently across trackNotificationEvent usage and related analytics helpers.
- Around line 85-89: The current code calls readNotification(id) then
immediately calls
trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_READ...), but
readNotification is an async React Query mutation; change to call
readNotification via its mutate (or mutateAsync) and move the
trackNotificationEvent into the mutation's success callback so the
NOTIFICATION_READ event is only logged after the mutation succeeds; locate the
readNotification usage in NotificationPage.tsx and use
readNotification.mutate(id, { onSuccess: () => { trackNotificationEvent(...) }
}) or await readNotification.mutateAsync(id) and then call
trackNotificationEvent.
🧹 Nitpick comments (3)
apps/web/src/entities/notification/ui/NotificationItem.tsx (1)

8-18: notificationType 타입을 도메인 타입으로 고정 권장.

  • 문제: string이라 유효하지 않은 값이 들어와도 컴파일 단계에서 잡히지 않습니다.
  • 원인: notificationType가 느슨한 타입으로 정의됨.
  • 대안: 도메인 타입(예: Notification['type'] 또는 별도 NotificationType 유니온)을 공유해 타입 안정성을 확보.
  • 장점: 추적 이벤트/렌더링에서 잘못된 타입 유입 방지.
  • 단점: 타입 정의(또는 import) 추가가 필요.
♻️ 예시 변경안
+import type { Notification } from '../api/types';
 ...
 export interface NotificationItemProps {
   ...
-  notificationType: string;
+  notificationType: Notification['type'];
 }
apps/web/src/app-pages/notification/ui/NotificationPage.tsx (2)

55-59: PAGE_VIEW 트래킹 로직의 의존성 배열 점검 필요

현재 useEffect의 의존성 배열에 pageName이 포함되어 있지만, trackRef 가드로 인해 최초 1회만 실행됩니다. 이로 인해 두 가지 잠재적 문제가 있습니다:

  1. 초기값 문제: usePageName()이 초기에 빈 값이나 다른 값을 반환하고 이후 변경되는 경우, 첫 번째 값으로만 이벤트가 발생합니다.
  2. 린트 경고 가능성: trackRef를 의존성에서 사용하지만, 실제로는 deps 변경과 무관하게 동작하여 ESLint exhaustive-deps 규칙과 충돌할 수 있습니다.

의도가 "마운트 시 1회 트래킹"이라면, 의존성 배열을 빈 배열로 변경하고 pageName이 안정적인 값인지 확인하거나, pageName이 유효할 때만 트래킹하도록 조건을 추가하는 것이 더 명확합니다.

♻️ 개선 제안: 명시적인 마운트 트래킹
  useEffect(() => {
    if (trackRef.current) return;
+   if (!pageName) return; // pageName이 유효할 때만 트래킹
    trackRef.current = true;
    trackNotificationEvent(NOTIFICATION_EVENTS.PAGE_VIEW, { page_name: pageName });
-  }, [pageName]);
+  }, [pageName]); // pageName 변경 시 재실행 가능하도록 유지하거나, [] 로 변경

또는 마운트 1회만 필요하다면:

  useEffect(() => {
-   if (trackRef.current) return;
-   trackRef.current = true;
    trackNotificationEvent(NOTIFICATION_EVENTS.PAGE_VIEW, { page_name: pageName });
+   // eslint-disable-next-line react-hooks/exhaustive-deps
-  }, [pageName]);
+  }, []); // 마운트 시 1회만 실행

74-97: handleNotificationClick 함수 구조 개선 제안

현재 함수가 여러 책임(트래킹, 읽음 처리, 네비게이션)을 가지고 있어 점점 복잡해지고 있습니다. 가독성과 테스트 용이성을 위해 각 동작을 분리하는 것을 고려해 보세요.

현재 구조가 동작에는 문제없지만, 향후 추가 로직이 생길 경우 유지보수가 어려워질 수 있습니다.

♻️ 선택적 개선: 책임 분리
// 트래킹 로직 분리 (features 레이어로 이동 가능)
const trackNotificationInteraction = (
  id: number,
  notificationType: string,
  isRead: boolean,
) => {
  trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_CLICK, {
    notification_type: notificationType,
  });
  
  if (!isRead) {
    trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_READ, {
      notification_id: `noti_${id}`,
    });
  }
};

const handleNotificationClick = (
  id: number,
  deepLink: string,
  isRead: boolean,
  notificationType: string,
) => {
  trackNotificationInteraction(id, notificationType, isRead);
  
  if (!isRead) {
    readNotification(id);
  }
  
  if (deepLink) {
    const separator = deepLink.includes('?') ? '&' : '?';
    router.push(`${deepLink}${separator}from=notification`);
  }
};

Comment on lines +87 to +88
trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_READ, {
notification_id: `noti_${id}`,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n "notification_id" apps/web/src/

Repository: Tave-Makers/SURF-FE

Length of output: 302


🏁 Script executed:

rg -n "trackNotificationEvent|NOTIFICATION_EVENTS" apps/web/src/ -A 3

Repository: Tave-Makers/SURF-FE

Length of output: 4105


🏁 Script executed:

fd -e ts -e tsx . packages/ apps/web/src | xargs rg -l "notification.*id|notif.*id" -i | head -20

Repository: Tave-Makers/SURF-FE

Length of output: 367


🏁 Script executed:

cat -n apps/web/src/entities/notification/api/readNotification.ts

Repository: Tave-Makers/SURF-FE

Length of output: 303


🏁 Script executed:

cat -n apps/web/src/entities/notification/ui/NotificationList.tsx | head -100

Repository: Tave-Makers/SURF-FE

Length of output: 817


🏁 Script executed:

# 다른 이벤트 추적에서 ID 포맷 패턴 확인
rg -n "_\$\{|prefix|format" apps/web/src/features/notification-tracking/ apps/web/src/app-pages/

Repository: Tave-Makers/SURF-FE

Length of output: 45


🏁 Script executed:

# notification 엔터티의 타입 정의 확인
fd -e ts -e tsx . apps/web/src/entities/notification | xargs cat

Repository: Tave-Makers/SURF-FE

Length of output: 11258


추적 이벤트의 ID 형식을 서버/분석 시스템과 일치시키세요

서버는 id: number 형식으로 반환하지만, 추적 시에만 noti_${id} 접두사를 붙여 전송하고 있습니다. API 호출 시에는 숫자 ID를 그대로 사용하므로, 이 포맷 차이로 인해 추후 분석 데이터와 서버 로그의 조인이 어려워질 수 있습니다.

분석팀과 협의하여:

  1. 접두사를 제거하고 숫자만 전송할지
  2. 아니면 모든 이벤트에 일관된 ID 포맷 규칙을 문서화할지

결정하고 적용하세요. 특히 다른 앱(예: admin)이나 패키지에서도 같은 규칙을 따르도록 표준화가 필요합니다.

🤖 Prompt for AI Agents
In `@apps/web/src/app-pages/notification/ui/NotificationPage.tsx` around lines 87
- 88, The tracking currently sends notification_id as `noti_${id}` in the
trackNotificationEvent call (NOTIFICATION_EVENTS.NOTIFICATION_READ), which
diverges from the server's numeric id; change the tracked payload to send the
numeric id (notification_id: id) to match API/server logs, and update any other
occurrences (e.g., other events, admin app, shared packages) to the same
numeric-id convention; if you opt for a different canonical format instead,
document and apply that format consistently across trackNotificationEvent usage
and related analytics helpers.

Comment on lines +88 to +90
trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_READ, {
notification_id: `noti_${id}`,
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

id에서 noti를 빼고 보내도 될 것 같은데 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

넵!!

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.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/web/src/app-pages/notification/ui/NotificationPage.tsx`:
- Around line 86-92: The onSuccess callback for readNotification now correctly
defers tracking until the mutation succeeds and the event payload uses the
server ID format; ensure the call to readNotification includes onSuccess that
calls trackNotificationEvent(NOTIFICATION_EVENTS.NOTIFICATION_READ, {
notification_id: `${id}` }) (no "noti_" prefix) so events fire only on
successful mutation—verify the readNotification invocation and the referenced
symbols (readNotification, onSuccess, trackNotificationEvent,
NOTIFICATION_EVENTS.NOTIFICATION_READ, id) match this behavior across
NotificationPage.tsx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] 알림 관련 로그 추가

2 participants