From 528557e06daf8ea58b6b26ddb13284a32632e828 Mon Sep 17 00:00:00 2001 From: yangsooplus Date: Mon, 19 Feb 2024 19:31:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=B3=B4=EB=82=B4=EC=9A=94=20GA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../envelopeadd/EnvelopeAddContract.kt | 2 + .../envelopeadd/EnvelopeAddViewModel.kt | 8 +++ .../envelopeadd/SentEnvelopeAddScreen.kt | 34 ++++++++++- .../envelopefilter/EnvelopeFilterContract.kt | 4 ++ .../envelopefilter/EnvelopeFilterScreen.kt | 60 ++++++++++++++++++- .../envelopefilter/EnvelopeFilterViewModel.kt | 4 ++ .../com/susu/feature/sent/SentContract.kt | 4 ++ .../java/com/susu/feature/sent/SentScreen.kt | 56 +++++++++++++++-- .../com/susu/feature/sent/SentViewModel.kt | 4 ++ 9 files changed, 167 insertions(+), 9 deletions(-) diff --git a/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddContract.kt b/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddContract.kt index 598e2072..7282898f 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddContract.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddContract.kt @@ -7,6 +7,8 @@ sealed interface EnvelopeAddEffect : SideEffect { data object PopBackStack : EnvelopeAddEffect data object PopBackStackWithRefresh : EnvelopeAddEffect data class HandleException(val throwable: Throwable, val retry: () -> Unit) : EnvelopeAddEffect + data class LogClickNextButton(val step: EnvelopeAddStep) : EnvelopeAddEffect + data class LogClickBackButton(val step: EnvelopeAddStep) : EnvelopeAddEffect } /** diff --git a/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddViewModel.kt b/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddViewModel.kt index ee0d323b..84d0f136 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddViewModel.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopeadd/EnvelopeAddViewModel.kt @@ -209,4 +209,12 @@ class EnvelopeAddViewModel @Inject constructor( buttonEnabled = date != null, ) } + + fun logBackButtonClickEvent() { + postSideEffect(EnvelopeAddEffect.LogClickBackButton(currentState.currentStep)) + } + + fun logNextButtonClickEvent() { + postSideEffect(EnvelopeAddEffect.LogClickNextButton(currentState.currentStep)) + } } diff --git a/feature/sent/src/main/java/com/susu/feature/envelopeadd/SentEnvelopeAddScreen.kt b/feature/sent/src/main/java/com/susu/feature/envelopeadd/SentEnvelopeAddScreen.kt index 0739bdcf..ca5fd97c 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopeadd/SentEnvelopeAddScreen.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopeadd/SentEnvelopeAddScreen.kt @@ -12,13 +12,17 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.core.os.bundleOf import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.google.firebase.analytics.FirebaseAnalytics import com.susu.core.designsystem.component.appbar.SusuProgressAppBar import com.susu.core.designsystem.component.appbar.icon.BackIcon import com.susu.core.designsystem.component.button.FilledButtonColor @@ -40,6 +44,7 @@ import com.susu.feature.envelopeadd.content.phone.PhoneContentRoute import com.susu.feature.envelopeadd.content.present.PresentContentRoute import com.susu.feature.envelopeadd.content.relationship.RelationshipContentRoute import com.susu.feature.envelopeadd.content.visited.VisitedContentRoute +import kotlinx.coroutines.launch import java.time.LocalDateTime @Composable @@ -51,12 +56,31 @@ fun SentEnvelopeAddRoute( handleException: (Throwable, () -> Unit) -> Unit, ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() + val context = LocalContext.current + val scope = rememberCoroutineScope() viewModel.sideEffect.collectWithLifecycle { sideEffect -> when (sideEffect) { is EnvelopeAddEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry) EnvelopeAddEffect.PopBackStack -> popBackStack() EnvelopeAddEffect.PopBackStackWithRefresh -> popBackStackWithRefresh() + is EnvelopeAddEffect.LogClickBackButton -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_envelope_add_screen_back_at_${sideEffect.step}", + ), + ) + } + + is EnvelopeAddEffect.LogClickNextButton -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_envelope_add_screen_next_at_${sideEffect.step}", + ), + ) + } } } @@ -75,8 +99,14 @@ fun SentEnvelopeAddRoute( SentEnvelopeAddScreen( uiState = uiState, categoryName = categoryName, - onClickBack = viewModel::goPrevStep, - onClickNext = viewModel::goNextStep, + onClickBack = { + viewModel.logBackButtonClickEvent() + viewModel.goPrevStep() + }, + onClickNext = { + viewModel.logNextButtonClickEvent() + viewModel.goNextStep() + }, updateParentMoney = viewModel::updateMoney, updateParentName = viewModel::updateName, updateParentFriendId = viewModel::updateFriendId, diff --git a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterContract.kt b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterContract.kt index 1b396575..35f10554 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterContract.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterContract.kt @@ -24,4 +24,8 @@ sealed interface EnvelopeFilterSideEffect : SideEffect { data object PopBackStack : EnvelopeFilterSideEffect data class PopBackStackWithFilter(val filter: String) : EnvelopeFilterSideEffect data class HandleException(val throwable: Throwable, val retry: () -> Unit) : EnvelopeFilterSideEffect + + data object LogClickFriendButtonEvent : EnvelopeFilterSideEffect + data object LogClickSliderEvent : EnvelopeFilterSideEffect + data object LogClickApplyButtonEvent : EnvelopeFilterSideEffect } diff --git a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterScreen.kt b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterScreen.kt index 3671c7d5..e5392bc5 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterScreen.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterScreen.kt @@ -15,12 +15,16 @@ import androidx.compose.foundation.layout.size import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.core.os.bundleOf import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.google.firebase.analytics.FirebaseAnalytics import com.susu.core.designsystem.component.appbar.SusuDefaultAppBar import com.susu.core.designsystem.component.appbar.icon.BackIcon import com.susu.core.designsystem.component.button.FilledButtonColor @@ -40,6 +44,7 @@ import com.susu.feature.envelopefilter.component.SearchBar import com.susu.feature.sent.R import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.debounce +import kotlinx.coroutines.launch @OptIn(FlowPreview::class) @Composable @@ -50,11 +55,40 @@ fun EnvelopeFilterRoute( handleException: (Throwable, () -> Unit) -> Unit, ) { val uiState = viewModel.uiState.collectAsStateWithLifecycle().value + val context = LocalContext.current + val scope = rememberCoroutineScope() + viewModel.sideEffect.collectWithLifecycle { sideEffect -> when (sideEffect) { is EnvelopeFilterSideEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry) EnvelopeFilterSideEffect.PopBackStack -> popBackStack() is EnvelopeFilterSideEffect.PopBackStackWithFilter -> popBackStackWithFilter(sideEffect.filter) + EnvelopeFilterSideEffect.LogClickApplyButtonEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_filter_apply_button", + ), + ) + } + + EnvelopeFilterSideEffect.LogClickFriendButtonEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_filter_friend_button", + ), + ) + } + + EnvelopeFilterSideEffect.LogClickSliderEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_filter_slider", + ), + ) + } } } @@ -68,15 +102,35 @@ fun EnvelopeFilterRoute( .collect(viewModel::getFriendList) } + LaunchedEffect(key1 = uiState.fromAmount, key2 = uiState.toAmount) { + snapshotFlow { uiState.fromAmount } + .debounce(1000L) + .collect { + viewModel.logSliderClickEvent() + } + + snapshotFlow { uiState.toAmount } + .debounce(1000L) + .collect { + viewModel.logSliderClickEvent() + } + } + EnvelopeFilterScreen( uiState = uiState, onClickBackIcon = viewModel::popBackStack, - onClickApplyFilterButton = viewModel::popBackStackWithFilter, + onClickApplyFilterButton = { + viewModel.popBackStackWithFilter() + viewModel.logApplyClickEvent() + }, + onClickRefreshButton = viewModel::clearFilter, onTextChangeSearch = viewModel::updateName, - onClickFriendChip = viewModel::toggleFriend, + onClickFriendChip = { friend -> + viewModel.toggleFriend(friend) + viewModel.logFriendClickEvent() + }, onCloseFriendChip = viewModel::unselectFriend, onMoneyValueChange = viewModel::updateMoneyRange, - onClickRefreshButton = viewModel::clearFilter, ) } diff --git a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterViewModel.kt b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterViewModel.kt index a5677c4c..d3f70077 100644 --- a/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterViewModel.kt +++ b/feature/sent/src/main/java/com/susu/feature/envelopefilter/EnvelopeFilterViewModel.kt @@ -126,4 +126,8 @@ class EnvelopeFilterViewModel @Inject constructor( toAmount = null, ) } + + fun logApplyClickEvent() = postSideEffect(EnvelopeFilterSideEffect.LogClickApplyButtonEvent) + fun logFriendClickEvent() = postSideEffect(EnvelopeFilterSideEffect.LogClickFriendButtonEvent) + fun logSliderClickEvent() = postSideEffect(EnvelopeFilterSideEffect.LogClickSliderEvent) } diff --git a/feature/sent/src/main/java/com/susu/feature/sent/SentContract.kt b/feature/sent/src/main/java/com/susu/feature/sent/SentContract.kt index 96d07278..81c749fa 100644 --- a/feature/sent/src/main/java/com/susu/feature/sent/SentContract.kt +++ b/feature/sent/src/main/java/com/susu/feature/sent/SentContract.kt @@ -70,4 +70,8 @@ sealed interface SentEffect : SideEffect { data object ScrollToTop : SentEffect data class FocusToLastEnvelope(val lastIndex: Int) : SentEffect data object LogSearchIconClickEvent : SentEffect + data object LogFilterButtonClickEvent : SentEffect + data object LogAlignButtonClickEvent : SentEffect + data class LogAlignItemClickEvent(val align: EnvelopeAlign) : SentEffect + data object LogShowHistoryButtonClickEvent : SentEffect } diff --git a/feature/sent/src/main/java/com/susu/feature/sent/SentScreen.kt b/feature/sent/src/main/java/com/susu/feature/sent/SentScreen.kt index 497a1406..11863bfe 100644 --- a/feature/sent/src/main/java/com/susu/feature/sent/SentScreen.kt +++ b/feature/sent/src/main/java/com/susu/feature/sent/SentScreen.kt @@ -122,6 +122,42 @@ fun SentRoute( ), ) } + + SentEffect.LogAlignButtonClickEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_screen_align_button", + ), + ) + } + + SentEffect.LogFilterButtonClickEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_screen_filter_button", + ), + ) + } + + SentEffect.LogShowHistoryButtonClickEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_screen_show_history_button", + ), + ) + } + + is SentEffect.LogAlignItemClickEvent -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "sent_screen_align_item_${sideEffect.align}", + ), + ) + } } } @@ -153,7 +189,10 @@ fun SentRoute( envelopesListState = envelopesListState, refreshState = refreshState, padding = padding, - onClickHistoryShowAll = viewModel::navigateSentEnvelope, + onClickHistoryShowAll = { id -> + viewModel.navigateSentEnvelope(id) + viewModel.logShowHistoryButtonClickEvent() + }, onClickAddEnvelope = viewModel::navigateSentAdd, onClickSearchIcon = { viewModel.navigateSentEnvelopeSearch() @@ -166,11 +205,20 @@ fun SentRoute( viewModel.getEnvelopesHistoryList(friendId) } }, - onClickFilterButton = viewModel::navigateEnvelopeFilter, + onClickFilterButton = { + viewModel.navigateEnvelopeFilter() + viewModel.logFilterButtonClickEvent() + }, onClickFriendClose = viewModel::unselectFriend, onClickMoneyClose = viewModel::removeMoney, - onClickAlignButton = viewModel::showAlignBottomSheet, - onClickAlignBottomSheetItem = viewModel::updateAlignPosition, + onClickAlignButton = { + viewModel.showAlignBottomSheet() + viewModel.logAlignButtonClickEvent() + }, + onClickAlignBottomSheetItem = { + viewModel.updateAlignPosition(it) + viewModel.logAlignItemClickEvent(it) + }, onDismissAlignBottomSheet = viewModel::hideAlignBottomSheet, ) } diff --git a/feature/sent/src/main/java/com/susu/feature/sent/SentViewModel.kt b/feature/sent/src/main/java/com/susu/feature/sent/SentViewModel.kt index 958e2dd4..ad5adff3 100644 --- a/feature/sent/src/main/java/com/susu/feature/sent/SentViewModel.kt +++ b/feature/sent/src/main/java/com/susu/feature/sent/SentViewModel.kt @@ -29,6 +29,10 @@ class SentViewModel @Inject constructor( private var filterUri: String? = null fun logSearchIconClickEvent() = postSideEffect(SentEffect.LogSearchIconClickEvent) + fun logFilterButtonClickEvent() = postSideEffect(SentEffect.LogFilterButtonClickEvent) + fun logAlignButtonClickEvent() = postSideEffect(SentEffect.LogAlignButtonClickEvent) + fun logAlignItemClickEvent(index: Int) = postSideEffect(SentEffect.LogAlignItemClickEvent(EnvelopeAlign.entries[index])) + fun logShowHistoryButtonClickEvent() = postSideEffect(SentEffect.LogShowHistoryButtonClickEvent) fun getEnvelopesList(refresh: Boolean?, onFinish: () -> Unit = {}) = viewModelScope.launch { mutex.withLock { From fab0bcaaa89f3016b38f3b8437ae47544157c870 Mon Sep 17 00:00:00 2001 From: yangsooplus Date: Mon, 19 Feb 2024 19:55:06 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=ED=86=B5=EA=B3=84=20GA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/src/main/AndroidManifest.xml | 3 ++ .../feature/statistics/StatisticsScreen.kt | 11 ++++++ .../content/susu/SusuStatisticsContent.kt | 35 +++++++++++++++++++ .../content/susu/SusuStatisticsContract.kt | 3 ++ .../content/susu/SusuStatisticsViewModel.kt | 17 +++++++-- 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/feature/statistics/src/main/AndroidManifest.xml b/feature/statistics/src/main/AndroidManifest.xml index 8bdb7e14..31c45c66 100644 --- a/feature/statistics/src/main/AndroidManifest.xml +++ b/feature/statistics/src/main/AndroidManifest.xml @@ -1,4 +1,7 @@ + + + diff --git a/feature/statistics/src/main/java/com/susu/feature/statistics/StatisticsScreen.kt b/feature/statistics/src/main/java/com/susu/feature/statistics/StatisticsScreen.kt index 4b6d0eca..2f99174d 100644 --- a/feature/statistics/src/main/java/com/susu/feature/statistics/StatisticsScreen.kt +++ b/feature/statistics/src/main/java/com/susu/feature/statistics/StatisticsScreen.kt @@ -16,8 +16,10 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.core.os.bundleOf import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.google.firebase.analytics.FirebaseAnalytics import com.susu.core.designsystem.component.appbar.SusuDefaultAppBar import com.susu.core.designsystem.component.appbar.icon.LogoIcon import com.susu.core.designsystem.component.screen.LoadingScreen @@ -58,6 +60,15 @@ fun StatisticsRoute( viewModel.checkAdditionalInfo() } + LaunchedEffect(key1 = uiState.currentTab) { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SCREEN_VIEW, + bundleOf( + FirebaseAnalytics.Param.SCREEN_NAME to "statistics_${uiState.currentTab}", + ), + ) + } + StatisticsScreen( padding = padding, uiState = uiState, diff --git a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt index b78b1af8..a4378622 100644 --- a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt +++ b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll @@ -31,8 +32,10 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.core.os.bundleOf import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.google.firebase.analytics.FirebaseAnalytics import com.susu.core.designsystem.component.bottomsheet.SusuSelectionBottomSheet import com.susu.core.designsystem.component.screen.LoadingScreen import com.susu.core.designsystem.theme.Blue60 @@ -47,6 +50,7 @@ import com.susu.feature.statistics.component.StatisticsHorizontalItem import com.susu.feature.statistics.component.StatisticsVerticalItem import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toPersistentList +import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -57,6 +61,8 @@ fun SusuStatisticsRoute( handleException: (Throwable, () -> Unit) -> Unit, ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() + val scope = rememberCoroutineScope() + val context = LocalContext.current val refreshState = rememberPullToRefreshState( positionalThreshold = 100.dp, @@ -65,6 +71,35 @@ fun SusuStatisticsRoute( viewModel.sideEffect.collectWithLifecycle { sideEffect -> when (sideEffect) { is SusuStatisticsEffect.HandleException -> handleException(sideEffect.throwable, sideEffect.retry) + is SusuStatisticsEffect.LogAgeOption -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_age", + FirebaseAnalytics.Param.VALUE to sideEffect.age, + ), + ) + } + + is SusuStatisticsEffect.LogCategoryOption -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_category", + FirebaseAnalytics.Param.VALUE to sideEffect.category, + ), + ) + } + + is SusuStatisticsEffect.LogRelationshipOption -> scope.launch { + FirebaseAnalytics.getInstance(context).logEvent( + FirebaseAnalytics.Event.SELECT_CONTENT, + bundleOf( + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_relationship", + FirebaseAnalytics.Param.VALUE to sideEffect.relationship, + ), + ) + } } } diff --git a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContract.kt b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContract.kt index a85bb3ca..47139a97 100644 --- a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContract.kt +++ b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContract.kt @@ -10,6 +10,9 @@ import kotlinx.collections.immutable.persistentListOf sealed interface SusuStatisticsEffect : SideEffect { data class HandleException(val throwable: Throwable, val retry: () -> Unit) : SusuStatisticsEffect + data class LogAgeOption(val age: StatisticsAge) : SusuStatisticsEffect + data class LogRelationshipOption(val relationship: String) : SusuStatisticsEffect + data class LogCategoryOption(val category: String) : SusuStatisticsEffect } data class SusuStatisticsState( diff --git a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsViewModel.kt b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsViewModel.kt index 49ee90e6..81c296f5 100644 --- a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsViewModel.kt +++ b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsViewModel.kt @@ -69,9 +69,20 @@ class SusuStatisticsViewModel @Inject constructor( } } - fun selectAge(age: StatisticsAge) = intent { copy(age = age, isAgeSheetOpen = false) } - fun selectRelationship(index: Int) = intent { copy(relationship = relationshipConfig[index], isRelationshipSheetOpen = false) } - fun selectCategory(index: Int) = intent { copy(category = categoryConfig[index], isCategorySheetOpen = false) } + fun selectAge(age: StatisticsAge) { + intent { copy(age = age, isAgeSheetOpen = false) } + postSideEffect(SusuStatisticsEffect.LogAgeOption(currentState.age)) + } + fun selectRelationship(index: Int) { + intent { copy(relationship = relationshipConfig[index], isRelationshipSheetOpen = false) } + postSideEffect(SusuStatisticsEffect.LogRelationshipOption(currentState.relationship.relation)) + } + + fun selectCategory(index: Int) { + intent { copy(category = categoryConfig[index], isCategorySheetOpen = false) } + postSideEffect(SusuStatisticsEffect.LogCategoryOption(currentState.category.category)) + } + fun showAgeSheet() = intent { copy(isAgeSheetOpen = true) } fun showRelationshipSheet() = intent { copy(isRelationshipSheetOpen = true) } fun showCategorySheet() = intent { copy(isCategorySheetOpen = true) } From 630586bb00a102b3180d2f78f980671929b31379 Mon Sep 17 00:00:00 2001 From: yangsooplus Date: Mon, 19 Feb 2024 20:35:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=88=98=EC=88=98=ED=86=B5=EA=B3=84?= =?UTF-8?q?=20Param.VALUE=20=EC=A0=9C=EA=B1=B0=20=ED=9B=84=20CONTENT=5FTYP?= =?UTF-8?q?E=EC=97=90=20=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/content/susu/SusuStatisticsContent.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt index a4378622..c8c60bdf 100644 --- a/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt +++ b/feature/statistics/src/main/java/com/susu/feature/statistics/content/susu/SusuStatisticsContent.kt @@ -75,8 +75,7 @@ fun SusuStatisticsRoute( FirebaseAnalytics.getInstance(context).logEvent( FirebaseAnalytics.Event.SELECT_CONTENT, bundleOf( - FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_age", - FirebaseAnalytics.Param.VALUE to sideEffect.age, + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_age_${sideEffect.age}", ), ) } @@ -85,8 +84,7 @@ fun SusuStatisticsRoute( FirebaseAnalytics.getInstance(context).logEvent( FirebaseAnalytics.Event.SELECT_CONTENT, bundleOf( - FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_category", - FirebaseAnalytics.Param.VALUE to sideEffect.category, + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_category_${sideEffect.category}", ), ) } @@ -95,8 +93,7 @@ fun SusuStatisticsRoute( FirebaseAnalytics.getInstance(context).logEvent( FirebaseAnalytics.Event.SELECT_CONTENT, bundleOf( - FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_relationship", - FirebaseAnalytics.Param.VALUE to sideEffect.relationship, + FirebaseAnalytics.Param.CONTENT_TYPE to "statistics_relationship_${sideEffect.relationship}", ), ) }