Skip to content

Commit ad31847

Browse files
committed
Add logging
1 parent 0e32ae8 commit ad31847

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

core/src/main/java/in/koreatech/koin/core/analytics/EventUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package `in`.koreatech.koin.core.analytics
22

33
object EventUtils {
44

5-
private const val SCROLL_THRESHOLD = .7f
5+
private const val SCROLL_THRESHOLD = 70f
66

77
fun didCrossedScrollThreshold(prevScrollRatio: Float, currentScrollRatio: Float, threshold: Float = SCROLL_THRESHOLD): Boolean {
88
return prevScrollRatio < threshold && currentScrollRatio >= threshold

core/src/main/java/in/koreatech/koin/core/constant/AnalyticsConstant.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object AnalyticsConstant {
99
}
1010

1111
object Label {
12+
const val MAIN_SCROLL = "main_scroll"
1213
const val MAIN_SHOP_CATEGORIES = "main_shop_categories"
1314
const val MAIN_SHOP_BENEFIT = "main_shop_benefit"
1415
const val SHOP_CATEGORIES = "shop_categories"
@@ -95,6 +96,9 @@ object AnalyticsConstant {
9596
const val BENEFIT_SHOP_CALL = "benefit_shop_call"
9697

9798
const val MENU_SHARE = "menu_share"
99+
100+
const val CAMPUS_DINING_1 = "CAMPUS_dining_1"
101+
const val CAMPUS_NOTICE_1 = "CAMPUS_notice_1"
98102
}
99103

100104
const val PREVIOUS_PAGE = "previous_page"

koin/src/main/java/in/koreatech/koin/ui/main/activity/MainActivity.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import `in`.koreatech.koin.core.activity.WebViewActivity
2828
import `in`.koreatech.koin.core.analytics.EventAction
2929
import `in`.koreatech.koin.core.analytics.EventExtra
3030
import `in`.koreatech.koin.core.analytics.EventLogger
31+
import `in`.koreatech.koin.core.analytics.EventUtils
3132
import `in`.koreatech.koin.core.constant.AnalyticsConstant
3233
import `in`.koreatech.koin.core.navigation.Navigator
3334
import `in`.koreatech.koin.core.navigation.SchemeType
@@ -69,6 +70,8 @@ class MainActivity : KoinNavigationDrawerTimeActivity() {
6970
override val screenTitle = "코인 - 메인"
7071
private val viewModel by viewModels<MainActivityViewModel>()
7172

73+
private var scrollPercentage = 0.0f
74+
7275
@Inject
7376
lateinit var navigator: Navigator
7477

@@ -164,6 +167,25 @@ class MainActivity : KoinNavigationDrawerTimeActivity() {
164167

165168
private fun initView() = with(binding) {
166169
initDiningABTest()
170+
binding.nestedScrollViewMain.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
171+
val offset = binding.nestedScrollViewMain.computeVerticalScrollOffset()
172+
val extent = binding.nestedScrollViewMain.computeVerticalScrollExtent()
173+
val range = binding.nestedScrollViewMain.computeVerticalScrollRange()
174+
175+
val newScrollPercentage = 100.0f * offset / (range - extent)
176+
if (EventUtils.didCrossedScrollThreshold(
177+
scrollPercentage,
178+
newScrollPercentage
179+
) && scrollPercentage.toDouble() != .0
180+
) {
181+
EventLogger.logScrollEvent(
182+
EventAction.CAMPUS,
183+
AnalyticsConstant.Label.MAIN_SCROLL,
184+
"70%"
185+
)
186+
}
187+
scrollPercentage = 100.0f * offset / (range - extent)
188+
}
167189
viewModel.postABTestAssign(Experiment.BENEFIT_STORE.experimentTitle)
168190
storeListButton.setOnClickListener {
169191
gotoStoreActivity(0)

koin/src/main/java/in/koreatech/koin/ui/main/viewmodel/MainActivityViewModel.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import androidx.lifecycle.liveData
77
import androidx.lifecycle.viewModelScope
88
import dagger.hilt.android.lifecycle.HiltViewModel
99
import `in`.koreatech.koin.core.abtest.Experiment
10+
import `in`.koreatech.koin.core.abtest.ExperimentGroup
11+
import `in`.koreatech.koin.core.analytics.EventAction
12+
import `in`.koreatech.koin.core.analytics.EventLogger
13+
import `in`.koreatech.koin.core.constant.AnalyticsConstant
1014
import `in`.koreatech.koin.core.viewmodel.BaseViewModel
1115
import `in`.koreatech.koin.domain.error.bus.BusErrorHandler
1216
import `in`.koreatech.koin.domain.model.bus.BusNode
@@ -34,6 +38,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
3438
import kotlinx.coroutines.flow.flow
3539
import kotlinx.coroutines.flow.map
3640
import kotlinx.coroutines.flow.stateIn
41+
import timber.log.Timber
3742
import javax.inject.Inject
3843

3944
@HiltViewModel
@@ -75,6 +80,14 @@ class MainActivityViewModel @Inject constructor(
7580
val diningABTestExperimentGroup = flow {
7681
abTestUseCase(Experiment.MAIN_DINING_SEE_MORE.experimentTitle).onSuccess {
7782
emit(it)
83+
when (it) {
84+
ExperimentGroup.MAIN_DINING_NEW -> {
85+
EventLogger.logClickEvent(EventAction.CAMPUS, AnalyticsConstant.Label.CAMPUS_DINING_1, "더보기O")
86+
}
87+
ExperimentGroup.MAIN_DINING_ORIGINAL -> {
88+
EventLogger.logClickEvent(EventAction.CAMPUS, AnalyticsConstant.Label.CAMPUS_DINING_1, "더보기X")
89+
}
90+
}
7891
}.onFailure {
7992
emit(Experiment.MAIN_DINING_SEE_MORE.experimentGroups.first())
8093
}

koin/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
android:layout_marginTop="-24dp">
7070

7171
<androidx.core.widget.NestedScrollView
72+
android:id="@+id/nested_scroll_view_main"
7273
android:layout_width="match_parent"
7374
android:layout_height="match_parent"
7475
android:fillViewport="true">

0 commit comments

Comments
 (0)