Skip to content

Conversation

@chock-cho
Copy link
Member

@chock-cho chock-cho commented Sep 6, 2025

💡 작업 내용

  • application layer에 UtmLinkUtils 유틸 클래스를 정의하여, 추후 추가될 utm link들을 관리하도록 만들었습니다.

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요?
  • 테스트는 잘 통과했나요?
  • 빌드에 성공했나요?
  • 본인을 assign 해주세요.
  • 해당 PR에 맞는 label을 붙여주세요.

🙋🏻‍ 확인해주세요

  • 관련된 Discussion 등이 있다면 첨부해주세요

🔗 Jira 티켓


https://yappsocks.atlassian.net/browse/YS-531

Summary by CodeRabbit

  • 신기능

    • 매칭 메일의 게시글 링크에 UTM 파라미터(utm_source=email, utm_medium=daily)를 자동 부착해 트래킹을 개선.
    • 기존 쿼리스트링이 있어도 올바른 구분자(?) 또는 (&) 를 사용해 추가하고, 이미 동일한 UTM이 있으면 중복 추가를 방지.
  • 테스트

    • UTM 부착 로직에 대한 단위 테스트 추가(쿼리 없음/쿼리 존재/이미 UTM 존재 시 시나리오 검증).

🔗 Jira 티켓


https://yappsocks.atlassian.net/browse/YS-531

@chock-cho chock-cho self-assigned this Sep 6, 2025
@chock-cho chock-cho added ✅ TEST 테스트 코드 추가 ✨ FEATURE 기능 추가 labels Sep 6, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 6, 2025

Walkthrough

이메일 매칭용 포스트 링크 생성 로직에 UTM 파라미터를 추가하는 유틸리티를 도입하고, 해당 유틸리티를 사용하도록 이메일 구성 로직을 수정했습니다. 새 유틸리티에 대한 단위 테스트가 추가되었습니다.

Changes

Cohort / File(s) Summary of Changes
이메일 매칭 링크 UTM 적용
application/src/main/kotlin/com/dobby/usecase/member/email/SendMatchingEmailUseCase.kt
포스트 URL 생성 후 UtmLinkUtils.add(...)를 통해 UTM 파라미터를 부착하여 맵의 postUrl 값으로 사용하도록 변경.
UTM 유틸리티 및 테스트 추가
application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt, application/src/test/kotlin/com/dobby/util/UtmLinkUtilsTest.kt
UtmLinkUtils 신설: 기본 UTM(utm_source=email&utm_medium=daily)을 URL에 추가하는 add 함수 제공(이미 UTM 존재 시 미추가, 구분자 자동 결정). Kotest 기반 단위 테스트 3건 추가.

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: 전송 결과
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

토끼는 링크에 태그를 톡, 콕!
이메일 길 위에 발자국 쏙쏙.
물음표냐 앰퍼샌드냐, 길잡이 완벽해!
중복은 노노, 깔끔한 표식에.
오늘의 클릭, 내일의 통계—퐁당퐁당 뛰는 데이터의 세계! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7af4eec and 1196c4c.

📒 Files selected for processing (2)
  • application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt (1 hunks)
  • application/src/test/kotlin/com/dobby/util/UtmLinkUtilsTest.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • application/src/test/kotlin/com/dobby/util/UtmLinkUtilsTest.kt
  • application/src/main/kotlin/com/dobby/util/UtmLinkUtils.kt
⏰ 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
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/YS-531

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.

@chock-cho chock-cho requested a review from Ji-soo708 September 6, 2025 13:14
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: 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#sectionhttps://.../123?utm_...#section
  • utm_source만 있거나 utm_medium만 있는 경우: 부족한 항목만 보충되는지
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56fb90a and 7af4eec.

📒 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

@chock-cho chock-cho merged commit c327a22 into dev Sep 23, 2025
4 checks passed
@chock-cho chock-cho deleted the feature/YS-531 branch September 23, 2025 13:10
chock-cho added a commit that referenced this pull request Oct 21, 2025
* 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
chock-cho added a commit that referenced this pull request Oct 21, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ FEATURE 기능 추가 ✅ TEST 테스트 코드 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants