Skip to content

Commit

Permalink
Merge pull request #197 from hellokitty-coding-club/feat/sign-up-logging
Browse files Browse the repository at this point in the history
[FEAT] Splash, SignIn, SignUp 로깅 세팅
  • Loading branch information
KxxHyoRim authored Nov 13, 2023
2 parents 0c37406 + aa91efb commit 9345419
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 20 deletions.
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()
)
}

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)
}


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

0 comments on commit 9345419

Please sign in to comment.