Skip to content

[feat] change_language 이벤트 설계 (앱 내 언어 설정이 바뀐 경우)#528

Merged
chlwhdtn03 merged 1 commit into
developfrom
feat/posthog_language
May 23, 2026
Merged

[feat] change_language 이벤트 설계 (앱 내 언어 설정이 바뀐 경우)#528
chlwhdtn03 merged 1 commit into
developfrom
feat/posthog_language

Conversation

@chlwhdtn03
Copy link
Copy Markdown
Collaborator

Summary

PostHog 마지막 요구사항인 change_langauge 이벤트 설계를 완료했습니다.

Describe your changes

Issue

  • Resolves #

To reviewers

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements analytics tracking for language changes by introducing a ChangeLanguageEvent and integrating it into the LanguageSelectorScreen. It also adds a unit test to verify the event payload. The review feedback suggests optimizing the language selection logic to prevent redundant operations when the same language is selected and recommends renaming event properties to follow Kotlin naming conventions and maintain consistency with existing analytics events.

Comment on lines +35 to +45
onLanguageSelected = { language ->
if (selectedLanguage != language) {
analyticsTracker.track(
ChangeLanguageEvent(
lang_from = selectedLanguage.code,
lang_to = language.code,
),
)
}
viewModel.selectLanguage(language)
},
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.

medium

To avoid redundant network calls and unnecessary Activity recreations (triggered by AppCompatDelegate.setApplicationLocales), the call to viewModel.selectLanguage(language) should be moved inside the if (selectedLanguage != language) block. This ensures that processing only occurs when a different language is actually selected.

Suggested change
onLanguageSelected = { language ->
if (selectedLanguage != language) {
analyticsTracker.track(
ChangeLanguageEvent(
lang_from = selectedLanguage.code,
lang_to = language.code,
),
)
}
viewModel.selectLanguage(language)
},
onLanguageSelected = { language ->
if (selectedLanguage != language) {
analyticsTracker.track(
ChangeLanguageEvent(
languageBefore = selectedLanguage.code,
languageAfter = language.code,
),
)
viewModel.selectLanguage(language)
}
},

Comment on lines +254 to +263
data class ChangeLanguageEvent(
val lang_from: String,
val lang_to: String,
) : AppAnalyticsEvent {
override val eventName = "change_language"
override val properties = buildMap {
put("lang_from", lang_from)
put("lang_to", lang_to)
}
}
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.

medium

Kotlin property names should follow the camelCase convention (e.g., languageBefore instead of lang_from). Additionally, for consistency with other transition-based events in this repository (like WidgetAnalyticsEvent.Changed), it is recommended to use language_before and language_after as the property keys in the analytics payload.

Suggested change
data class ChangeLanguageEvent(
val lang_from: String,
val lang_to: String,
) : AppAnalyticsEvent {
override val eventName = "change_language"
override val properties = buildMap {
put("lang_from", lang_from)
put("lang_to", lang_to)
}
}
data class ChangeLanguageEvent(
val languageBefore: String,
val languageAfter: String,
) : AppAnalyticsEvent {
override val eventName = "change_language"
override val properties = buildMap {
put("language_before", languageBefore)
put("language_after", languageAfter)
}
}

Comment on lines +31 to +45
fun `change language payload keeps previous and next locale codes`() {
val payload = ChangeLanguageEvent(
lang_from = "ko",
lang_to = "en",
).toPayload()

assertEquals("change_language", payload.eventName)
assertEquals(
mapOf(
"lang_from" to "ko",
"lang_to" to "en",
),
payload.properties,
)
}
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.

medium

Updating the test case to reflect the suggested naming improvements in ChangeLanguageEvent for consistency and adherence to Kotlin naming conventions.

Suggested change
fun `change language payload keeps previous and next locale codes`() {
val payload = ChangeLanguageEvent(
lang_from = "ko",
lang_to = "en",
).toPayload()
assertEquals("change_language", payload.eventName)
assertEquals(
mapOf(
"lang_from" to "ko",
"lang_to" to "en",
),
payload.properties,
)
}
@Test
fun `change language payload keeps previous and next locale codes`() {
val payload = ChangeLanguageEvent(
languageBefore = "ko",
languageAfter = "en",
).toPayload()
assertEquals("change_language", payload.eventName)
assertEquals(
mapOf(
"language_before" to "ko",
"language_after" to "en",
),
payload.properties,
)
}

@chlwhdtn03 chlwhdtn03 merged commit a4587b8 into develop May 23, 2026
2 checks passed
@chlwhdtn03 chlwhdtn03 deleted the feat/posthog_language branch May 23, 2026 14:12
@chlwhdtn03 chlwhdtn03 mentioned this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant