Skip to content

Commit

Permalink
[FEAT] SplashLogging (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim committed Nov 13, 2023
1 parent 0c37406 commit 8c202ce
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
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.ClickScheme
import java.lang.reflect.Type

class CommonLoggingScheme(
eventLogName: String,
screenName: String,
logVersion: String,
logData: Map<String, Any>,
) : 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<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.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
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,6 +29,15 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
Expand Down

0 comments on commit 8c202ce

Please sign in to comment.