From 911964be270015ed5db4bdd687311c96b65c40c3 Mon Sep 17 00:00:00 2001 From: dongchyeon Date: Sat, 3 Aug 2024 00:21:42 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat=20:=20=ED=99=88=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A2=85=EB=A5=98=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/teamwiney/winey/WineyApp.kt | 2 +- .../java/com/teamwiney/core/common/AmplitudeEvent.kt | 11 +++++++++++ .../core/common/{di => }/AmplitudeProvider.kt | 7 +++---- .../teamwiney/core/common/navigation/Destinations.kt | 1 - .../src/main/java/com/teamwiney/home/HomeScreen.kt | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 core/common/src/main/java/com/teamwiney/core/common/AmplitudeEvent.kt rename core/common/src/main/java/com/teamwiney/core/common/{di => }/AmplitudeProvider.kt (82%) diff --git a/app/src/main/java/com/teamwiney/winey/WineyApp.kt b/app/src/main/java/com/teamwiney/winey/WineyApp.kt index e86c1342..9504854b 100644 --- a/app/src/main/java/com/teamwiney/winey/WineyApp.kt +++ b/app/src/main/java/com/teamwiney/winey/WineyApp.kt @@ -2,7 +2,7 @@ package com.teamwiney.winey import android.app.Application import com.kakao.sdk.common.KakaoSdk -import com.teamwiney.core.common.di.AmplitudeProvider +import com.teamwiney.core.common.AmplitudeProvider import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp diff --git a/core/common/src/main/java/com/teamwiney/core/common/AmplitudeEvent.kt b/core/common/src/main/java/com/teamwiney/core/common/AmplitudeEvent.kt new file mode 100644 index 00000000..e21f8749 --- /dev/null +++ b/core/common/src/main/java/com/teamwiney/core/common/AmplitudeEvent.kt @@ -0,0 +1,11 @@ +package com.teamwiney.core.common + +enum class AmplitudeEvent { + HOME_ENTER, + WINE_DETAIL_CLICK, + ANALYZE_BUTTON_CLICK, + TIP_POST_CLICK; + + val eventName: String + get() = name +} \ No newline at end of file diff --git a/core/common/src/main/java/com/teamwiney/core/common/di/AmplitudeProvider.kt b/core/common/src/main/java/com/teamwiney/core/common/AmplitudeProvider.kt similarity index 82% rename from core/common/src/main/java/com/teamwiney/core/common/di/AmplitudeProvider.kt rename to core/common/src/main/java/com/teamwiney/core/common/AmplitudeProvider.kt index 7ffebe01..4da47c7a 100644 --- a/core/common/src/main/java/com/teamwiney/core/common/di/AmplitudeProvider.kt +++ b/core/common/src/main/java/com/teamwiney/core/common/AmplitudeProvider.kt @@ -1,11 +1,10 @@ -package com.teamwiney.core.common.di +package com.teamwiney.core.common import android.content.Context import com.amplitude.android.Amplitude import com.amplitude.android.Configuration import com.amplitude.android.DefaultTrackingOptions import com.amplitude.android.utilities.AndroidLoggerProvider -import com.teamwiney.core.common.BuildConfig object AmplitudeProvider { private var amplitude: Amplitude? = null @@ -25,7 +24,7 @@ object AmplitudeProvider { return amplitude ?: throw IllegalStateException("Amplitude is not initialized") } - fun trackEvent(eventName: String) { - getAmplitude().track(eventName) + fun trackEvent(event: AmplitudeEvent) { + getAmplitude().track(event.eventName) } } \ No newline at end of file diff --git a/core/common/src/main/java/com/teamwiney/core/common/navigation/Destinations.kt b/core/common/src/main/java/com/teamwiney/core/common/navigation/Destinations.kt index acc0019b..cc446130 100644 --- a/core/common/src/main/java/com/teamwiney/core/common/navigation/Destinations.kt +++ b/core/common/src/main/java/com/teamwiney/core/common/navigation/Destinations.kt @@ -17,7 +17,6 @@ object AuthDestinations { const val PHONE = "signUpPhone" const val AUTHENTICATION = "signUpAuthentication" const val FAVORITE_TASTE = "signUpFavoriteTaste" - const val TASTE_RESULT = "signUpTasteResult" const val COMPLETE = "signUpComplete" } } diff --git a/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt b/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt index 65e7ef90..112b47ed 100644 --- a/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt +++ b/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt @@ -51,7 +51,7 @@ import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import com.teamwiney.analysis.component.TipCard import com.teamwiney.core.common.WineyAppState -import com.teamwiney.core.common.di.AmplitudeProvider +import com.teamwiney.core.common.AmplitudeProvider import com.teamwiney.core.common.navigation.HomeDestinations import com.teamwiney.core.design.R import com.teamwiney.data.network.model.response.RecommendWine From ccc951cb9a48a04a0961fa2f84af80fa0d3a2902 Mon Sep 17 00:00:00 2001 From: dongchyeon Date: Sat, 3 Aug 2024 00:40:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat=20:=20=ED=99=88=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A7=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/src/main/java/com/teamwiney/home/HomeScreen.kt | 9 ++++++++- .../src/main/java/com/teamwiney/home/HomeViewModel.kt | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt b/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt index 112b47ed..33ff032b 100644 --- a/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt +++ b/feature/home/src/main/java/com/teamwiney/home/HomeScreen.kt @@ -50,6 +50,7 @@ import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemContentType import androidx.paging.compose.itemKey import com.teamwiney.analysis.component.TipCard +import com.teamwiney.core.common.AmplitudeEvent import com.teamwiney.core.common.WineyAppState import com.teamwiney.core.common.AmplitudeProvider import com.teamwiney.core.common.navigation.HomeDestinations @@ -74,6 +75,10 @@ fun HomeScreen( val wineTips = uiState.wineTips.collectAsLazyPagingItems() val wineTipsRefreshState = wineTips.loadState.refresh + LaunchedEffect(true) { + AmplitudeProvider.trackEvent(AmplitudeEvent.HOME_ENTER) + } + LaunchedEffect(wineTipsRefreshState) { if (wineTipsRefreshState is LoadState.Error) { val errorMessage = wineTipsRefreshState.error.message ?: "네트워크 오류가 발생했습니다." @@ -111,7 +116,7 @@ fun HomeScreen( HomeLogo( onClick = { viewModel.processEvent(HomeContract.Event.ShowAnalysis) - AmplitudeProvider.trackEvent("analysis_button_click") + AmplitudeProvider.trackEvent(AmplitudeEvent.ANALYZE_BUTTON_CLICK) }, hintPopupOpen = uiState.isFirstScroll ) @@ -194,6 +199,7 @@ fun HomeWineTips( thumbnail = it.thumbnail, onClick = { viewModel.processEvent(HomeContract.Event.ShowTipDetail(it.url)) + AmplitudeProvider.trackEvent(AmplitudeEvent.TIP_POST_CLICK) } ) } @@ -290,6 +296,7 @@ private fun HomeRecommendWine( }, onShowDetail = { processEvent(HomeContract.Event.ShowWineCardDetail(recommendWines[page].wineId)) + AmplitudeProvider.trackEvent(AmplitudeEvent.WINE_DETAIL_CLICK) }, color = recommendWines[page].type, name = recommendWines[page].name, diff --git a/feature/home/src/main/java/com/teamwiney/home/HomeViewModel.kt b/feature/home/src/main/java/com/teamwiney/home/HomeViewModel.kt index 94a89937..217fa214 100644 --- a/feature/home/src/main/java/com/teamwiney/home/HomeViewModel.kt +++ b/feature/home/src/main/java/com/teamwiney/home/HomeViewModel.kt @@ -69,7 +69,7 @@ class HomeViewModel @Inject constructor( } } - fun getRecommendWines() = viewModelScope.launch { + private fun getRecommendWines() = viewModelScope.launch { wineRepository.getRecommendWines().onStart { updateState(currentState.copy(isLoading = true)) }.collectLatest { @@ -130,7 +130,7 @@ class HomeViewModel @Inject constructor( } } - fun getWineTips() = viewModelScope.launch { + private fun getWineTips() = viewModelScope.launch { updateState( currentState.copy( wineTips = Pager(