Skip to content

Commit

Permalink
[REFACTOR] logging 관련 코드가 domain 모듈을 거치도록 수정 (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim committed Nov 13, 2023
1 parent 38df120 commit 25238d7
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 25 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
Expand Up @@ -6,8 +6,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.lgtm.domain.entity.LgtmResponseException
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import com.swm.logging.android.SWMLogging
import kotlinx.coroutines.CoroutineExceptionHandler

abstract class BaseViewModel : ViewModel() {
Expand All @@ -32,8 +30,4 @@ abstract class BaseViewModel : ViewModel() {
}
}
}

fun shotSwmLogging(scheme : SwmCommonLoggingScheme) {
SWMLogging.logEvent(scheme)
}
}
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,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 @@ -13,7 +13,7 @@ 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.swm.logging.android.SWMLogging
import com.lgtm.domain.repository.LoggingRepository
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
Expand All @@ -22,6 +22,7 @@ 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 @@ -90,6 +91,6 @@ class SignInViewModel @Inject constructor(
}

fun shotSignInExposureLogging(scheme: SWMLoggingScheme) {
SWMLogging.logEvent(scheme)
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 @@ -431,6 +434,10 @@ class SignUpViewModel @Inject constructor(
_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 @@ -61,7 +61,7 @@ class ChooseRoleFragment : BaseFragment<FragmentChooseRoleBinding>(R.layout.frag
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 5))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ class IntroductionFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 4))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NicknameFragment : BaseFragment<FragmentNicknameBinding>(R.layout.fragment
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 2))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

private fun setupViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class TechTagFragment : BaseFragment<FragmentTechTagBinding>(R.layout.fragment_t
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 3))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class TermsFragment : BaseFragment<FragmentTermsBinding>(R.layout.fragment_terms
.setEventLogName("termsServiceClick")
.setScreenName(this.javaClass)
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

private fun shotTermsPrivacyClickLogging() {
val scheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("termsPrivacyClick")
.setScreenName(this.javaClass)
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

private fun openUrlInBrowser(url: String) {
Expand Down Expand Up @@ -135,7 +135,7 @@ class TermsFragment : BaseFragment<FragmentTermsBinding>(R.layout.fragment_terms
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 1))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ class EducationStatusFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 6, "juniorStep" to 1))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class RealNameFragment : BaseFragment<FragmentRealNameBinding>(R.layout.fragment
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 7, "juniorStep" to 2))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class BankAccountFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 9, "seniorStep" to 4))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CareerPeriodFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 8, "seniorStep" to 3))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ class CompanyNameFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 6, "seniorStep" to 1))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ class PositionFragment :
.setScreenName(this.javaClass)
.setLogData(mapOf("signUpStep" to 7, "seniorStep" to 2))
.build()
viewModel.shotSwmLogging(scheme)
signUpViewModel.shotSwmLogging(scheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
.setEventLogName("splashExposure")
.setScreenName(this.javaClass)
.build()
viewModel?.shotSwmLogging(scheme)
splashViewModel.shotSwmLogging(scheme)
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.IntroRepository
import com.swm.logging.android.SWMLogging
import com.lgtm.domain.repository.LoggingRepository
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
Expand All @@ -24,6 +24,7 @@ import javax.inject.Inject
class SplashViewModel @Inject constructor(
private val introRepository: IntroRepository,
private val authRepository: AuthRepository,
private val loggingRepository: LoggingRepository
) : BaseViewModel() {


Expand Down Expand Up @@ -99,8 +100,8 @@ class SplashViewModel @Inject constructor(
return authRepository.isAutoLoginAvailable()
}

fun shotSplashExposureLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
fun shotSwmLogging(swmLoggingScheme: SWMLoggingScheme) {
loggingRepository.shotSwmLogging(swmLoggingScheme)
}

companion object {
Expand Down

0 comments on commit 25238d7

Please sign in to comment.