Skip to content

[add] 엠플리튜드 유저id 세팅 + 파이어베이스 크래시 에널리틱스 추가 #454

Open
hye0njuoo wants to merge 3 commits into
feat/#435-errormodalfrom
feat/#434-amplitude
Open

[add] 엠플리튜드 유저id 세팅 + 파이어베이스 크래시 에널리틱스 추가 #454
hye0njuoo wants to merge 3 commits into
feat/#435-errormodalfrom
feat/#434-amplitude

Conversation

@hye0njuoo

Copy link
Copy Markdown
Member

✅ Check List

  • merge할 브랜치의 위치를 확인해 주세요.(main❌/develop⭕)
  • 2인 이상의 Approve를 받은 후 머지해주세요.
  • 변경사항은 500줄 이하로 유지해주세요.
  • PR에는 핵심 내용만 적고, 자세한 내용은 트슈에 작성한 뒤 링크를 공유해주세요.
  • Approve된 PR은 Assigner가 직접 머지해주세요.
  • 수정 요청이 있다면 반영 후 다시 push해주세요.

📌 Related Issue

  • closed #이슈번호

📎 Work Description

분석/관측(Analytics & Observability) 파이프라인을 Android와 동일한 수준으로 맞췄습니다.

  1. Amplitude userId 매핑 — 서버 userId(Long)를 Amplitude user_id로 연결
  2. 에러 CTA Amplitude 이벤트 — 에러 화면의 버튼 클릭을 이벤트로 수집
  3. Firebase Crashlytics + Analytics 연동 — 크래시/오류를 Crashlytics에 기록 → Slack 알림

2·3번은 에러 처리 정책 PR(#435)의 ErrorPresenter/BaseService choke-point 위에서 동작합니다. (해당 PR 이후 머지 예정)


1. Amplitude userId 매핑

서버가 소셜로그인 / 회원가입 프로필 등록 / 내정보 확인 응답에 userId(Long)를 추가함에 따라, 이를 Amplitude user_id로 설정합니다.

세팅 지점 (코호트별)

진입 출처 위치
기존 유저 소셜 로그인 로그인 응답 userId LoginViewModel
신규 유저 가입 프로필 등록 응답 userId OnBoardingViewModel
자동 로그인 후 / 기존 유저 내정보(mypage/info) 응답 userId MypageViewModel
  • 자동 로그인(reissue) 응답엔 userId가 없으므로(백엔드 미제공), 해당 유저는 MyPage 진입 시 백필됩니다.
  • 로컬 저장 없음 — Amplitude SDK가 user_id를 자체 영속화하므로 별도 UserDefaults 캐싱 불필요. (clearUserId()는 로그아웃용으로 제공)
  • minIdLength = 1 — Amplitude 기본 규칙(user_id ≥ 5자)에 막혀 짧은 숫자 id가 400(Invalid id length)으로 거부되던 문제 해결.

데이터 흐름 변경

  • UserProfileResponseDTO/UserProfileEntity/mapper에 userId: Int64? 추가 (mypage/info)
  • LoginResponseDTO/LoginResponseEntity/mapper에 userId: Int64? 추가 (소셜 로그인)
  • RegisterProfileResponseDTO 신규 + OnBoarding 체인(Service/Repository/UseCase) Void → Int64 (가입 시 requestPlainrequest로 응답 수신)
  • TokenRefreshResponseDTO는 userId 없음 → 미적용
  • AmplitudeManager.updateUserId(Int64) / clearUserId() 추가

2. 에러 CTA Amplitude 이벤트

에러 화면의 CTA 버튼 클릭을 수집합니다. 버튼을 실제로 탭했을 때만 발화(화면 노출 시점엔 미발화).

버튼 이벤트 action
다시 시도(서버) server_error_retry
다시 시도(네트워크) network_error_retry
이전 페이지로 돌아가기 / 단어장 확인 data_not_found_go_back
뒤로가기(좌상단) 서버 server_error_go_back / 데이터없음 data_not_found_go_back
모달 확인 서버 server_error_confirm
피드백 다시 요청하기 feedback_retry

3. Firebase Crashlytics + Analytics 연동

크래시·오류 모니터링을 추가하고 Slack으로 알림이 가도록 연동했습니다.

수집 정책

종류 Debug Release
크래시(fatal) 자동 자동
비치명 API 오류(non-fatal) 안감 전달
  • 크래시: FirebaseApp.configure()로 양쪽 빌드 자동 수집.
  • 비치명 API 오류: BaseService choke-point에서 모든 실패를 기록(에러 코드 필터 없음 — Android Timber.e → ReleaseTree.recordException와 동일). RELEASE 빌드에서만 전송(한 Firebase 프로젝트 + 프로젝트 단위 Slack이라 dev 노이즈 방지).
  • 5xx 응답 본문을 디코딩해 50302(GPT)·50304(S3) 등 세부 코드로 그룹핑.

구조 (모듈 경계 유지)

  • CrashReporting 프로토콜 + CrashReporter(HilingualCore, Firebase 비의존) — Network/Presentation은 추상화만 호출
  • FirebaseCrashReporter(App 타겟) — Crashlytics 구현체를 #if !DEBUG에서 주입
  • BaseService.report(...) — non-fatal을 NSError(domain: "API.<API>", code:, userInfo: [path, error])로 기록 → 도메인/코드별 그룹핑

📷 Screenshots

기능/화면 iPhone SE iPhone 16 Pro
A 기능

💬 To Reviewers

  • 리뷰어에게 전달하고 싶은 메시지를 남겨주세요.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e6d62cae-53bf-4fb6-a7d4-4021522b1ca7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#434-amplitude

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.

@hyeyeonie hyeyeonie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

애널리틱스 추가 작업하신 거 확인했습니다 ~ !
파일 상단에 설명 기재해주신 것 같은데 코드 작업할 때 참고하겠습니다 👍🏻


import UIKit
import FirebaseCore
import FirebaseCrashlytics

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

오와 파베에 이런 프레임 워크가 있군요 !

Comment on lines +40 to +54
// MARK: - Crash Reporting

private static func report(_ error: NetworkError, path: String) {
let code: Int
switch error {
case .serverError(let serverError): code = serverError.code
case .decoding: code = -1001
case .networkFail: code = -1002
case .timeout: code = -1003
case .forbidden: code = 403
case .unauthorized: code = 401
case .notFound: code = 404
case .refreshFailed: code = -1004
case .unknown: code = -1000
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

오호 리포트 케이스 굿굿

@hye0njuoo hye0njuoo force-pushed the feat/#434-amplitude branch from 5b43ece to a7fb11c Compare July 2, 2026 12:55
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.

2 participants