[YS-531] feature: 공고 매칭 이메일 전송 시 UTM 파라미터 추가#167
Conversation
Walkthrough이메일 매칭용 포스트 링크 생성 로직에 UTM 파라미터를 추가하는 유틸리티를 도입하고, 해당 유틸리티를 사용하도록 이메일 구성 로직을 수정했습니다. 새 유틸리티에 대한 단위 테스트가 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
actor Scheduler as Scheduler/Trigger
participant UseCase as SendMatchingEmailUseCase
participant UrlGen as UrlGeneratorGateway
participant UTM as UtmLinkUtils
participant Email as EmailSender
Scheduler->>UseCase: 실행
loop 포스트 목록 구성
UseCase->>UrlGen: getExperimentPostUrl(postId)
UrlGen-->>UseCase: baseUrl
UseCase->>UTM: add(baseUrl)
UTM-->>UseCase: postUrlWithUtm
UseCase->>UseCase: 이메일 데이터 맵에 postUrl 설정
end
UseCase->>Email: send(emailData)
Email-->>UseCase: 전송 결과
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt (3)
8-9: '?&' 엣지케이스 및 깔끔한 조인 처리URL이
?또는&로 끝나는 경우?&utm_...형태가 생길 수 있습니다. 아래처럼 분기해 주세요.- val sep = if (url.contains("?")) "&" else "?" + val sep = when { + url.endsWith("?") || url.endsWith("&") -> "" + url.contains("?") -> "&" + else -> "?" + }
7-10: 부분 존재 UTM 처리 정책 확인 필요 (한쪽만 있을 때 보충할지 여부)현재는
utm_source또는utm_medium중 하나라도 있으면 그대로 반환합니다. 한쪽만 있을 때 나머지를 보충(append)해야 정확한 트래킹이 가능합니다. 의도 확인 부탁드립니다. 보충하는 쪽으로 갈 경우 예시는 아래와 같습니다.- if (url.contains("utm_source=") || url.contains("utm_medium=")) return url - val sep = if (url.contains("?")) "&" else "?" - return url + sep + utm + val hasSource = Regex("""(^|[?&])utm_source=""", RegexOption.IGNORE_CASE).containsMatchIn(url) + val hasMedium = Regex("""(^|[?&])utm_medium=""", RegexOption.IGNORE_CASE).containsMatchIn(url) + if (hasSource && hasMedium) return url + + val sep = when { + url.endsWith("?") || url.endsWith("&") -> "" + url.contains("?") -> "&" + else -> "?" + } + + // utm 문자열에서 값 추출(커스텀 utm 인자도 지원) + fun extract(utmStr: String, key: String, default: String) = + Regex("""(?:^|&)${key}=([^&]+)""").find(utmStr)?.groupValues?.get(1) ?: default + + val src = extract(utm, "utm_source", "email") + val med = extract(utm, "utm_medium", "daily") + + val addition = when { + hasSource && !hasMedium -> "utm_medium=$med" + !hasSource && hasMedium -> "utm_source=$src" + else -> "utm_source=$src&utm_medium=$med" + } + return url + sep + addition
6-6: 메서드 명확화 제안: add → appendUtm
add는 의미가 모호합니다. 사용 목적에 맞게appendUtm(혹은appendEmailUtm) 정도로 변경하면 가독성이 좋아집니다. 호출부 변경이 필요합니다.- fun add(url: String, utm: String = EMAIL_UTM): String { + fun appendUtm(url: String, utm: String = EMAIL_UTM): String {application/src/test/kotlin/com/dobby/util/UtmLinkUtilsTest.kt (1)
8-33: 엣지케이스 테스트 추가 제안커버리지 좋습니다. 아래 케이스가 추가되면 회귀 방지에 도움됩니다.
- URL이
?로 끝나는 경우:https://.../post/123?→...?utm_...- 프래그먼트(
#frag)가 있는 경우:https://.../123#section→https://.../123?utm_...#sectionutm_source만 있거나utm_medium만 있는 경우: 부족한 항목만 보충되는지
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
application/src/main/kotlin/com/dobby/usecase/member/email/SendMatchingEmailUseCase.kt(2 hunks)application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt(1 hunks)application/src/test/kotlin/com/dobby/util/UtmLinkUtilsTest.kt(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: ktlint-code-quality-check
application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt
[error] 6-6: Command './gradlew ktlintCheck' failed due to KtLint violations. UtmLinkUtils.kt:6:51 - Unexpected spacing before ':'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
application/src/main/kotlin/com/dobby/usecase/member/email/SendMatchingEmailUseCase.kt (1)
74-76: UTM 유틸 적용 LGTM기존 URL 생성 후 UTM 부착으로 분리한 점 명확하고 안전합니다. 위 유틸의 분기 개선(끝이
?,&)만 반영되면 엣지케이스도 커버됩니다.유틸 메서드명을
appendUtm으로 바꾸는 제안을 수용하신다면, 아래처럼 호출부도 함께 변경해 주세요.- val postUrlWithUtm = UtmLinkUtils.add(baseUrl) + val postUrlWithUtm = UtmLinkUtils.appendUtm(baseUrl)Also applies to: 82-82
* feat: add utm source parameters for tracking users source * feature: delegate application layer to add utm sources to meet the clean architecture * test: add unit test to combinate domain rules * feature: rollback infrastructure area layer * fix: fix space to meet the ktlintFormat logic
* feat: add utm source parameters for tracking users source * feature: delegate application layer to add utm sources to meet the clean architecture * test: add unit test to combinate domain rules * feature: rollback infrastructure area layer * fix: fix space to meet the ktlintFormat logic
💡 작업 내용
✅ 셀프 체크리스트
🙋🏻 확인해주세요
🔗 Jira 티켓
https://yappsocks.atlassian.net/browse/YS-531
Summary by CodeRabbit
신기능
테스트
🔗 Jira 티켓
https://yappsocks.atlassian.net/browse/YS-531