diff --git a/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt index 7bef940ae..d2140b528 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt @@ -20,6 +20,9 @@ import com.runnect.runnect.presentation.discover.DiscoverFragment import com.runnect.runnect.presentation.mypage.MyPageFragment import com.runnect.runnect.presentation.storage.StorageMainFragment import com.runnect.runnect.presentation.storage.StorageScrapFragment +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName +import com.runnect.runnect.util.analytics.EventName.EVENT_VIEW_HOME import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber @@ -31,6 +34,8 @@ class MainActivity : BindingActivity(R.layout.activity_main override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + Analytics.logClickedItemEvent(EVENT_VIEW_HOME) initRemoteConfig() checkVisitorMode() checkIntentValue() @@ -63,6 +68,7 @@ class MainActivity : BindingActivity(R.layout.activity_main } private fun changeFragment(menuItemId: Int) { + logClickEvent(menuItemId) supportFragmentManager.commit { replace( R.id.fl_main, when (menuItemId) { @@ -76,6 +82,18 @@ class MainActivity : BindingActivity(R.layout.activity_main } } + private fun logClickEvent(menuItemId: Int) { + with(EventName) { + when (menuItemId) { + R.id.menu_main_drawing -> if(isVisitorMode) EVENT_CLICK_JOIN_IN_COURSE_DRAWING else EVENT_CLICK_NAV_COURSE_DRAWING + R.id.menu_main_storage -> if(isVisitorMode) EVENT_CLICK_JOIN_IN_STORAGE else EVENT_CLICK_NAV_STORAGE + R.id.menu_main_discover -> if(isVisitorMode) EVENT_CLICK_JOIN_IN_COURSE_DISCOVERY else EVENT_CLICK_NAV_COURSE_DISCOVERY + R.id.menu_main_my_page -> if(isVisitorMode) EVENT_CLICK_JOIN_IN_MY_PAGE else EVENT_CLICK_NAV_MY_PAGE + else -> "" + }.let(Analytics::logClickedItemEvent) + } + } + private fun addListener() { binding.btmNaviMain.setOnItemSelectedListener { changeFragment(it.itemId) diff --git a/app/src/main/java/com/runnect/runnect/presentation/coursemain/CourseMainFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/coursemain/CourseMainFragment.kt index 12b398503..47a8d3329 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/coursemain/CourseMainFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/coursemain/CourseMainFragment.kt @@ -21,6 +21,8 @@ import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentCourseMainBinding import com.runnect.runnect.presentation.search.SearchActivity +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_COURSE_DRAWING import com.runnect.runnect.util.extension.PermissionUtil import com.runnect.runnect.util.extension.showToast @@ -95,6 +97,7 @@ class CourseMainFragment : private fun initDrawCourseButtonClickListener() { binding.btnDraw.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_DRAWING) val intent = Intent(activity, SearchActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) startActivity(intent) diff --git a/app/src/main/java/com/runnect/runnect/presentation/draw/DrawActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/draw/DrawActivity.kt index c9383650a..1a17535d2 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/draw/DrawActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/draw/DrawActivity.kt @@ -45,6 +45,8 @@ import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.countdown.CountDownActivity import com.runnect.runnect.presentation.state.UiState import com.runnect.runnect.util.DepartureSetMode +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName import com.runnect.runnect.util.custom.dialog.RequireLoginDialogFragment import com.runnect.runnect.util.extension.PermissionUtil import com.runnect.runnect.util.extension.hideKeyboard @@ -509,6 +511,7 @@ class DrawActivity : BindingActivity(R.layout.activity_draw with(dialogLayout) { this.btn_run.setOnClickListener { + Analytics.logClickedItemEvent(EventName.EVENT_CLICK_RUN_AFTER_COURSE_COMPLETE) if (isCustomLocationMode) departureLatLng = customDepartureLatLng val courseData = CourseData( @@ -537,6 +540,7 @@ class DrawActivity : BindingActivity(R.layout.activity_draw } this.btn_storage.setOnClickListener { + Analytics.logClickedItemEvent(EventName.EVENT_CLICK_STORED_AFTER_COURSE_COMPLETE) val intent = Intent(this@DrawActivity, MainActivity::class.java).apply { putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDrawCourse") addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) diff --git a/app/src/main/java/com/runnect/runnect/presentation/endrun/EndRunActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/endrun/EndRunActivity.kt index 7386b02bc..d5ab7b3c7 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/endrun/EndRunActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/endrun/EndRunActivity.kt @@ -18,6 +18,9 @@ import com.runnect.runnect.data.dto.request.RequestPostRunningHistory import com.runnect.runnect.databinding.ActivityEndRunBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.state.UiState +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_BACK_RUNNING_TRACKING +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_STORE_RUNNING_TRACKING import com.runnect.runnect.util.custom.toast.RunnectToast import com.runnect.runnect.util.extension.hideKeyboard import com.runnect.runnect.util.extension.round @@ -67,6 +70,7 @@ class EndRunActivity: BindingActivity(R.layout.activity_e private fun backBtn() { binding.imgBtnBack.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_BACK_RUNNING_TRACKING) val intent = Intent(this, MainActivity::class.java).apply { putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, viewModel.dataFrom.value) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) @@ -152,6 +156,7 @@ class EndRunActivity: BindingActivity(R.layout.activity_e private fun saveRecord() { binding.btnEndRunSave.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_STORE_RUNNING_TRACKING) viewModel.postRecord( RequestPostRunningHistory( courseId = viewModel.courseId.value!!, diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/GoogleLogin.kt b/app/src/main/java/com/runnect/runnect/presentation/login/GoogleLogin.kt index 197170a6b..e08841f47 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/GoogleLogin.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/GoogleLogin.kt @@ -12,6 +12,8 @@ import com.google.android.gms.common.api.ApiException import com.google.android.gms.tasks.Task import com.runnect.runnect.BuildConfig import com.runnect.runnect.data.dto.request.RequestPostLogin +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_GOOGLE_LOGIN import timber.log.Timber import java.lang.ref.WeakReference @@ -60,7 +62,9 @@ class GoogleLogin(activity: LoginActivity, viewModel: LoginViewModel) : SocialLo token = socialToken, provider = LoginActivity.GOOGLE_SIGN ) - ) + ) { + Analytics.logClickedItemEvent(EVENT_CLICK_GOOGLE_LOGIN) + } } catch (e: ApiException) { Timber.tag("failed").w("signInResult:failed code=%s", e.statusCode) } diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/KakaoLogin.kt b/app/src/main/java/com/runnect/runnect/presentation/login/KakaoLogin.kt index e4911e881..4a68311ee 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/KakaoLogin.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/KakaoLogin.kt @@ -7,6 +7,8 @@ import com.kakao.sdk.common.model.ClientError import com.kakao.sdk.common.model.ClientErrorCause import com.kakao.sdk.user.UserApiClient.Companion.instance import com.runnect.runnect.data.dto.request.RequestPostLogin +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_KAKAO_LOGIN import timber.log.Timber import java.lang.ref.WeakReference @@ -23,7 +25,9 @@ class KakaoLogin(context: Context, viewModel: LoginViewModel) : SocialLogin { RequestPostLogin( token.accessToken, LoginActivity.KAKAO_SIGN ) - ) + ) { + Analytics.logClickedItemEvent(EVENT_CLICK_KAKAO_LOGIN) + } } } diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt index 1234ae32a..e44468fef 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt @@ -11,6 +11,12 @@ import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.databinding.ActivityLoginBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.state.UiState +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_GOOGLE_LOGIN +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_KAKAO_LOGIN +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_VISITOR +import com.runnect.runnect.util.analytics.EventName.EVENT_VIEW_SOCIAL_LOGIN import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber @@ -34,6 +40,8 @@ class LoginActivity : BindingActivity(com.runnect.runnect. override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + Analytics.logClickedItemEvent(EVENT_VIEW_SOCIAL_LOGIN) googleLogin = GoogleLogin( activity = this@LoginActivity, viewModel = viewModel @@ -57,6 +65,7 @@ class LoginActivity : BindingActivity(com.runnect.runnect. socialLogin.signIn() } btnVisitorMode.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_VISITOR) PreferenceManager.setString( context = applicationContext, key = TOKEN_KEY_ACCESS, diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/LoginViewModel.kt b/app/src/main/java/com/runnect/runnect/presentation/login/LoginViewModel.kt index 547cf0ca1..986360b1a 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/LoginViewModel.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/LoginViewModel.kt @@ -25,7 +25,7 @@ class LoginViewModel @Inject constructor(private val loginRepository: LoginRepos get() = _loginState - fun postLogin(request: RequestPostLogin) { + fun postLogin(request: RequestPostLogin, logEvent: (() -> Unit)? = null) { viewModelScope.launch { runCatching { _loginState.value = UiState.Loading @@ -37,6 +37,7 @@ class LoginViewModel @Inject constructor(private val loginRepository: LoginRepos }.onSuccess { loginResult.value = it _loginState.value = UiState.Success + logEvent?.invoke() }.onFailure { errorMessage.value = it.message _loginState.value = UiState.Failure diff --git a/app/src/main/java/com/runnect/runnect/presentation/search/SearchActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/search/SearchActivity.kt index 7b00996db..6c86e7914 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/search/SearchActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/search/SearchActivity.kt @@ -20,6 +20,9 @@ import com.runnect.runnect.databinding.ActivitySearchBinding import com.runnect.runnect.presentation.draw.DrawActivity import com.runnect.runnect.presentation.search.adapter.SearchAdapter import com.runnect.runnect.presentation.state.UiState +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_CURRENT_LOCATE +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_MAP_LOCATE import com.runnect.runnect.util.callback.listener.OnSearchItemClick import com.runnect.runnect.util.extension.PermissionUtil import com.runnect.runnect.util.extension.hideKeyboard @@ -171,6 +174,7 @@ class SearchActivity : BindingActivity(R.layout.activity_ }) binding.cvStartCurrentLocation.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_CURRENT_LOCATE) this.let { PermissionUtil.requestLocationPermission( context = it, @@ -182,6 +186,7 @@ class SearchActivity : BindingActivity(R.layout.activity_ } binding.cvStartCustomLocation.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_MAP_LOCATE) startCustomLocation() } } diff --git a/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt index 9dda34dca..a8addd825 100644 --- a/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt +++ b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt @@ -1,6 +1,39 @@ package com.runnect.runnect.util.analytics object EventName { + + // App + const val EVENT_VIEW_HOME = "view_home" // 앱 실행 + const val EVENT_VIEW_SOCIAL_LOGIN = "view_social_login" + + // Login + const val EVENT_CLICK_GOOGLE_LOGIN = "click_google_login" + const val EVENT_CLICK_KAKAO_LOGIN = "click_kakao_login" + const val EVENT_CLICK_VISITOR = "click_visitor" + + // Running Tracking + const val EVENT_CLICK_BACK_RUNNING_TRACKING = "click_back_running_tracking" + const val EVENT_CLICK_STORE_RUNNING_TRACKING = "click_store_running_tracking" + + // Draw Course + const val EVENT_CLICK_COURSE_DRAWING = "click_course_drawing" + const val EVENT_CLICK_CURRENT_LOCATE = "click_current_locate" + const val EVENT_CLICK_MAP_LOCATE = "click_map_locate" + const val EVENT_CLICK_STORED_AFTER_COURSE_COMPLETE = "click_stored_after_course_complete" + const val EVENT_CLICK_RUN_AFTER_COURSE_COMPLETE = "click_run_after_course_complete" + + // Navigation Menu + const val EVENT_CLICK_NAV_COURSE_DRAWING = "click_nav_course_drawing" + const val EVENT_CLICK_NAV_COURSE_DISCOVERY = "click_nav_course_discovery" + const val EVENT_CLICK_NAV_STORAGE = "click_nav_storage" + const val EVENT_CLICK_NAV_MY_PAGE = "click_nav_my_page" + + // Visitor Mode + const val EVENT_CLICK_JOIN_IN_COURSE_DRAWING = "click_join_in_course_drawing" + const val EVENT_CLICK_JOIN_IN_COURSE_DISCOVERY = "click_join_in_course_discovery" + const val EVENT_CLICK_JOIN_IN_STORAGE = "click_join_in_storage" + const val EVENT_CLICK_JOIN_IN_MY_PAGE = "click_join_in_my_page" + // Discover const val EVENT_CLICK_UPLOAD_BUTTON = "click_upload_button" const val EVENT_CLICK_DATE = "click_date_sort"