Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Splash, SignIn, SignUp 로깅 세팅 #197

Merged
merged 14 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/com/lgtm/android/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.lgtm.android.di

import com.lgtm.android.data.repository.AuthRepositoryImpl
import com.lgtm.android.data.repository.IntroRepositoryImpl
import com.lgtm.android.data.repository.LoggingRepositoryImpl
import com.lgtm.android.data.repository.MissionRepositoryImpl
import com.lgtm.android.data.repository.NotificationRepositoryImpl
import com.lgtm.android.data.repository.ProfileRepositoryImpl
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.IntroRepository
import com.lgtm.domain.repository.LoggingRepository
import com.lgtm.domain.repository.MissionRepository
import com.lgtm.domain.repository.NotificationRepository
import com.lgtm.domain.repository.ProfileRepository
Expand Down Expand Up @@ -44,4 +46,9 @@ interface RepositoryModule {
notificationRepositoryImpl: NotificationRepositoryImpl
): NotificationRepository

@Binds
fun bindsLoggingRepository(
loggingRepositoryImpl: LoggingRepositoryImpl
): LoggingRepository

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.lgtm.android.data.repository

import com.lgtm.domain.repository.LoggingRepository
import com.swm.logging.android.SWMLogging
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import javax.inject.Inject

class LoggingRepositoryImpl @Inject constructor() : LoggingRepository {
override fun shotSwmLogging(scheme: SWMLoggingScheme) {
SWMLogging.logEvent(scheme)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.lgtm.domain.logging

import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import java.lang.reflect.Type

class SwmCommonLoggingScheme(
eventLogName: String,
screenName: String,
logVersion: String,
logData: Map<String, Any>,
) : SWMLoggingScheme() {

init {
setLoggingScheme(
eventLogName = eventLogName,
screenName = screenName,
logVersion = logVersion,
logData = logData.toMutableMap()
)
Comment on lines +14 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 메소드는 어디에 속한 메소드인가요?

}

class Builder {
private lateinit var eventLogName: String
private lateinit var screenName: String
private var logVersion: String = "1"
private var map = mapOf<String, Any>()

fun setEventLogName(eventLogName: String): Builder {
this.eventLogName = eventLogName
return this
}

fun setScreenName(screenName: String): Builder {
this.screenName = screenName
return this
}

fun setScreenName(type: Type): Builder {
check(type is Class<*>)
this.screenName = type.simpleName
return this
}


fun setLogData(map: Map<String, Any>): Builder {
this.map = map
return this
}

fun setLogVersion(logVersion: Int): Builder {
this.logVersion = logVersion.toString()
return this
}

fun build(): SwmCommonLoggingScheme {
check(::eventLogName.isInitialized) { "eventLogName is not initialized" }
check(::screenName.isInitialized) { "screenName is not initialized" }

return SwmCommonLoggingScheme(
eventLogName,
screenName,
logVersion,
map
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.lgtm.domain.repository

import com.swm.logging.android.logging_scheme.SWMLoggingScheme

interface LoggingRepository {
fun shotSwmLogging(scheme: SWMLoggingScheme)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.lgtm.android.auth.ui.signup.SignUpActivity
import com.lgtm.android.common_ui.base.BaseActivity
import com.lgtm.android.common_ui.util.NetworkState
import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -31,6 +32,7 @@ class SignInActivity : BaseActivity<ActivitySignInBinding>(R.layout.activity_sig
initClickListener()
observeGithubLoginResponse()
observePatchDeviceTokenStatus()
shotSignInExposureLogging()
}

private fun setAnimationOnGithubButton() {
Expand Down Expand Up @@ -118,6 +120,15 @@ class SignInActivity : BaseActivity<ActivitySignInBinding>(R.layout.activity_sig
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}

private fun shotSignInExposureLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("signInExposure")
.setScreenName(this.javaClass)
.build()
signInViewModel.shotSignInExposureLogging(scheme)
}
Comment on lines +123 to +129
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 액티비티마다 이러한 로깅을 쏘게된다면 BaseActivity에 묻어서 로깅을 처리할 방법은 없을지도 생각해보면 좋을거같아요.



companion object {
const val MEMBER_DATA = "memberData"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import com.lgtm.android.common_ui.util.NetworkState
import com.lgtm.domain.entity.LgtmResponseException
import com.lgtm.domain.entity.response.GithubLoginResponse
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.LoggingRepository
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class SignInViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val loggingRepository: LoggingRepository
) : BaseViewModel() {

private val deviceToken = MutableLiveData<String?>()
Expand Down Expand Up @@ -86,4 +89,8 @@ class SignInViewModel @Inject constructor(
}
}
}

fun shotSignInExposureLogging(scheme: SWMLoggingScheme) {
loggingRepository.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import com.lgtm.domain.entity.request.SignUpSeniorRequestVO
import com.lgtm.domain.entity.response.MemberDataDTO
import com.lgtm.domain.entity.response.SignUpResponseVO
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.LoggingRepository
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class SignUpViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val loggingRepository: LoggingRepository
) : BaseViewModel() {

/** Device Token */
Expand Down Expand Up @@ -312,14 +315,14 @@ class SignUpViewModel @Inject constructor(
}

private val _accountNumber = MutableLiveData<String>()
private val accountNumber: LiveData<String> = _accountNumber
val accountNumber: LiveData<String> = _accountNumber

fun setAccountNumber(number: String) {
_accountNumber.value = number
}

private val _accountHolder = MutableLiveData<String>()
private val accountHolder: LiveData<String> = _accountHolder
val accountHolder: LiveData<String> = _accountHolder

fun setAccountHolder(holder: String) {
_accountHolder.value = holder
Expand Down Expand Up @@ -421,6 +424,20 @@ class SignUpViewModel @Inject constructor(
}
}

fun clearSignUpState() {
_signUpState.value = NetworkState.Init
}

private val _selectedBankIdx = MutableLiveData<Int>()
val selectedBankIdx: LiveData<Int> = _selectedBankIdx
fun setSelectedBankIdx(position: Int) {
_selectedBankIdx.value = position
}

fun shotSwmLogging(swmLoggingScheme: SWMLoggingScheme) {
loggingRepository.shotSwmLogging(swmLoggingScheme)
}

companion object {
private const val ONE_MONTH = 1
private const val ONE_YEAR = 12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.lgtm.android.auth.ui.signup.SignUpViewModel
import com.lgtm.android.common_ui.base.BaseFragment
import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.domain.constants.Role
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -23,6 +24,7 @@ class ChooseRoleFragment : BaseFragment<FragmentChooseRoleBinding>(R.layout.frag
setupViewModel()
observeSelectedRole()
setupNextButtonListener()
shotChooseRoleExposureLogging()
}

private fun observeSelectedRole() {
Expand Down Expand Up @@ -53,4 +55,13 @@ class ChooseRoleFragment : BaseFragment<FragmentChooseRoleBinding>(R.layout.frag
findNavController().navigate(R.id.action_chooseRoleFragment_to_companyNameFragment)
}

private fun shotChooseRoleExposureLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("chooseRoleExposure")
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 5))
.build()
signUpViewModel.shotSwmLogging(scheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.lgtm.android.auth.databinding.FragmentIntroductionBinding
import com.lgtm.android.auth.ui.signup.SignUpViewModel
import com.lgtm.android.common_ui.base.BaseFragment
import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -24,6 +25,7 @@ class IntroductionFragment :
setupEditText()
onIntroductionChanged()
setupNextButtonListener()
shotIntroductionExposureLogging()
}

private fun setupViewModel() {
Expand Down Expand Up @@ -55,4 +57,13 @@ class IntroductionFragment :
private fun navigateToSelectRoleFragment() {
findNavController().navigate(R.id.action_introductionFragment_to_chooseRoleFragment)
}

private fun shotIntroductionExposureLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("introductionExposure")
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 4))
.build()
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.lgtm.android.auth.databinding.FragmentNicknameBinding
import com.lgtm.android.auth.ui.signup.SignUpViewModel
import com.lgtm.android.common_ui.base.BaseFragment
import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import dagger.hilt.android.AndroidEntryPoint


Expand All @@ -24,6 +25,16 @@ class NicknameFragment : BaseFragment<FragmentNicknameBinding>(R.layout.fragment
setupEditText()
onNicknameChanged()
setupNextButtonListener()
shotNickNameExposureLogging()
}

private fun shotNickNameExposureLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("nicknameExposure")
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 2))
.build()
signUpViewModel.shotSwmLogging(scheme)
}

private fun setupViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.lgtm.android.common_ui.base.BaseFragment
import com.lgtm.android.common_ui.util.TechTagChipGroup
import com.lgtm.android.common_ui.util.TechTagTheme
import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -25,6 +26,7 @@ class TechTagFragment : BaseFragment<FragmentTechTagBinding>(R.layout.fragment_t
setChips()
observeTechTagList()
setupNextButtonListener()
shotTechTagExposureLogging()
}

private fun setupViewModel() {
Expand Down Expand Up @@ -53,4 +55,13 @@ class TechTagFragment : BaseFragment<FragmentTechTagBinding>(R.layout.fragment_t
private fun navigateToIntroductionFragment() {
findNavController().navigate(R.id.action_techTagFragment_to_introductionFragment)
}

private fun shotTechTagExposureLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("techTagExposure")
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 3))
.build()
signUpViewModel.shotSwmLogging(scheme)
}
}
Loading
Loading