Skip to content

Commit

Permalink
Merge pull request #316 from Runnect/feature/add-ga
Browse files Browse the repository at this point in the history
[ADD] 마이페이지, 보관함, 발견 / 이벤트 태깅
  • Loading branch information
sxunea authored Feb 14, 2024
2 parents 958b1f3 + c05cbe4 commit d14cfd5
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatDelegate
import com.kakao.sdk.common.KakaoSdk
import com.runnect.runnect.BuildConfig
import com.runnect.runnect.R
import com.runnect.runnect.util.analytics.Analytics
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

Expand All @@ -20,15 +21,20 @@ class ApplicationClass : Application() {
Timber.plant(Timber.DebugTree())
}
appContext = applicationContext
KakaoSdk.init(this,getString(R.string.kakao_native_app_key))
KakaoSdk.init(this, getString(R.string.kakao_native_app_key))
initApiMode()
initAnalytics()
}

private fun initApiMode() {
val currentApi = ApiMode.getCurrentApiMode(appContext)
PreferenceManager.setString(appContext, API_MODE, currentApi.name)
}

private fun initAnalytics() {
Analytics.initializeFirebaseAnalytics(applicationContext)
}

companion object {
lateinit var appContext: Context
const val API_MODE = "API_MODE"
Expand All @@ -39,7 +45,7 @@ class ApplicationClass : Application() {
!::appContext.isInitialized -> BuildConfig.RUNNECT_NODE_URL
else -> {
val mode = ApiMode.getCurrentApiMode(appContext)
when(mode) {
when (mode) {
ApiMode.JAVA -> BuildConfig.RUNNECT_PROD_URL
ApiMode.TEST -> BuildConfig.RUNNECT_DEV_URL
else -> BuildConfig.RUNNECT_NODE_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import com.runnect.runnect.presentation.login.LoginActivity
import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity
import com.runnect.runnect.presentation.profile.ProfileActivity
import com.runnect.runnect.presentation.state.UiStateV2
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_SHARE
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_USER_PROFILE
import com.runnect.runnect.util.analytics.EventName.VIEW_COURSE_DETAIL
import com.runnect.runnect.util.custom.dialog.CommonDialogFragment
import com.runnect.runnect.util.custom.dialog.CommonDialogText
import com.runnect.runnect.util.custom.dialog.RequireLoginDialogFragment
Expand Down Expand Up @@ -84,6 +88,8 @@ class CourseDetailActivity :
binding.vm = viewModel
binding.lifecycleOwner = this

Analytics.logClickedItemEvent(VIEW_COURSE_DETAIL)

initIntentExtraData()
updatePublicCourseIdFromDeepLink()
getCourseDetail()
Expand Down Expand Up @@ -142,6 +148,7 @@ class CourseDetailActivity :
startActivity(this)
}
applyScreenEnterAnimation()
Analytics.logClickedItemEvent(EVENT_CLICK_USER_PROFILE)
}

private fun handleBackButtonByCurrentScreenMode() {
Expand Down Expand Up @@ -238,6 +245,7 @@ class CourseDetailActivity :
desc = courseDetail.description,
image = courseDetail.image
)
Analytics.logClickedItemEvent(EVENT_CLICK_SHARE)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@ import com.runnect.runnect.R
import com.runnect.runnect.binding.BindingFragment
import com.runnect.runnect.databinding.FragmentDiscoverBinding
import com.runnect.runnect.domain.entity.DiscoverBanner
import com.runnect.runnect.presentation.discover.model.EditableDiscoverCourse
import com.runnect.runnect.presentation.MainActivity
import com.runnect.runnect.presentation.MainActivity.Companion.isVisitorMode
import com.runnect.runnect.presentation.detail.CourseDetailActivity
import com.runnect.runnect.presentation.detail.CourseDetailRootScreen
import com.runnect.runnect.presentation.discover.adapter.BannerAdapter
import com.runnect.runnect.presentation.discover.adapter.multiview.DiscoverMultiViewAdapter
import com.runnect.runnect.presentation.discover.adapter.multiview.DiscoverMultiViewType
import com.runnect.runnect.presentation.discover.model.EditableDiscoverCourse
import com.runnect.runnect.presentation.discover.pick.DiscoverPickActivity
import com.runnect.runnect.presentation.discover.search.DiscoverSearchActivity
import com.runnect.runnect.presentation.state.UiStateV2
import com.runnect.runnect.presentation.storage.StorageScrapFragment
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_DATE
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_SCRAP
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_TRY_BANNER
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_UPLOAD_BUTTON
import com.runnect.runnect.util.custom.toast.RunnectToast
import com.runnect.runnect.util.extension.applyScreenEnterAnimation
import com.runnect.runnect.util.extension.getCompatibleParcelableExtra
Expand All @@ -40,6 +45,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber

@AndroidEntryPoint
class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragment_discover) {
Expand Down Expand Up @@ -98,12 +104,22 @@ class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragm
},
onSortButtonClick = { criteria ->
viewModel.sortRecommendCourses(criteria)
Analytics.logClickedItemEvent(returnEventName(criteria))
}
).apply {
binding.rvDiscoverMultiView.adapter = this
}
}

private fun returnEventName(criteria: String): String {
var eventName = ""
when (criteria) {
"date" -> eventName = EVENT_CLICK_DATE
"scrap" -> eventName = EVENT_CLICK_SCRAP
}
return eventName
}

private fun navigateToDetailScreen(publicCourseId: Int) {
val context = context ?: return
Intent(context, CourseDetailActivity::class.java).apply {
Expand Down Expand Up @@ -139,6 +155,7 @@ class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragm
ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
Timber.d("viewpager position: $position")
updateBannerPosition(position)
updateBannerIndicatorPosition()
}
Expand Down Expand Up @@ -257,6 +274,7 @@ class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragm
showCourseUploadWarningToast(context)
return
}
Analytics.logClickedItemEvent(EVENT_CLICK_UPLOAD_BUTTON)
startActivity(Intent(context, DiscoverPickActivity::class.java))
activity?.applyScreenEnterAnimation()
}
Expand Down Expand Up @@ -309,6 +327,7 @@ class DiscoverFragment : BindingFragment<FragmentDiscoverBinding>(R.layout.fragm
banners = banners,
onBannerItemClick = { url ->
showPromotionWebsite(url)
Analytics.logClickedItemEvent(EVENT_CLICK_TRY_BANNER)
}
).apply {
binding.vpDiscoverBanner.adapter = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.runnect.runnect.R
import com.runnect.runnect.binding.BindingActivity
import com.runnect.runnect.databinding.ActivityDiscoverSearchBinding
import com.runnect.runnect.presentation.discover.model.EditableDiscoverCourse
import com.runnect.runnect.presentation.detail.CourseDetailActivity
import com.runnect.runnect.presentation.detail.CourseDetailRootScreen
import com.runnect.runnect.presentation.discover.DiscoverFragment.Companion.EXTRA_EDITABLE_DISCOVER_COURSE
import com.runnect.runnect.presentation.discover.model.EditableDiscoverCourse
import com.runnect.runnect.presentation.discover.search.adapter.DiscoverSearchAdapter
import com.runnect.runnect.presentation.state.UiStateV2
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_TRY_SEARCH_COURSE
import com.runnect.runnect.util.analytics.EventName.VIEW_COURSE_SEARCH
import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration
import com.runnect.runnect.util.extension.applyScreenEnterAnimation
import com.runnect.runnect.util.extension.getCompatibleParcelableExtra
Expand Down Expand Up @@ -52,7 +55,7 @@ class DiscoverSearchActivity :
super.onCreate(savedInstanceState)
binding.vm = viewModel
binding.lifecycleOwner = this@DiscoverSearchActivity

Analytics.logClickedItemEvent(VIEW_COURSE_SEARCH)
showSearchKeyboard()
initSearchAdapter()
initSearchRecyclerView()
Expand Down Expand Up @@ -129,6 +132,7 @@ class DiscoverSearchActivity :
if (actionId == IME_ACTION_SEARCH) {
val keyword = binding.etDiscoverSearchTitle.text
if (!keyword.isNullOrBlank()) {
Analytics.logClickedItemEvent(EVENT_CLICK_TRY_SEARCH_COURSE)
viewModel.getCourseSearch(keyword = keyword.toString())
hideKeyboard(binding.etDiscoverSearchTitle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import com.runnect.runnect.binding.BindingActivity
import com.runnect.runnect.databinding.ActivityDiscoverUploadBinding
import com.runnect.runnect.presentation.MainActivity
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_COURSE_UPLOAD
import com.runnect.runnect.util.analytics.EventName.VIEW_COURSE_UPLOAD
import com.runnect.runnect.util.extension.hideKeyboard
import com.runnect.runnect.util.extension.showToast
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -27,7 +30,7 @@ class DiscoverUploadActivity :
super.onCreate(savedInstanceState)
binding.vm = viewModel
binding.lifecycleOwner = this

Analytics.logClickedItemEvent(VIEW_COURSE_UPLOAD)
initLayout()
addListener()
addObserver()
Expand All @@ -54,6 +57,7 @@ class DiscoverUploadActivity :
if (it.isActivated) {
viewModel.postUploadMyCourse()
}
Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_UPLOAD)
}
//키보드 이벤트에 따른 동작 정의
binding.root.viewTreeObserver.addOnGlobalLayoutListener {
Expand Down Expand Up @@ -84,6 +88,7 @@ class DiscoverUploadActivity :
UiState.Success -> {
handleReturnToDiscover()
}

UiState.Failure -> {
binding.indeterminateBar.isVisible = false
Timber.tag(ContentValues.TAG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import com.runnect.runnect.presentation.mypage.reward.MyRewardActivity
import com.runnect.runnect.presentation.mypage.setting.MySettingFragment
import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_GOAL_REWARD
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_RUNNING_RECORD
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_UPLOADED_COURSE
import com.runnect.runnect.util.extension.getStampResId
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
Expand All @@ -34,10 +38,8 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
private val viewModel: MyPageViewModel by activityViewModels()
private lateinit var resultEditNameLauncher: ActivityResultLauncher<Intent>
var isVisitorMode: Boolean = MainActivity.isVisitorMode

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

if (isVisitorMode) {
activateVisitorMode()
} else {
Expand Down Expand Up @@ -103,18 +105,22 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
}

binding.viewMyPageMainRewardFrame.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_GOAL_REWARD)
startActivity(Intent(requireContext(), MyRewardActivity::class.java))
requireActivity().overridePendingTransition(
R.anim.slide_in_right, R.anim.slide_out_left
)
}
binding.viewMyPageMainHistoryFrame.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_RUNNING_RECORD)
startActivity(Intent(requireContext(), MyHistoryActivity::class.java))
requireActivity().overridePendingTransition(
R.anim.slide_in_right, R.anim.slide_out_left
)
}

binding.viewMyPageMainUploadFrame.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_UPLOADED_COURSE)
startActivity(Intent(requireContext(), MyUploadActivity::class.java))
requireActivity().overridePendingTransition(
R.anim.slide_in_right, R.anim.slide_out_left
Expand Down Expand Up @@ -171,10 +177,11 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
}
}

private fun inquiryKakao(){
private fun inquiryKakao() {
val url = TalkApiClient.instance.channelChatUrl(BuildConfig.KAKAO_CHANNEL_ID)
KakaoCustomTabsClient.openWithDefault(requireActivity(), url)
}

companion object {
const val RES_NAME = "mypage_img_stamp_"
const val RES_STAMP_TYPE = "drawable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import com.runnect.runnect.presentation.mypage.history.adapter.MyHistoryAdapter
import com.runnect.runnect.presentation.mypage.history.detail.MyHistoryDetailActivity
import com.runnect.runnect.presentation.search.SearchActivity
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.custom.deco.RecyclerOffsetDecorationHeight
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD
import com.runnect.runnect.util.callback.listener.OnMyHistoryItemClick
import com.runnect.runnect.util.custom.deco.RecyclerOffsetDecorationHeight
import com.runnect.runnect.util.extension.navigateToPreviousScreenWithAnimation
import com.runnect.runnect.util.extension.setCustomDialog
import com.runnect.runnect.util.extension.setDialogButtonClickListener
Expand Down Expand Up @@ -84,6 +86,7 @@ class MyHistoryActivity : BindingActivity<ActivityMyHistoryBinding>(R.layout.act
navigateToPreviousScreenWithAnimation()
}
binding.cvHistoryMyPageDrawCourse.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD)
startDrawCourseSearchActivity()
}
binding.btnMyPageHistoryEditHistory.setOnClickListener {
Expand Down Expand Up @@ -245,6 +248,7 @@ class MyHistoryActivity : BindingActivity<ActivityMyHistoryBinding>(R.layout.act
onBackPressedDispatcher.addCallback(this, callback)
}


companion object {
const val CHOICE_MODE_DESC = "기록 선택"
const val EDIT_CANCEL = "취소"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ class MySettingFragment : BindingFragment<FragmentMySettingBinding>(R.layout.fra
const val TERMS_URL =
"https://third-sight-046.notion.site/Runnect-5dfee19ccff04c388590e5ee335e77ed"
private const val DEV_MODE_SCHEME = "runnect://devmode"

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import com.runnect.runnect.databinding.FragmentMySettingAccountInfoBinding
import com.runnect.runnect.presentation.login.LoginActivity
import com.runnect.runnect.presentation.mypage.setting.MySettingFragment
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_TRY_LOGOUT
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_TRY_WITHDRAW
import com.runnect.runnect.util.analytics.EventName.EVENT_VIEW_SUCCESS_LOGOUT
import com.runnect.runnect.util.analytics.EventName.EVENT_VIEW_SUCCESS_WITHDRAW
import com.runnect.runnect.util.extension.setCustomDialog
import com.runnect.runnect.util.extension.setDialogButtonClickListener
import com.runnect.runnect.util.extension.showToast
Expand Down Expand Up @@ -57,10 +62,12 @@ class MySettingAccountInfoFragment :
}

binding.viewSettingAccountInfoLogoutFrame.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_TRY_LOGOUT)
logoutDialog.show()
}

binding.viewSettingAccountInfoWithdrawalFrame.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_TRY_WITHDRAW)
withdrawalDialog.show()
}
requireActivity().onBackPressedDispatcher.addCallback(
Expand All @@ -84,6 +91,7 @@ class MySettingAccountInfoFragment :
}

private fun handleSuccessfulUserDeletion() {
Analytics.logClickedItemEvent(EVENT_VIEW_SUCCESS_WITHDRAW)
binding.indeterminateBar.isVisible = false
moveToLogin()
showToast("탈퇴 처리되었습니다.")
Expand Down Expand Up @@ -114,6 +122,7 @@ class MySettingAccountInfoFragment :
logoutDialog.setDialogButtonClickListener { which ->
when (which) {
logoutDialog.btn_delete_yes -> {
Analytics.logClickedItemEvent(EVENT_VIEW_SUCCESS_LOGOUT)
moveToLogin()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import com.runnect.runnect.presentation.detail.CourseDetailRootScreen
import com.runnect.runnect.presentation.discover.pick.DiscoverPickActivity
import com.runnect.runnect.presentation.mypage.upload.adapter.MyUploadAdapter
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration
import com.runnect.runnect.util.analytics.Analytics
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE
import com.runnect.runnect.util.callback.listener.OnMyUploadItemClick
import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration
import com.runnect.runnect.util.extension.navigateToPreviousScreenWithAnimation
import com.runnect.runnect.util.extension.setCustomDialog
import com.runnect.runnect.util.extension.setDialogButtonClickListener
Expand All @@ -39,7 +41,6 @@ class MyUploadActivity : BindingActivity<ActivityMyUploadBinding>(R.layout.activ
binding.vm = viewModel
binding.lifecycleOwner = this
viewModel.getUserUploadCourse()

initLayout()
addListener()
addObserver()
Expand All @@ -52,6 +53,7 @@ class MyUploadActivity : BindingActivity<ActivityMyUploadBinding>(R.layout.activ
initRecyclerView()
}


private fun initRecyclerView() {
binding.rvMyPageUpload.layoutManager = GridLayoutManager(this, 2)
binding.rvMyPageUpload.addItemDecoration(
Expand All @@ -75,6 +77,7 @@ class MyUploadActivity : BindingActivity<ActivityMyUploadBinding>(R.layout.activ
handleDeleteButtonClicked(it)
}
binding.cvUploadMyPageUploadCourse.setOnClickListener {
Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE)
startActivity(Intent(this, DiscoverPickActivity::class.java))
finish()
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
Expand Down
Loading

0 comments on commit d14cfd5

Please sign in to comment.