Skip to content

Commit

Permalink
[FEAT] Home / FirstMissionClick Logging (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim committed Nov 7, 2023
1 parent 5ff91a8 commit a418571
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.lgtm.domain.logging

import com.swm.logging.android.logging_scheme.ClickScheme

class FirstMissionClickScheme(
missionId : Int,
spendingTime : Long
) : ClickScheme() {

init {
setLoggingScheme(
eventLogName = "firstMissionClick",
screenName = "HomeFragment",
logVersion = "1",
logData = mutableMapOf(
"missionId" to missionId,
"spendingTime" to spendingTime
)
)
}

class Builder {
private var missionId : Int = 0
private var spendingTime : Long = 0

fun setMissionId(missionId : Int): Builder {
this.missionId = missionId
return this
}

fun setSpendingTime(spendingTime : Long): Builder {
this.spendingTime = spendingTime
return this
}

fun build(): FirstMissionClickScheme {
return FirstMissionClickScheme(
missionId,
spendingTime
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HomeMissionClickScheme(

init {
setLoggingScheme(
logName = "homeMissionClick",
eventLogName = "homeMissionClick",
screenName = "HomeFragment",
logVersion = "1",
logData = mutableMapOf(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ import com.lgtm.android.common_ui.util.setOnThrottleClickListener
import com.lgtm.android.main.R
import com.lgtm.android.main.databinding.FragmentHomeBinding
import com.lgtm.domain.constants.Role
import com.lgtm.domain.logging.FirstMissionClickScheme
import com.lgtm.domain.logging.HomeMissionClickScheme
import com.lgtm.domain.server_drive_ui.SduiContent
import com.lgtm.domain.server_drive_ui.SectionItemVO
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.AndroidEntryPoint
import kotlin.properties.Delegates

@AndroidEntryPoint
class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private val homeViewModel by viewModels<HomeViewModel>()
private lateinit var commonAdapter: SduiAdapter
private var isFirstMissionClick = false
private val entryTime = System.currentTimeMillis()
private var firstMissionClickTime by Delegates.notNull<Long>()

override fun initializeViewModel() {
viewModel = homeViewModel
Expand Down Expand Up @@ -76,12 +81,27 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
}

private fun onClickMissionItem(sduiContent: SduiContent) {
val scheme = getHomeExposureLoggingScheme(sduiContent)
homeViewModel.shotHomeExposureLogging(scheme)
if (!isFirstMissionClick) logFirstMissionClick(sduiContent)
logMissionClick(sduiContent)
moveToMissionDetail((sduiContent as SectionItemVO).missionId)
}

private fun getHomeExposureLoggingScheme(sduiContent: SduiContent): SWMLoggingScheme {
private fun logFirstMissionClick(sduiContent: SduiContent) {
firstMissionClickTime = System.currentTimeMillis()
isFirstMissionClick = true
val firstMissionClickScheme = FirstMissionClickScheme.Builder()
.setMissionId((sduiContent as SectionItemVO).missionId)
.setSpendingTime(firstMissionClickTime - entryTime)
.build()
homeViewModel.shotFirstMissionClickLogging(firstMissionClickScheme)
}

private fun logMissionClick(sduiContent: SduiContent) {
val scheme = getHomeMissionClickLoggingScheme(sduiContent)
homeViewModel.shotHomeMissionClickLogging(scheme)
}

private fun getHomeMissionClickLoggingScheme(sduiContent: SduiContent): SWMLoggingScheme {
return HomeMissionClickScheme.Builder()
.setMissionContent(sduiContent)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ class HomeViewModel @Inject constructor(
}
}

fun shotHomeExposureLogging(swmLoggingScheme: SWMLoggingScheme) {
fun shotHomeMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
}

fun getUserRole() = role

fun shotFirstMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object SWMLogging {
}

override fun onNext(value: SWMLoggingScheme) {
println("Rx: 아이템 받음: ${value.logName}")
println("Rx: 아이템 받음: ${value.eventLogName}")
runBlocking {
val result = async { shotLogging(value) }
println("Rx: 로깅 결과: ${result.await()}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.swm.logging.android.logging_scheme
import com.swm.logging.android.SWMLogging

abstract class SWMLoggingScheme {
open lateinit var logName: String
open lateinit var eventLogName: String
open lateinit var screenName: String
open lateinit var logVersion: String
private val osVersionAndName: String = SWMLogging.getOsNameAndVersion()
Expand All @@ -14,12 +14,12 @@ abstract class SWMLoggingScheme {
private val appVersion = SWMLogging.getAppVersion()
private val region = SWMLogging.getRegion()
fun setLoggingScheme(
logName: String,
eventLogName: String,
screenName: String,
logVersion: String,
logData: MutableMap<String, Any>?,
) {
this.logName = logName
this.eventLogName = eventLogName
this.screenName = screenName
this.logVersion = logVersion
this.logData = logData
Expand Down

0 comments on commit a418571

Please sign in to comment.