From 2700fe93e213a71130ce6bb68ccd8865fb7dd939 Mon Sep 17 00:00:00 2001 From: jinukeu Date: Sun, 18 Feb 2024 16:57:27 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=88=AC=ED=91=9C=20GA=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/community/CommunityContract.kt | 4 ++ .../community/community/CommunityScreen.kt | 55 +++++++++++++++++-- .../community/community/CommunityViewModel.kt | 4 ++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/feature/community/src/main/java/com/susu/feature/community/community/CommunityContract.kt b/feature/community/src/main/java/com/susu/feature/community/community/CommunityContract.kt index 4945b359..75312443 100644 --- a/feature/community/src/main/java/com/susu/feature/community/community/CommunityContract.kt +++ b/feature/community/src/main/java/com/susu/feature/community/community/CommunityContract.kt @@ -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 } diff --git a/feature/community/src/main/java/com/susu/feature/community/community/CommunityScreen.kt b/feature/community/src/main/java/com/susu/feature/community/community/CommunityScreen.kt index 920fba98..0b407cfd 100644 --- a/feature/community/src/main/java/com/susu/feature/community/community/CommunityScreen.kt +++ b/feature/community/src/main/java/com/susu/feature/community/community/CommunityScreen.kt @@ -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", + ), + ) + } } } @@ -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() @@ -191,6 +237,7 @@ fun CommunityScreen( onClickSearchIcon: () -> Unit = {}, onClickFloatingButton: () -> Unit = {}, onClickVote: (Long) -> Unit = {}, + onClickPopularVote: (Long) -> Unit = {}, onClickCategory: (Category?) -> Unit = {}, onClickShowVotePopular: () -> Unit = {}, onClickShowMine: () -> Unit = {}, @@ -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) }) } } } diff --git a/feature/community/src/main/java/com/susu/feature/community/community/CommunityViewModel.kt b/feature/community/src/main/java/com/susu/feature/community/community/CommunityViewModel.kt index 761596b9..2fe49d39 100644 --- a/feature/community/src/main/java/com/susu/feature/community/community/CommunityViewModel.kt +++ b/feature/community/src/main/java/com/susu/feature/community/community/CommunityViewModel.kt @@ -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 {