Skip to content

Commit

Permalink
[FEAT] HomeMissionClickLogging (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim committed Nov 7, 2023
1 parent 0e488f6 commit 3c11955
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 82 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/lgtm/android/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.lgtm.android.di

import com.google.gson.GsonBuilder
import com.lgtm.android.BuildConfig.DEBUG
import com.lgtm.android.BuildConfig.IS_DEV
import com.lgtm.android.BuildConfig.LGTM_BASE_URL_DEBUG
import com.lgtm.android.BuildConfig.LGTM_BASE_URL_RELEASE
import com.lgtm.android.data.datasource.LgtmPreferenceDataSource
Expand Down Expand Up @@ -64,7 +64,7 @@ object NetworkModule {
@Singleton
fun providesLGTMRetrofit(okHttpClient: OkHttpClient): Retrofit =
Retrofit.Builder()
.baseUrl(if (DEBUG) LGTM_BASE_URL_DEBUG else LGTM_BASE_URL_RELEASE)
.baseUrl(if (IS_DEV) LGTM_BASE_URL_DEBUG else LGTM_BASE_URL_RELEASE)
.client(okHttpClient)
.addConverterFactory(
GsonConverterFactory.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import com.lgtm.android.common_ui.viewholder.SduiBaseHolder
import com.lgtm.android.common_ui.viewholder.SduiItemViewHolder
import com.lgtm.android.common_ui.viewholder.getSduiViewHolder
import com.lgtm.domain.entity.response.SduiItemVO
import com.lgtm.domain.server_drive_ui.SduiContent
import com.lgtm.domain.server_drive_ui.SduiViewType


class SduiAdapter(
private val onMissionClickListener: (Int) -> Unit
private val onMissionClickListener: (SduiContent) -> Unit
) : ListAdapter<SduiItemVO, SduiBaseHolder>(
ItemDiffCallback<SduiItemVO>(onContentsTheSame = { old, new -> old == new },
onItemsTheSame = { old, new -> old.content == new.content })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class SduiItemViewHolder(
private val binding: ItemSduiItemBinding
) : SduiBaseHolder(binding) {

private lateinit var navigateToMissionDetail : (Int) -> Unit
private lateinit var navigateToMissionDetail : (SduiContent) -> Unit
override fun bind(theme: SduiTheme, viewContent: SduiContent) {
binding.data = viewContent as SectionItemVO
binding.theme = theme
binding.clMission.setOnThrottleClickListener { navigateToMissionDetail(viewContent.missionId) }
binding.clMission.setOnThrottleClickListener { navigateToMissionDetail(viewContent) }

if (viewContent.isScraped != null) {
binding.bookmarkButton.isBookmarked = viewContent.isScraped == true
Expand All @@ -25,7 +25,7 @@ class SduiItemViewHolder(
}
}

fun setNavigateToMissionDetail(navigateToMissionDetail : (Int) -> Unit) {
fun setNavigateToMissionDetail(navigateToMissionDetail : (SduiContent) -> Unit) {
this.navigateToMissionDetail = navigateToMissionDetail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.lgtm.domain.logging

import com.lgtm.domain.server_drive_ui.SduiContent
import com.swm.logging.android.logging_scheme.SWMLoggingScheme

class HomeMissionClickScheme(
sduiContent: SduiContent,
) : SWMLoggingScheme() {

init {
setLoggingScheme(
logName = "homeMissionClick",
screenName = "HomeFragment",
logVersion = "1",
logData = mutableMapOf(
"sduiContent" to sduiContent
)
)
}

class Builder {
private lateinit var sduiContent: SduiContent

fun setMissionContent(sduiContent: SduiContent): Builder {
this.sduiContent = sduiContent
return this
}

fun build(): HomeMissionClickScheme {
return HomeMissionClickScheme(
sduiContent
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class HomeScreenClickScheme(

init {
setLoggingScheme(
evenLogName = "notificationClick",
screenName = "home",
logVersion = 1,
logName = "notificationClick",
screenName = "HomeFragment",
logVersion = "1",
logData = mutableMapOf(
"titleName" to titleName,
"age" to age
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ 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.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

@AndroidEntryPoint
Expand Down Expand Up @@ -67,10 +71,22 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
}

private fun initAdapter() {
commonAdapter = SduiAdapter(::moveToMissionDetail)
commonAdapter = SduiAdapter(::onClickMissionItem)
binding.rvSdui.adapter = commonAdapter
}

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

private fun getHomeExposureLoggingScheme(sduiContent: SduiContent): SWMLoggingScheme {
return HomeMissionClickScheme.Builder()
.setMissionContent(sduiContent)
.build()
}

private fun moveToMissionDetail(missionId: Int) {
lgtmNavigator.navigateToMissionDetail(requireContext(), missionId)
}
Expand All @@ -82,7 +98,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private fun submitDataWhenDataChanged() {
homeViewModel.sduiList.observe(viewLifecycleOwner) {
commonAdapter.submitList(it)
homeViewModel.shotHomeExposureLogging()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import androidx.lifecycle.viewModelScope
import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.domain.constants.Role
import com.lgtm.domain.entity.response.SduiItemVO
import com.lgtm.domain.logging.HomeScreenClickScheme
import com.lgtm.domain.logging.HomeScreenExposureScheme
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.NotificationRepository
import com.lgtm.domain.usecase.MissionUseCase
import com.swm.logging.android.SWMLogging
import com.swm.logging.android.logging_scheme.ClickScheme
import com.swm.logging.android.logging_scheme.ExposureScheme
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 @@ -59,30 +56,10 @@ class HomeViewModel @Inject constructor(
}
}


fun shotHomeExposureLogging() {
val scheme = getHomeExposureLoggingScheme()
SWMLogging.logEvent(scheme)
fun shotHomeExposureLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
}

fun getUserRole() = role

fun shotHomeNotificationClickLogging() {
val scheme = getHomeClickLoggingScheme()
SWMLogging.logEvent(scheme)
}

private fun getHomeClickLoggingScheme(): ClickScheme {
return HomeScreenClickScheme.Builder()
.setAge("-1")
.setTitleName("homeMissionClick")
.build()
}

private fun getHomeExposureLoggingScheme(): ExposureScheme {
return HomeScreenExposureScheme.Builder()
.setTitleName("homeMissionClick")
.setAge("-1")
.build()
}
}
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.eventLogName}")
println("Rx: 아이템 받음: ${value.logName}")
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 eventLogName: String
open lateinit var logName: 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(
evenLogName: String,
logName: String,
screenName: String,
logVersion: String,
logData: MutableMap<String, Any>?,
) {
this.eventLogName = evenLogName
this.logName = logName
this.screenName = screenName
this.logVersion = logVersion
this.logData = logData
Expand Down

0 comments on commit 3c11955

Please sign in to comment.