Skip to content

Commit

Permalink
feat: 투표 GA 기록
Browse files Browse the repository at this point in the history
  • Loading branch information
jinukeu committed Feb 18, 2024
1 parent 24eab0a commit 2700fe9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ sealed interface CommunitySideEffect : SideEffect {
data class NavigateVoteDetail(val voteId: Long) : CommunitySideEffect
data class ShowReportDialog(val onConfirmRequest: () -> Unit, val onCheckedAction: () -> Unit) : CommunitySideEffect
data object LogSearchIconClickEvent : CommunitySideEffect
data class LogCategoryClickEvent(val name: String) : CommunitySideEffect
data object LogPopularVoteClickEvent : CommunitySideEffect
data object LogAlignPopularVoteClickEvent : CommunitySideEffect
data object LogShowMyVoteClickEvent : CommunitySideEffect
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@ fun CommunityRoute(
),
)
}

CommunitySideEffect.LogAlignPopularVoteClickEvent -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
bundleOf(
FirebaseAnalytics.Param.CONTENT_TYPE to "community_screen_align_popular_vote",
),
)
}
is CommunitySideEffect.LogCategoryClickEvent -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
bundleOf(
FirebaseAnalytics.Param.CONTENT_TYPE to "community_screen_category_${sideEffect.name}",
),
)
}
CommunitySideEffect.LogPopularVoteClickEvent -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
bundleOf(
FirebaseAnalytics.Param.CONTENT_TYPE to "community_screen_popular_vote",
),
)
}
CommunitySideEffect.LogShowMyVoteClickEvent -> scope.launch {
FirebaseAnalytics.getInstance(context).logEvent(
FirebaseAnalytics.Event.SELECT_CONTENT,
bundleOf(
FirebaseAnalytics.Param.CONTENT_TYPE to "community_screen_show_my_vote",
),
)
}
}
}

Expand Down Expand Up @@ -168,10 +201,23 @@ fun CommunityRoute(
currentTime = currentTime,
voteListState = voteListState,
onClickFloatingButton = viewModel::navigateVoteAdd,
onClickCategory = viewModel::selectCategory,
onClickShowMine = viewModel::toggleShowMyVote,
onClickShowVotePopular = viewModel::toggleShowVotePopular,
onClickCategory = { category ->
viewModel.logCategoryClickEvent(category?.name ?: "")
viewModel.selectCategory(category)
},
onClickShowMine = {
viewModel.logShowMyVoteClickEvent()
viewModel.toggleShowMyVote()
},
onClickShowVotePopular = {
viewModel.logAlignPopularVoteClickEvent()
viewModel.toggleShowVotePopular()
},
onClickVote = viewModel::navigateVoteDetail,
onClickPopularVote = {
viewModel.logPopularVoteClickEvent()
viewModel.navigateVoteDetail(it)
},
onClickSearchIcon = {
viewModel.navigateVoteSearch()
viewModel.logSearchIconClickEvent()
Expand All @@ -191,6 +237,7 @@ fun CommunityScreen(
onClickSearchIcon: () -> Unit = {},
onClickFloatingButton: () -> Unit = {},
onClickVote: (Long) -> Unit = {},
onClickPopularVote: (Long) -> Unit = {},
onClickCategory: (Category?) -> Unit = {},
onClickShowVotePopular: () -> Unit = {},
onClickShowMine: () -> Unit = {},
Expand Down Expand Up @@ -241,7 +288,7 @@ fun CommunityScreen(
items = uiState.popularVoteList,
key = { it.id },
) { vote ->
MostPopularVoteCard(vote, onClick = { onClickVote(vote.id) })
MostPopularVoteCard(vote, onClick = { onClickPopularVote(vote.id) })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class CommunityViewModel @Inject constructor(
private var isLast = false
private var isFirstVisit = true
fun logSearchIconClickEvent() = postSideEffect(CommunitySideEffect.LogSearchIconClickEvent)
fun logPopularVoteClickEvent() = postSideEffect(CommunitySideEffect.LogPopularVoteClickEvent)
fun logShowMyVoteClickEvent() = postSideEffect(CommunitySideEffect.LogShowMyVoteClickEvent)
fun logAlignPopularVoteClickEvent() = postSideEffect(CommunitySideEffect.LogAlignPopularVoteClickEvent)
fun logCategoryClickEvent(name: String) = postSideEffect(CommunitySideEffect.LogCategoryClickEvent(name))

fun addVoteIfNeed(vote: String?) {
val toAddVote = vote?.let {
Expand Down

0 comments on commit 2700fe9

Please sign in to comment.