Skip to content

Commit

Permalink
Merge pull request #268 from BCSDLab/hotfix/log-event
Browse files Browse the repository at this point in the history
[Hotfix] 로그 이벤트 추가
  • Loading branch information
ThirFir authored May 13, 2024
2 parents 6660bf0 + def022c commit 533acc9
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ buildscript {
compileSdkVersion = 34
minSdkVersion = 21
targetSdkVersion = 34
versionName = "3.4.1"
minVersionCode = 30401
versionName = "3.4.2"
minVersionCode = 30402
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object AnalyticsConstant {
const val MAIN_SHOP_CATEGORIES = "main_shop_categories"
const val SHOP_CATEGORIES = "shop_categories"
const val SHOP_CATEGORIES_SEARCH = "shop_categories_search"
const val SHOP_CATEGORIES_EVENT = "shop_categories_event"
const val HAMBURGER = "hamburger"
const val HAMBURGER_SHOP = "${HAMBURGER}_shop"
const val HAMBURGER_DINING = "${HAMBURGER}_dining"
Expand All @@ -43,6 +44,8 @@ object AnalyticsConstant {
const val SHOP_PICTURE = "shop_picture"
const val SHOP_CALL = "shop_call"
const val SHOP_CLICK = "shop_click"
const val SHOP_BACK_BUTTON = "shop_back_button"
const val SHOP_DETAIL_VIEW_EVENT = "shop_detail_view_event"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.koin.R
import `in`.koreatech.koin.core.util.dataBinding
import `in`.koreatech.koin.core.viewpager.HorizontalMarginItemDecoration
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.constant.AnalyticsConstant
import `in`.koreatech.koin.core.util.dataBinding
import `in`.koreatech.koin.core.viewpager.HorizontalMarginItemDecoration
import `in`.koreatech.koin.data.util.localized
import `in`.koreatech.koin.data.util.todayOrTomorrow
import `in`.koreatech.koin.databinding.ActivityMainBinding
Expand All @@ -26,7 +26,6 @@ import `in`.koreatech.koin.ui.navigation.KoinNavigationDrawerActivity
import `in`.koreatech.koin.ui.navigation.state.MenuState
import `in`.koreatech.koin.ui.store.contract.StoreActivityContract
import `in`.koreatech.koin.util.ext.observeLiveData
import androidx.activity.result.contract.ActivityResultContracts

@AndroidEntryPoint
class MainActivity : KoinNavigationDrawerActivity() {
Expand Down Expand Up @@ -58,8 +57,13 @@ class MainActivity : KoinNavigationDrawerActivity() {
private val diningContainerAdapter by lazy { DiningContainerViewPager2Adapter(this) }

private val storeCategoriesRecyclerAdapter = StoreCategoriesRecyclerAdapter().apply {
setOnItemClickListener {
gotoStoreActivity(it)
setOnItemClickListener { id, name ->
EventLogger.logClickEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.MAIN_SHOP_CATEGORIES,
name
)
gotoStoreActivity(id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ diffCallback

with(holder){
container.setOnClickListener {
onItemClickListener?.onItemClick(event.id)
onItemClickListener?.onItemClick(event.id, event.name)
}

Glide.with(storeCategoryImage)
Expand All @@ -47,13 +47,13 @@ diffCallback
}

interface OnItemClickListener {
fun onItemClick(id: Int)
fun onItemClick(id: Int, name: String)
}

inline fun setOnItemClickListener(crossinline onItemClick: (Id: Int) -> Unit) {
inline fun setOnItemClickListener(crossinline onItemClick: (Id: Int, name: String) -> Unit) {
onItemClickListener = object : StoreCategoriesRecyclerAdapter.OnItemClickListener {
override fun onItemClick(id: Int) {
onItemClick(id)
override fun onItemClick(id: Int, name: String) {
onItemClick(id, name)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package `in`.koreatech.koin.ui.store.activity

import android.graphics.Rect
import android.os.Bundle
import android.os.Handler
import android.os.Looper
Expand Down Expand Up @@ -68,6 +69,11 @@ class StoreActivity : KoinNavigationDrawerActivity() {

private val storeEventPagerAdapter = StoreEventPagerAdapter().apply {
setOnItemClickListener {
EventLogger.logClickEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.SHOP_CATEGORIES_EVENT,
it.shopName
)
storeDetailContract.launch(it.shopId)
}
}
Expand All @@ -76,6 +82,12 @@ class StoreActivity : KoinNavigationDrawerActivity() {
setOnItemClickListener {
viewModel.setCategory(it.toStoreCategory())
binding.searchEditText.text.clear()
val eventValue = getStoreCategoryName(viewModel.category.value)
EventLogger.logClickEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.SHOP_CATEGORIES,
eventValue
)
}
}

Expand Down Expand Up @@ -121,7 +133,8 @@ class StoreActivity : KoinNavigationDrawerActivity() {
val initStoreCategory =
intent.extras?.getInt(StoreActivityContract.STORE_CATEGORY)?.toStoreCategory()

storeCategoriesAdapter.selectPosition = intent.extras?.getInt(StoreActivityContract.STORE_CATEGORY)?.minus(2)
storeCategoriesAdapter.selectPosition =
intent.extras?.getInt(StoreActivityContract.STORE_CATEGORY)?.minus(2)
viewModel.setCategory(initStoreCategory)
}

Expand All @@ -133,7 +146,7 @@ class StoreActivity : KoinNavigationDrawerActivity() {
super.onBackPressed()
}

private fun initView(){
private fun initView() {
binding.koinBaseAppbar.setOnClickListener {
when (it.id) {
AppBarBase.getLeftButtonId() -> onBackPressed()
Expand All @@ -145,7 +158,7 @@ class StoreActivity : KoinNavigationDrawerActivity() {
binding.categoriesRecyclerview.apply {
layoutManager = GridLayoutManager(this@StoreActivity, 5)
adapter = storeCategoriesAdapter

}


Expand Down Expand Up @@ -192,7 +205,11 @@ class StoreActivity : KoinNavigationDrawerActivity() {
)
)
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {

}

Expand All @@ -208,6 +225,25 @@ class StoreActivity : KoinNavigationDrawerActivity() {
})
}

binding.root.post {
val rect = Rect()
window!!.decorView.getWindowVisibleDisplayFrame(rect)
val statusBarHeight = rect.top

binding.containerScrollView.setOnScrollChangeListener { v, _, scrollY, _, oldScrollY ->
val oldScrollRatio =
oldScrollY.toFloat() / (binding.containerScrollView.getChildAt(0).height - (binding.root.height - binding.callvanMainLayout.getChildAt(0).height - statusBarHeight))
val scrollRatio =
scrollY.toFloat() / (binding.containerScrollView.getChildAt(0).height - (binding.root.height - binding.callvanMainLayout.getChildAt(0).height - statusBarHeight))
if (scrollRatio >= 0.7 && oldScrollRatio < 0.7) {
EventLogger.logScrollEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.SHOP_CATEGORIES,
"scroll in " + getStoreCategoryName(viewModel.category.value)
)
}
}
}
}

private val runnable = object : Runnable {
Expand All @@ -221,6 +257,7 @@ class StoreActivity : KoinNavigationDrawerActivity() {
viewPagerHandler.postDelayed(this, viewPagerDelayTime)
}
}

private fun startAutoScroll() {
viewPagerHandler.removeCallbacks(runnable)
viewPagerHandler.postDelayed(runnable, viewPagerDelayTime)
Expand All @@ -233,12 +270,12 @@ class StoreActivity : KoinNavigationDrawerActivity() {
binding.storeSwiperefreshlayout.isRefreshing = it
}

observeLiveData(viewModel.storeEvents){
observeLiveData(viewModel.storeEvents) {
storeEventPagerAdapter.submitList(it)
binding.eventViewPager.isGone = it.isNullOrEmpty()
}

observeLiveData(viewModel.storeCategories){
observeLiveData(viewModel.storeCategories) {
storeCategoriesAdapter.submitList(it.drop(1))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import com.bumptech.glide.Glide
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import `in`.koreatech.koin.R
import `in`.koreatech.koin.core.analytics.EventLogger
Expand Down Expand Up @@ -37,8 +39,7 @@ class StoreDetailActivity : KoinNavigationDrawerActivity() {
override val screenTitle = "상점 상세"
private val viewModel by viewModels<StoreDetailViewModel>()
private var flyerDialogFragment: StoreFlyerDialogFragment? = null



private val callPermission =
registerForActivityResult(ActivityResultContracts.RequestPermission()) {
if (it) {
Expand Down Expand Up @@ -75,7 +76,14 @@ class StoreDetailActivity : KoinNavigationDrawerActivity() {
setContentView(binding.root)
binding.koinBaseAppbar.setOnClickListener {
when (it.id) {
AppBarBase.getLeftButtonId() -> onBackPressed()
AppBarBase.getLeftButtonId() -> {
EventLogger.logClickEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.SHOP_BACK_BUTTON,
viewModel.store.value?.name ?: "Unknown"
)
onBackPressed()
}
AppBarBase.getRightButtonId() -> toggleNavigationDrawer()
}
}
Expand All @@ -100,6 +108,21 @@ class StoreDetailActivity : KoinNavigationDrawerActivity() {
}
}.attach()

binding.storeDetailTabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
if (tab?.position == 1)
EventLogger.logClickEvent(
AnalyticsConstant.Domain.BUSINESS,
AnalyticsConstant.Label.SHOP_DETAIL_VIEW_EVENT,
viewModel.store.value?.name ?: "Unknown"
)
}

override fun onTabUnselected(p0: TabLayout.Tab?) {}

override fun onTabReselected(p0: TabLayout.Tab?) {}
})

initViewModel()
val storeId = intent.extras?.getInt(StoreDetailActivityContract.STORE_ID)
if (storeId == null) {
Expand Down

0 comments on commit 533acc9

Please sign in to comment.