From 8c202cee2583dd90996e17f501c99dc3fcc8882a Mon Sep 17 00:00:00 2001 From: kxxhyorim Date: Tue, 14 Nov 2023 02:41:51 +0900 Subject: [PATCH] [FEAT] SplashLogging (#156) --- .../domain/logging/CommonLoggingScheme.kt | 67 +++++++++++++++++++ .../android/auth/ui/splash/SplashActivity.kt | 10 +++ .../android/auth/ui/splash/SplashViewModel.kt | 6 ++ 3 files changed, 83 insertions(+) create mode 100644 domain/src/main/java/com/lgtm/domain/logging/CommonLoggingScheme.kt diff --git a/domain/src/main/java/com/lgtm/domain/logging/CommonLoggingScheme.kt b/domain/src/main/java/com/lgtm/domain/logging/CommonLoggingScheme.kt new file mode 100644 index 00000000..3c2b4160 --- /dev/null +++ b/domain/src/main/java/com/lgtm/domain/logging/CommonLoggingScheme.kt @@ -0,0 +1,67 @@ +package com.lgtm.domain.logging + +import com.swm.logging.android.logging_scheme.ClickScheme +import java.lang.reflect.Type + +class CommonLoggingScheme( + eventLogName: String, + screenName: String, + logVersion: String, + logData: Map, +) : ClickScheme() { + + 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 = mutableMapOf() + + 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): Builder { + this.map = map.toMutableMap() + return this + } + + fun setLogVersion(logVersion: Int): Builder { + this.logVersion = logVersion.toString() + return this + } + + fun build(): CommonLoggingScheme { + check(::eventLogName.isInitialized) { "eventLogName is not initialized" } + check(::screenName.isInitialized) { "screenName is not initialized" } + + return CommonLoggingScheme( + eventLogName, + screenName, + logVersion, + map + ) + } + } +} \ No newline at end of file diff --git a/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashActivity.kt b/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashActivity.kt index bdd06d23..5e1c3c5d 100644 --- a/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashActivity.kt +++ b/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashActivity.kt @@ -13,6 +13,7 @@ import com.lgtm.android.auth.databinding.ActivitySplashBinding import com.lgtm.android.auth.ui.SignInActivity import com.lgtm.android.auth.ui.SystemMaintenanceActivity import com.lgtm.android.common_ui.base.BaseActivity +import com.lgtm.domain.logging.CommonLoggingScheme import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -28,6 +29,15 @@ class SplashActivity : BaseActivity(R.layout.activity_spl observeCurrentVersion() checkAutoLoginState() startNextActivityAfterDelay() + shotSplashExposureLogging() + } + + private fun shotSplashExposureLogging() { + val scheme = CommonLoggingScheme.Builder() + .setEventLogName("splashExposure") + .setScreenName(this.javaClass) + .build() + splashViewModel.shotSplashExposureLogging(scheme) } override fun onResume() { diff --git a/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashViewModel.kt b/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashViewModel.kt index ba34611a..2b62f3ca 100644 --- a/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashViewModel.kt +++ b/feature/auth/src/main/java/com/lgtm/android/auth/ui/splash/SplashViewModel.kt @@ -14,6 +14,8 @@ 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.swm.logging.android.logging_scheme.SWMLoggingScheme import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -97,6 +99,10 @@ class SplashViewModel @Inject constructor( return authRepository.isAutoLoginAvailable() } + fun shotSplashExposureLogging(swmLoggingScheme: SWMLoggingScheme) { + SWMLogging.logEvent(swmLoggingScheme) + } + companion object { private const val IS_SYSTEM_MAINTENANCE = "isSystemUnderMaintenance" }