diff --git a/common-ui/src/main/java/com/lgtm/android/common_ui/adapter/SduiAdapter.kt b/common-ui/src/main/java/com/lgtm/android/common_ui/adapter/SduiAdapter.kt index 838dc241..887ebb62 100644 --- a/common-ui/src/main/java/com/lgtm/android/common_ui/adapter/SduiAdapter.kt +++ b/common-ui/src/main/java/com/lgtm/android/common_ui/adapter/SduiAdapter.kt @@ -14,7 +14,7 @@ import com.lgtm.domain.server_drive_ui.SduiViewType class SduiAdapter( private val onMissionClickListener: (SduiContent) -> Unit, - private val onRecommendationClickListener: () -> Unit + private val onRecommendationClickListener: (SduiContent) -> Unit ) : ListAdapter( ItemDiffCallback(onContentsTheSame = { old, new -> old == new }, onItemsTheSame = { old, new -> old.content == new.content }) diff --git a/common-ui/src/main/java/com/lgtm/android/common_ui/model/mapper/UiMapper.kt b/common-ui/src/main/java/com/lgtm/android/common_ui/model/mapper/UiMapper.kt index 58b5b5a3..d22dda7d 100644 --- a/common-ui/src/main/java/com/lgtm/android/common_ui/model/mapper/UiMapper.kt +++ b/common-ui/src/main/java/com/lgtm/android/common_ui/model/mapper/UiMapper.kt @@ -264,6 +264,19 @@ fun SuggestionVO.toUiModel(): SuggestionUI { ) } +fun SuggestionUI.toVOModel(): SuggestionVO { + return SuggestionVO( + viewType = viewType, + title = title, + description = description, + suggestionId = suggestionId, + date = "$date $time", + likeNum = likeNum, + isLiked = isLiked, + isMyPost = isMyPost + ) +} + fun NotificationVO.toUiModel(): NotificationUI { return NotificationUI( title = title, diff --git a/common-ui/src/main/java/com/lgtm/android/common_ui/viewholder/SduiSubItemViewHolder.kt b/common-ui/src/main/java/com/lgtm/android/common_ui/viewholder/SduiSubItemViewHolder.kt index 6c4fa0bd..320b0863 100644 --- a/common-ui/src/main/java/com/lgtm/android/common_ui/viewholder/SduiSubItemViewHolder.kt +++ b/common-ui/src/main/java/com/lgtm/android/common_ui/viewholder/SduiSubItemViewHolder.kt @@ -9,18 +9,18 @@ import com.lgtm.domain.server_drive_ui.SectionSubItemVO class SduiSubItemViewHolder( private val binding: ItemSduiSubItemBinding ) : SduiBaseHolder(binding) { - private lateinit var navigateToRecommendationDashboard: () -> Unit + private lateinit var navigateToRecommendationDashboard: (SduiContent) -> Unit override fun bind(theme: SduiTheme, viewContent: SduiContent) { binding.data = viewContent as SectionSubItemVO binding.theme = theme binding.btnMissionRecommend.setOnThrottleClickListener { // todo 추후 appUrl을 활용한 화면 전환 처리 - navigateToRecommendationDashboard() + navigateToRecommendationDashboard(viewContent) } } - fun setNavigateToRecommendationDashboard(navigateToRecommendationDashboard: () -> Unit) { + fun setNavigateToRecommendationDashboard(navigateToRecommendationDashboard: (SduiContent) -> Unit) { this.navigateToRecommendationDashboard = navigateToRecommendationDashboard } } \ No newline at end of file diff --git a/feature/main/src/main/java/com/lgtm/android/main/home/HomeFragment.kt b/feature/main/src/main/java/com/lgtm/android/main/home/HomeFragment.kt index 60a60b3f..ea3a4ace 100644 --- a/feature/main/src/main/java/com/lgtm/android/main/home/HomeFragment.kt +++ b/feature/main/src/main/java/com/lgtm/android/main/home/HomeFragment.kt @@ -11,8 +11,10 @@ import com.lgtm.android.main.databinding.FragmentHomeBinding import com.lgtm.domain.constants.Role import com.lgtm.domain.logging.FirstMissionClickScheme import com.lgtm.domain.logging.HomeMissionClickScheme +import com.lgtm.domain.logging.SwmCommonLoggingScheme import com.lgtm.domain.server_drive_ui.SduiContent import com.lgtm.domain.server_drive_ui.SectionItemVO +import com.lgtm.domain.server_drive_ui.SectionSubItemVO import com.swm.logging.android.logging_scheme.SWMLoggingScheme import dagger.hilt.android.AndroidEntryPoint import kotlin.properties.Delegates @@ -84,8 +86,9 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { moveToMissionDetail((sduiContent as SectionItemVO).missionId) } - private fun onClickRecommendation() { + private fun onClickRecommendation(sduiContent: SduiContent) { moveToRecommendationDashboard() + logMissionSuggestionClick(sduiContent) } private fun logFirstMissionClick(sduiContent: SduiContent) { @@ -144,4 +147,18 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { } } + private fun logMissionSuggestionClick(sduiContent: SduiContent) { + val role = homeViewModel.getUserRole() + val missionSuggestionClickScheme = SwmCommonLoggingScheme.Builder() + .setEventLogName("suggestionClick") + .setScreenName(this.javaClass) + .setLogData(mapOf( + "memberType" to role.role, + "suggestionTitle" to homeViewModel.getMissionSuggestionTitle(), + "suggestionDescription" to (sduiContent as SectionSubItemVO).text + )) + .build() + homeViewModel.shotMissionSuggestionClickLogging(missionSuggestionClickScheme) + } + } \ No newline at end of file diff --git a/feature/main/src/main/java/com/lgtm/android/main/home/HomeViewModel.kt b/feature/main/src/main/java/com/lgtm/android/main/home/HomeViewModel.kt index ff15775f..7df07f26 100644 --- a/feature/main/src/main/java/com/lgtm/android/main/home/HomeViewModel.kt +++ b/feature/main/src/main/java/com/lgtm/android/main/home/HomeViewModel.kt @@ -9,11 +9,14 @@ import com.google.firebase.crashlytics.ktx.crashlytics import com.google.firebase.ktx.Firebase import com.lgtm.android.common_ui.base.BaseViewModel import com.lgtm.domain.constants.Role +import com.lgtm.domain.constants.UNKNOWN import com.lgtm.domain.entity.response.SduiItemVO import com.lgtm.domain.repository.AuthRepository +import com.lgtm.domain.repository.LoggingRepository import com.lgtm.domain.repository.NotificationRepository +import com.lgtm.domain.server_drive_ui.SectionSubItemVO +import com.lgtm.domain.server_drive_ui.SectionTitleVO import com.lgtm.domain.usecase.MissionUseCase -import com.swm.logging.android.SWMLogging import com.swm.logging.android.logging_scheme.SWMLoggingScheme import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch @@ -23,7 +26,8 @@ import javax.inject.Inject class HomeViewModel @Inject constructor( private val useCase: MissionUseCase, private val notificationRepository: NotificationRepository, - authRepository: AuthRepository, + private val loggingRepository: LoggingRepository, + authRepository: AuthRepository ) : BaseViewModel() { private val role = authRepository.getMemberType() @@ -61,12 +65,36 @@ class HomeViewModel @Inject constructor( } fun shotHomeMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) { - SWMLogging.logEvent(swmLoggingScheme) + loggingRepository.shotSwmLogging(swmLoggingScheme) } fun getUserRole() = role fun shotFirstMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) { - SWMLogging.logEvent(swmLoggingScheme) + loggingRepository.shotSwmLogging(swmLoggingScheme) + } + + fun shotMissionSuggestionClickLogging(swmLoggingScheme: SWMLoggingScheme) { + loggingRepository.shotSwmLogging(swmLoggingScheme) + } + + fun getMissionSuggestionTitle(): String { + val idx = getMissionSuggestionTitleIdx() + return idx?.let { + (_sduiList.value?.get(it)?.content as? SectionTitleVO)?.title ?: UNKNOWN + } ?: UNKNOWN + } + + private fun getMissionSuggestionTitleIdx(): Int? { + var titleIdx: Int? = null + _sduiList.value?.let { + for(i in it.indices) { + if (it[i].content is SectionSubItemVO) { + titleIdx = i-1 + break + } + } + } + return titleIdx } } \ No newline at end of file diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardActivity.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardActivity.kt index 240fafbe..e6a6222e 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardActivity.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardActivity.kt @@ -10,6 +10,8 @@ import com.lgtm.android.common_ui.base.BaseComposeActivity import com.lgtm.android.common_ui.theme.LGTMTheme import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.SuggestionDashboardScreen import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardUiEffect +import com.lgtm.domain.logging.SwmCommonLoggingScheme +import com.lgtm.domain.mission_suggestion.SuggestionContent import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @@ -61,9 +63,22 @@ class SuggestionDashboardActivity : BaseComposeActivity() { effect.suggestionId ) } + + is SuggestionDashboardUiEffect.ShotSuggestionClickLogging -> { + val scheme = getHomeSuggestionItemClickLoggingScheme(effect.suggestionContent) + suggestionDashboardViewModel.shotSwmLogging(scheme) + } } } } } } + + private fun getHomeSuggestionItemClickLoggingScheme(suggestionContent: SuggestionContent): SwmCommonLoggingScheme { + return SwmCommonLoggingScheme.Builder() + .setEventLogName("suggestionItemClick") + .setScreenName(this.javaClass) + .setLogData(mapOf("suggestionItem" to suggestionContent)) + .build() + } } \ No newline at end of file diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardViewModel.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardViewModel.kt index dbf1aa49..8db81f2e 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardViewModel.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/SuggestionDashboardViewModel.kt @@ -8,6 +8,7 @@ import com.google.firebase.ktx.Firebase import com.lgtm.android.common_ui.base.BaseViewModel import com.lgtm.android.common_ui.model.SuggestionUI import com.lgtm.android.common_ui.model.mapper.toUiModel +import com.lgtm.android.common_ui.model.mapper.toVOModel import com.lgtm.android.common_ui.util.UiState import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardInputs import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardOutputs @@ -17,8 +18,10 @@ import com.lgtm.domain.mission_suggestion.SuggestionContent import com.lgtm.domain.mission_suggestion.SuggestionVO import com.lgtm.domain.mission_suggestion.SuggestionViewType import com.lgtm.domain.repository.AuthRepository +import com.lgtm.domain.repository.LoggingRepository import com.lgtm.domain.repository.SuggestionRepository import com.lgtm.domain.usecase.SuggestionUseCase +import com.swm.logging.android.logging_scheme.SWMLoggingScheme import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -31,6 +34,7 @@ import javax.inject.Inject class SuggestionDashboardViewModel @Inject constructor( private val suggestionUseCase: SuggestionUseCase, private val suggestionRepository: SuggestionRepository, + private val loggingRepository: LoggingRepository, authRepository: AuthRepository ): BaseViewModel(), SuggestionDashboardInputs, SuggestionDashboardOutputs { @@ -115,9 +119,11 @@ class SuggestionDashboardViewModel @Inject constructor( } } - override fun moveToSuggestionDetail(suggestionId: Int) { + override fun moveToSuggestionDetail(suggestionId: Int, suggestionUI: SuggestionUI) { + val suggestionContent = suggestionUI.toVOModel() viewModelScope.launch(lgtmErrorHandler) { _suggestionDashboardUiEffect.emit(SuggestionDashboardUiEffect.SuggestionDetail(suggestionId)) + _suggestionDashboardUiEffect.emit(SuggestionDashboardUiEffect.ShotSuggestionClickLogging(suggestionContent)) } } @@ -127,4 +133,7 @@ class SuggestionDashboardViewModel @Inject constructor( } } + fun shotSwmLogging(swmLoggingScheme: SWMLoggingScheme) { + loggingRepository.shotSwmLogging(swmLoggingScheme) + } } \ No newline at end of file diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/SuggestionDashboardScreen.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/SuggestionDashboardScreen.kt index eaa694d9..53a8f4d8 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/SuggestionDashboardScreen.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/SuggestionDashboardScreen.kt @@ -155,7 +155,7 @@ fun SuggestionHeader( fun SuggestionList( modifier: Modifier = Modifier, suggestionList: List, - onSuggestionClick: (Int) -> Unit, + onSuggestionClick: (Int, SuggestionUI) -> Unit, onSuggestionLike: (Int, Int) -> Unit, onSuggestionCancelLike: (Int, Int) -> Unit ) { @@ -181,7 +181,7 @@ fun SuggestionList( fun getSuggestionViewByType( index: Int, suggestionContent: SuggestionContent, - onSuggestionClick: (Int) -> Unit, + onSuggestionClick: (Int, SuggestionUI) -> Unit, onSuggestionLike: (Int, Int) -> Unit, onSuggestionCancelLike: (Int, Int) -> Unit ) { diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardInputs.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardInputs.kt index 971049c3..2fdd749e 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardInputs.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardInputs.kt @@ -1,9 +1,11 @@ package com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract +import com.lgtm.android.common_ui.model.SuggestionUI + interface SuggestionDashboardInputs { fun likeSuggestion(index: Int, suggestionId: Int) fun cancelLikeSuggestion(index: Int, suggestionId: Int) fun moveToCreateSuggestion() - fun moveToSuggestionDetail(suggestionId: Int) + fun moveToSuggestionDetail(suggestionId: Int, suggestionUI: SuggestionUI) fun goBack() } \ No newline at end of file diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardUiEffect.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardUiEffect.kt index bf2c76ee..03923b8b 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardUiEffect.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/contract/SuggestionDashboardUiEffect.kt @@ -1,7 +1,10 @@ package com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract +import com.lgtm.domain.mission_suggestion.SuggestionContent + sealed class SuggestionDashboardUiEffect { object GoBack: SuggestionDashboardUiEffect() object CreateSuggestion: SuggestionDashboardUiEffect() data class SuggestionDetail(val suggestionId: Int): SuggestionDashboardUiEffect() + data class ShotSuggestionClickLogging(val suggestionContent: SuggestionContent): SuggestionDashboardUiEffect() } \ No newline at end of file diff --git a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/item/SuggestionContent.kt b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/item/SuggestionContent.kt index 97deee55..a90032fd 100644 --- a/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/item/SuggestionContent.kt +++ b/feature/mission_suggestion/src/main/java/com/lgtm/android/mission_suggestion/ui/dashboard/presentation/item/SuggestionContent.kt @@ -25,7 +25,7 @@ import com.lgtm.android.common_ui.util.throttleClickable fun SuggestionContent( index: Int, suggestionUI: SuggestionUI, - onSuggestionClick: (Int) -> Unit, + onSuggestionClick: (Int, SuggestionUI) -> Unit, onSuggestionLike: (Int, Int) -> Unit, onSuggestionCancelLike: (Int, Int) -> Unit ) { @@ -47,7 +47,7 @@ fun SuggestionContent( ) .throttleClickable( enabled = true, - onClick = { onSuggestionClick(suggestionUI.suggestionId) } + onClick = { onSuggestionClick(suggestionUI.suggestionId, suggestionUI) } ) ) { Text(