Skip to content

Commit

Permalink
Merge branch 'feature/add-ga-2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dongx0915 committed Feb 14, 2024
2 parents 66bcfba + f800629 commit 1d95693
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 3 deletions.
18 changes: 18 additions & 0 deletions app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,6 +34,8 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Analytics.logClickedItemEvent(EVENT_VIEW_HOME)
initRemoteConfig()
checkVisitorMode()
checkIntentValue()
Expand Down Expand Up @@ -63,6 +68,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun changeFragment(menuItemId: Int) {
logClickEvent(menuItemId)
supportFragmentManager.commit {
replace(
R.id.fl_main, when (menuItemId) {
Expand All @@ -76,6 +82,18 @@ class MainActivity : BindingActivity<ActivityMainBinding>(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -509,6 +511,7 @@ class DrawActivity : BindingActivity<ActivityDrawBinding>(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(
Expand Down Expand Up @@ -537,6 +540,7 @@ class DrawActivity : BindingActivity<ActivityDrawBinding>(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,6 +70,7 @@ class EndRunActivity: BindingActivity<ActivityEndRunBinding>(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)
Expand Down Expand Up @@ -152,6 +156,7 @@ class EndRunActivity: BindingActivity<ActivityEndRunBinding>(R.layout.activity_e

private fun saveRecord() {
binding.btnEndRunSave.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_STORE_RUNNING_TRACKING)
viewModel.postRecord(
RequestPostRunningHistory(
courseId = viewModel.courseId.value!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -23,7 +25,9 @@ class KakaoLogin(context: Context, viewModel: LoginViewModel) : SocialLogin {
RequestPostLogin(
token.accessToken, LoginActivity.KAKAO_SIGN
)
)
) {
Analytics.logClickedItemEvent(EVENT_CLICK_KAKAO_LOGIN)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -34,6 +40,8 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(com.runnect.runnect.

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Analytics.logClickedItemEvent(EVENT_VIEW_SOCIAL_LOGIN)
googleLogin = GoogleLogin(
activity = this@LoginActivity,
viewModel = viewModel
Expand All @@ -57,6 +65,7 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(com.runnect.runnect.
socialLogin.signIn()
}
btnVisitorMode.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_VISITOR)
PreferenceManager.setString(
context = applicationContext,
key = TOKEN_KEY_ACCESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -171,6 +174,7 @@ class SearchActivity : BindingActivity<ActivitySearchBinding>(R.layout.activity_
})

binding.cvStartCurrentLocation.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_CURRENT_LOCATE)
this.let {
PermissionUtil.requestLocationPermission(
context = it,
Expand All @@ -182,6 +186,7 @@ class SearchActivity : BindingActivity<ActivitySearchBinding>(R.layout.activity_
}

binding.cvStartCustomLocation.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_MAP_LOCATE)
startCustomLocation()
}
}
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 1d95693

Please sign in to comment.