[feature] 비즈니스 이벤트 로깅 기반 구축 - #161
Merged
Merged
Conversation
- common/analytics: EventType/TargetType, EventLog(BaseEntity), AnalyticsEvent(record), AnalyticsRecorder(발행 헬퍼), AnalyticsEventListener(비동기 AFTER_COMMIT 적재), EventLogRepository, properties JSON 컨버터 - 기존 ApplicationEvent + @async @TransactionalEventListener 패턴 재사용 - fire-and-forget: 적재 실패가 비즈니스 트랜잭션에 영향 없음
- JSON 컨버터 직렬화/역직렬화 - 리스너 적재·필드 매핑·properties 왕복 - 커밋 시 적재 / 롤백 시 미적재(AFTER_COMMIT) 통합 검증
- prod(validate) 배포 전 수동 생성용 CREATE TABLE - DAU/신규가입/코호트 리텐션/등록→승인→응모 퍼널 집계 쿼리
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
요약
백엔드에 이벤트 로그를 수집하는 기반이 없어, 비즈니스 이벤트를
event_log에 적재하는 구조를 마련한다. (MVP)What — 무엇을 바꿨나
common/analytics패키지 신설EventType/TargetType(enum),EventLog(BaseEntity 상속),AnalyticsEvent(record)AnalyticsRecorder(발행 헬퍼),AnalyticsEventListener(비동기 AFTER_COMMIT 적재)EventLogRepository,JsonMapConverter(properties JSON ↔ Map)SIGNUP/LOGIN:AuthService.login(firstLogin 분기)PLACE_REGISTER_REQUESTED:PlaceService.registerPLACE_APPROVED/PLACE_REJECTED:AdminPlaceRegisterRequestService.reviewEVENT_ENTERED:RequestReviewEventListener(자동 응모 성공 시)src/main/resources/sql/event_log.sql: prod 수동 DDL + 검증 쿼리Why — 왜 필요한가
퍼널 같은 걸 볼 때마다
created_at으로 매번 사후에 재구성해야 했다.데이터라 운영 DB와 조인도 안 된다.
How — 어떻게 구현했나
ApplicationEvent+@Async @TransactionalEventListener(AFTER_COMMIT)패턴 재사용.도메인은
AnalyticsRecorder로 이벤트만 발행하고 analytics에 의존하지 않는다.트랜잭션에 영향을 주지 않는다. AFTER_COMMIT이라 롤백된 액션은 남지 않는다.
fallbackExecution = true로, 트랜잭션 밖에서 발행되는 이벤트(자동 응모 등)도 적재한다.properties(JSON 컬럼 + 컨버터)와anonymous_id컬럼을 미리 두어, 스키마 변경 없이 속성추가나 익명 추적 연동으로 확장할 수 있게 했다. MVP에선 대부분 비워둔다.
체크리스트
./gradlew test)관련 이슈
기타 / 리뷰 포인트
ddl-auto: validate라event_log테이블을 먼저 수동 생성해야기동에 성공한다. DDL은
src/main/resources/sql/event_log.sql참고.