From 7caeee042ca56d5bf7d94263e0e731c1fd58096e Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Wed, 17 Jan 2024 20:40:39 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[FEAT]=20#315=20GA=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EB=B0=8F=20logEvent=20Util=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnect/util/analytics/Analytics.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt diff --git a/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt b/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt new file mode 100644 index 000000000..083975a60 --- /dev/null +++ b/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt @@ -0,0 +1,40 @@ +package com.runnect.runnect.util.analytics + +import android.content.Context +import android.os.Bundle +import com.google.android.gms.common.wrappers.InstantApps +import com.google.firebase.analytics.FirebaseAnalytics + +object Analytics { + private const val STATUS_INSTALLED = "installed" + private const val STATUS_INSTANT = "instant" + private const val ANALYTICS_USER_PROP = "app_type" + + private var firebaseAnalytics: FirebaseAnalytics? = null + + fun initializeFirebaseAnalytics(context: Context) { + firebaseAnalytics = FirebaseAnalytics.getInstance(context) + + // 현재 앱이 인스턴트 앱인지를 확인하고, 그 여부에 따라 UserProperty 다르게 세팅 + if (InstantApps.isInstantApp(context)) { + setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTANT) + } else { + setUserProperty(ANALYTICS_USER_PROP, STATUS_INSTALLED) + } + } + + private fun setUserProperty(property: String, value: String) { + firebaseAnalytics?.setUserProperty(property, value) + } + + fun logClickedItemEvent(itemName: String) { + val bundle = Bundle().apply { + putString(FirebaseAnalytics.Param.ITEM_NAME, itemName) + } + logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle) + } + + private fun logEvent(eventName: String, params: Bundle) { + firebaseAnalytics?.logEvent(eventName, params) + } +} From 12b23b9e126a260b0474257aa2c515c42c25261d Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Wed, 17 Jan 2024 20:44:56 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[ADD]=20#315=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnect/application/ApplicationClass.kt | 10 ++++++++-- .../presentation/mypage/MyPageFragment.kt | 20 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/application/ApplicationClass.kt b/app/src/main/java/com/runnect/runnect/application/ApplicationClass.kt index 8365d7c3c..0051070b5 100644 --- a/app/src/main/java/com/runnect/runnect/application/ApplicationClass.kt +++ b/app/src/main/java/com/runnect/runnect/application/ApplicationClass.kt @@ -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 @@ -20,8 +21,9 @@ 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() { @@ -29,6 +31,10 @@ class ApplicationClass : Application() { 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" @@ -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 diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt index 1f716a15b..edb3ec3b3 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt @@ -11,6 +11,9 @@ import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.fragment.app.commit import androidx.fragment.app.replace +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.kakao.sdk.common.util.KakaoCustomTabsClient import com.kakao.sdk.talk.TalkApiClient import com.runnect.runnect.BuildConfig @@ -25,6 +28,7 @@ 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.extension.getStampResId import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber @@ -34,10 +38,10 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private val viewModel: MyPageViewModel by activityViewModels() private lateinit var resultEditNameLauncher: ActivityResultLauncher var isVisitorMode: Boolean = MainActivity.isVisitorMode - + private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - + initFirebaseAnalytics() if (isVisitorMode) { activateVisitorMode() } else { @@ -46,6 +50,9 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } + private fun initFirebaseAnalytics(){ + firebaseAnalytics = Firebase.analytics + } private fun activateVisitorMode() { with(binding) { ivVisitorMode.isVisible = true @@ -103,18 +110,22 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } binding.viewMyPageMainRewardFrame.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_TO_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_TO_HISTORY) startActivity(Intent(requireContext(), MyHistoryActivity::class.java)) requireActivity().overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left ) } + binding.viewMyPageMainUploadFrame.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_TO_UPLOADED_COURSE) startActivity(Intent(requireContext(), MyUploadActivity::class.java)) requireActivity().overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left @@ -181,5 +192,10 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ const val EXTRA_NICK_NAME = "nickname" const val EXTRA_PROFILE = "profile_img" const val ACCOUNT_INFO_TAG = "accountInfo" + + const val EVENT_TO_HISTORY = "toHistory" + const val EVENT_TO_REWARD = "toReward" + const val EVENT_TO_UPLOADED_COURSE = "toUpload" + } } \ No newline at end of file From d793f8901c7e1c199c58c1303530b2b8000c7965 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Wed, 17 Jan 2024 20:46:55 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[ADD]=20#315=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mypage/upload/MyUploadActivity.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt index f98e3ecfa..7edf99bfd 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt @@ -9,6 +9,9 @@ import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.recyclerview.widget.GridLayoutManager +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.databinding.ActivityMyUploadBinding @@ -17,8 +20,9 @@ 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.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 @@ -33,13 +37,14 @@ class MyUploadActivity : BindingActivity(R.layout.activ private val viewModel: MyUploadViewModel by viewModels() private lateinit var adapter: MyUploadAdapter private lateinit var dialog: AlertDialog + private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this viewModel.getUserUploadCourse() - + initFirebaseAnalytics() initLayout() addListener() addObserver() @@ -52,6 +57,10 @@ class MyUploadActivity : BindingActivity(R.layout.activ initRecyclerView() } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + private fun initRecyclerView() { binding.rvMyPageUpload.layoutManager = GridLayoutManager(this, 2) binding.rvMyPageUpload.addItemDecoration( @@ -75,6 +84,7 @@ class MyUploadActivity : BindingActivity(R.layout.activ handleDeleteButtonClicked(it) } binding.cvUploadMyPageUploadCourse.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_UPLOAD_COURSE) startActivity(Intent(this, DiscoverPickActivity::class.java)) finish() overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left) @@ -268,5 +278,7 @@ class MyUploadActivity : BindingActivity(R.layout.activ const val DELETE_BTN = "삭제하기" const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" const val EXTRA_ROOT_SCREEN = "rootScreen" + + const val EVENT_UPLOAD_COURSE = "uploadCourse" } } \ No newline at end of file From 9f73d2c1fe35fba2fa51a3458f8149bd1cdaa345 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Wed, 17 Jan 2024 20:55:46 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[ADD]=20#315=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mypage/setting/MySettingFragment.kt | 10 +++++++++- .../MySettingAccountInfoFragment.kt | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt index 8aa50598d..4d3720110 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt @@ -8,6 +8,9 @@ import androidx.activity.OnBackPressedCallback import androidx.core.view.isVisible import androidx.fragment.app.commit import androidx.fragment.app.replace +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.BuildConfig import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment @@ -17,13 +20,17 @@ import com.runnect.runnect.presentation.mypage.setting.accountinfo.MySettingAcco import com.runnect.runnect.util.extension.showWebBrowser class MySettingFragment : BindingFragment(R.layout.fragment_my_setting) { + private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initFirebaseAnalytics() addListener() setVisibleDeveloperMode() registerBackPressedCallback() } - + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } private fun registerBackPressedCallback() { val callback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { @@ -90,5 +97,6 @@ class MySettingFragment : BindingFragment(R.layout.fra const val TERMS_URL = "https://third-sight-046.notion.site/Runnect-5dfee19ccff04c388590e5ee335e77ed" private const val DEV_MODE_SCHEME = "runnect://devmode" + } } diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt index 5954421f8..c9626d359 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt @@ -10,6 +10,9 @@ import androidx.core.view.isVisible import androidx.fragment.app.commit import androidx.fragment.app.replace import androidx.fragment.app.viewModels +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.application.PreferenceManager import com.runnect.runnect.binding.BindingFragment @@ -17,6 +20,7 @@ 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.extension.setCustomDialog import com.runnect.runnect.util.extension.setDialogButtonClickListener import com.runnect.runnect.util.extension.showToast @@ -29,6 +33,7 @@ class MySettingAccountInfoFragment : BindingFragment(R.layout.fragment_my_setting_account_info) { private lateinit var logoutDialog: AlertDialog private lateinit var withdrawalDialog: AlertDialog + private lateinit var firebaseAnalytics: FirebaseAnalytics private val viewModel: MySettingAccountInfoViewModel by viewModels() private val backPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { @@ -44,6 +49,7 @@ class MySettingAccountInfoFragment : initLogoutDialog() setLogoutDialogClickEvent() initWithdrawalDialog() + initFirebaseAnalytics() setWithdrawalDialogClickEvent() } @@ -51,16 +57,22 @@ class MySettingAccountInfoFragment : setEmailFromMySetting() } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + private fun addListener() { binding.ivSettingAccountInfoBack.setOnClickListener { moveToMySetting() } binding.viewSettingAccountInfoLogoutFrame.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_ACCOUNT_TRY_LOGOUT) logoutDialog.show() } binding.viewSettingAccountInfoWithdrawalFrame.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_ACCOUNT_TRY_WITHDRAWL) withdrawalDialog.show() } requireActivity().onBackPressedDispatcher.addCallback( @@ -84,6 +96,7 @@ class MySettingAccountInfoFragment : } private fun handleSuccessfulUserDeletion() { + Analytics.logClickedItemEvent(EVENT_ACCOUNT_COMPLETE_WITHDRAWL) binding.indeterminateBar.isVisible = false moveToLogin() showToast("탈퇴 처리되었습니다.") @@ -114,6 +127,7 @@ class MySettingAccountInfoFragment : logoutDialog.setDialogButtonClickListener { which -> when (which) { logoutDialog.btn_delete_yes -> { + Analytics.logClickedItemEvent(EVENT_ACCOUNT_COMPLETE_LOGOUT) moveToLogin() } } @@ -160,5 +174,11 @@ class MySettingAccountInfoFragment : const val DESCRIPTION_WITHDRAWAL_NO = "아니오" const val TOKEN_KEY_ACCESS = "access" const val TOKEN_KEY_REFRESH = "refresh" + + const val EVENT_ACCOUNT_TRY_LOGOUT = "tryLogout" + const val EVENT_ACCOUNT_COMPLETE_LOGOUT = "completeLogout" + const val EVENT_ACCOUNT_TRY_WITHDRAWL = "tryWithdrawl" + const val EVENT_ACCOUNT_COMPLETE_WITHDRAWL = "completeWithdrawl" + } } \ No newline at end of file From eb9713c695358431cef46a176cecd69706703227 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 19 Jan 2024 12:39:58 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[MOD]=20#315=20GA=20logEvent=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20bundle=20nullable=ED=95=98=EA=B2=8C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnect/runnect/util/analytics/Analytics.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt b/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt index 083975a60..588631812 100644 --- a/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt +++ b/app/src/main/java/com/runnect/runnect/util/analytics/Analytics.kt @@ -2,6 +2,7 @@ package com.runnect.runnect.util.analytics import android.content.Context import android.os.Bundle +import android.util.StatsLog.logEvent import com.google.android.gms.common.wrappers.InstantApps import com.google.firebase.analytics.FirebaseAnalytics @@ -27,14 +28,13 @@ object Analytics { firebaseAnalytics?.setUserProperty(property, value) } - fun logClickedItemEvent(itemName: String) { - val bundle = Bundle().apply { - putString(FirebaseAnalytics.Param.ITEM_NAME, itemName) + fun logClickedItemEvent(eventName: String, itemName: String? = null) { + val bundle = itemName?.let { + Bundle().apply { + putString(FirebaseAnalytics.Param.ITEM_NAME, it) + } } - logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle) + firebaseAnalytics?.logEvent(eventName, bundle) } - private fun logEvent(eventName: String, params: Bundle) { - firebaseAnalytics?.logEvent(eventName, params) - } } From 6ce98dfe24332d07b1e78c3d5550b2c152a24e0c Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 19 Jan 2024 12:40:31 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[MOD]=20#315=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accountinfo/MySettingAccountInfoFragment.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt index c9626d359..756ec6d19 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt @@ -67,12 +67,12 @@ class MySettingAccountInfoFragment : } binding.viewSettingAccountInfoLogoutFrame.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_ACCOUNT_TRY_LOGOUT) + Analytics.logClickedItemEvent(EVENT_CLICK_TRY_LOGOUT) logoutDialog.show() } binding.viewSettingAccountInfoWithdrawalFrame.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_ACCOUNT_TRY_WITHDRAWL) + Analytics.logClickedItemEvent(EVENT_CLICK_TRY_WITHDRAW) withdrawalDialog.show() } requireActivity().onBackPressedDispatcher.addCallback( @@ -96,7 +96,7 @@ class MySettingAccountInfoFragment : } private fun handleSuccessfulUserDeletion() { - Analytics.logClickedItemEvent(EVENT_ACCOUNT_COMPLETE_WITHDRAWL) + Analytics.logClickedItemEvent(EVENT_VIEW_SUCCESS_WITHDRAW) binding.indeterminateBar.isVisible = false moveToLogin() showToast("탈퇴 처리되었습니다.") @@ -127,7 +127,7 @@ class MySettingAccountInfoFragment : logoutDialog.setDialogButtonClickListener { which -> when (which) { logoutDialog.btn_delete_yes -> { - Analytics.logClickedItemEvent(EVENT_ACCOUNT_COMPLETE_LOGOUT) + Analytics.logClickedItemEvent(EVENT_VIEW_SUCCESS_LOGOUT) moveToLogin() } } @@ -175,10 +175,10 @@ class MySettingAccountInfoFragment : const val TOKEN_KEY_ACCESS = "access" const val TOKEN_KEY_REFRESH = "refresh" - const val EVENT_ACCOUNT_TRY_LOGOUT = "tryLogout" - const val EVENT_ACCOUNT_COMPLETE_LOGOUT = "completeLogout" - const val EVENT_ACCOUNT_TRY_WITHDRAWL = "tryWithdrawl" - const val EVENT_ACCOUNT_COMPLETE_WITHDRAWL = "completeWithdrawl" + const val EVENT_VIEW_SUCCESS_LOGOUT = "viewSuccessLogout" + const val EVENT_CLICK_TRY_LOGOUT = "clickTryLogout" + const val EVENT_VIEW_SUCCESS_WITHDRAW = "viewSuccessWithdraw" + const val EVENT_CLICK_TRY_WITHDRAW = "clickTryLogout" } } \ No newline at end of file From 6754d5c42f5018c01369b5490d4f0280e1e1e97c Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 19 Jan 2024 12:58:44 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[MOD]=20#315=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/mypage/MyPageFragment.kt | 18 ++++++++++-------- .../mypage/history/MyHistoryActivity.kt | 15 ++++++++++++++- .../mypage/upload/MyUploadActivity.kt | 4 ++-- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt index edb3ec3b3..82f81cff1 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt @@ -50,9 +50,10 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } - private fun initFirebaseAnalytics(){ + private fun initFirebaseAnalytics() { firebaseAnalytics = Firebase.analytics } + private fun activateVisitorMode() { with(binding) { ivVisitorMode.isVisible = true @@ -110,14 +111,14 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } binding.viewMyPageMainRewardFrame.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_TO_REWARD) + 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_TO_HISTORY) + Analytics.logClickedItemEvent(EVENT_CLICK_RUNNING_RECORD) startActivity(Intent(requireContext(), MyHistoryActivity::class.java)) requireActivity().overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left @@ -125,7 +126,7 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } binding.viewMyPageMainUploadFrame.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_TO_UPLOADED_COURSE) + Analytics.logClickedItemEvent(EVENT_CLICK_UPLOADED_COURSE) startActivity(Intent(requireContext(), MyUploadActivity::class.java)) requireActivity().overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left @@ -182,10 +183,11 @@ class MyPageFragment : BindingFragment(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" @@ -193,9 +195,9 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ const val EXTRA_PROFILE = "profile_img" const val ACCOUNT_INFO_TAG = "accountInfo" - const val EVENT_TO_HISTORY = "toHistory" - const val EVENT_TO_REWARD = "toReward" - const val EVENT_TO_UPLOADED_COURSE = "toUpload" + const val EVENT_CLICK_RUNNING_RECORD = "clickRunningRecord" + const val EVENT_CLICK_GOAL_REWARD = "clickGoalReward" + const val EVENT_CLICK_UPLOADED_COURSE = "clickUploadedCourse" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt index a98f1dfbf..5e7a032e6 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt @@ -9,6 +9,9 @@ import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.data.dto.HistoryInfoDTO @@ -17,8 +20,9 @@ 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.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 @@ -32,6 +36,7 @@ class MyHistoryActivity : BindingActivity(R.layout.act private val viewModel: MyHistoryViewModel by viewModels() private lateinit var adapter: MyHistoryAdapter private lateinit var dialog: AlertDialog + private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -58,6 +63,10 @@ class MyHistoryActivity : BindingActivity(R.layout.act binding.rvMyPageHistory.addItemDecoration(RecyclerOffsetDecorationHeight(this, 10)) } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + private fun getRecord() { viewModel.getRecord() } @@ -84,6 +93,7 @@ class MyHistoryActivity : BindingActivity(R.layout.act navigateToPreviousScreenWithAnimation() } binding.cvHistoryMyPageDrawCourse.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD) startDrawCourseSearchActivity() } binding.btnMyPageHistoryEditHistory.setOnClickListener { @@ -245,6 +255,7 @@ class MyHistoryActivity : BindingActivity(R.layout.act onBackPressedDispatcher.addCallback(this, callback) } + companion object { const val CHOICE_MODE_DESC = "기록 선택" const val EDIT_CANCEL = "취소" @@ -253,5 +264,7 @@ class MyHistoryActivity : BindingActivity(R.layout.act const val DELETE_BTN = "삭제하기" const val EXTRA_HISTORY_DATA = "historyData" const val BUNDLE_HISTORY = "historyDataBundle" + + const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "clickCourseDrawingInRunningRecord" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt index 7edf99bfd..9815e8f5d 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt @@ -84,7 +84,7 @@ class MyUploadActivity : BindingActivity(R.layout.activ handleDeleteButtonClicked(it) } binding.cvUploadMyPageUploadCourse.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_UPLOAD_COURSE) + 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) @@ -279,6 +279,6 @@ class MyUploadActivity : BindingActivity(R.layout.activ const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" const val EXTRA_ROOT_SCREEN = "rootScreen" - const val EVENT_UPLOAD_COURSE = "uploadCourse" + const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "clickCourseUploadInUploadedCourse" } } \ No newline at end of file From fc5ea841081d01e2b8b7dd82f8c3fe613870439a Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 19 Jan 2024 13:11:36 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[ADD]=20#315=20=EB=B3=B4=EA=B4=80?= =?UTF-8?q?=ED=95=A8=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/mypage/MyPageFragment.kt | 6 ++--- .../mypage/history/MyHistoryActivity.kt | 3 ++- .../MySettingAccountInfoFragment.kt | 8 +++---- .../mypage/upload/MyUploadActivity.kt | 2 +- .../storage/StorageMainFragment.kt | 22 ++++++++++++++++--- .../storage/StorageMyDrawFragment.kt | 17 +++++++++++++- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt index 82f81cff1..02696dd35 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt @@ -195,9 +195,9 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ const val EXTRA_PROFILE = "profile_img" const val ACCOUNT_INFO_TAG = "accountInfo" - const val EVENT_CLICK_RUNNING_RECORD = "clickRunningRecord" - const val EVENT_CLICK_GOAL_REWARD = "clickGoalReward" - const val EVENT_CLICK_UPLOADED_COURSE = "clickUploadedCourse" + const val EVENT_CLICK_RUNNING_RECORD = "click_running_record" + const val EVENT_CLICK_GOAL_REWARD = "click_goal_reward" + const val EVENT_CLICK_UPLOADED_COURSE = "click_uploaded_course" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt index 5e7a032e6..7d60d64b1 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt @@ -43,6 +43,7 @@ class MyHistoryActivity : BindingActivity(R.layout.act binding.vm = viewModel binding.lifecycleOwner = this initLayout() + initFirebaseAnalytics() addListener() addObserver() initDialog() @@ -265,6 +266,6 @@ class MyHistoryActivity : BindingActivity(R.layout.act const val EXTRA_HISTORY_DATA = "historyData" const val BUNDLE_HISTORY = "historyDataBundle" - const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "clickCourseDrawingInRunningRecord" + const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "click_course_drawing_in_running_record" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt index 756ec6d19..294c315be 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt @@ -175,10 +175,10 @@ class MySettingAccountInfoFragment : const val TOKEN_KEY_ACCESS = "access" const val TOKEN_KEY_REFRESH = "refresh" - const val EVENT_VIEW_SUCCESS_LOGOUT = "viewSuccessLogout" - const val EVENT_CLICK_TRY_LOGOUT = "clickTryLogout" - const val EVENT_VIEW_SUCCESS_WITHDRAW = "viewSuccessWithdraw" - const val EVENT_CLICK_TRY_WITHDRAW = "clickTryLogout" + const val EVENT_VIEW_SUCCESS_LOGOUT = "view_success_logout" + const val EVENT_CLICK_TRY_LOGOUT = "click_try_logout" + const val EVENT_VIEW_SUCCESS_WITHDRAW = "view_success_withdraw" + const val EVENT_CLICK_TRY_WITHDRAW = "click_try_withdraw" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt index 9815e8f5d..035e66fac 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt @@ -279,6 +279,6 @@ class MyUploadActivity : BindingActivity(R.layout.activ const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" const val EXTRA_ROOT_SCREEN = "rootScreen" - const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "clickCourseUploadInUploadedCourse" + const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "click_course_upload_in_uploaded_course" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt index 66f3d7b23..ce4d66c05 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt @@ -9,24 +9,29 @@ import androidx.fragment.app.commit import androidx.fragment.app.replace import androidx.fragment.app.viewModels import com.google.android.material.tabs.TabLayout +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentStorageMainBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.login.LoginActivity +import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity +import com.runnect.runnect.util.analytics.Analytics import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber @AndroidEntryPoint class StorageMainFragment : BindingFragment(R.layout.fragment_storage_main) { - + private lateinit var firebaseAnalytics: FirebaseAnalytics val viewModel: StorageViewModel by viewModels() var isVisitorMode: Boolean = MainActivity.isVisitorMode override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - + initFirebaseAnalytics() if (isVisitorMode) { activateVisitorMode() } else { @@ -70,20 +75,27 @@ class StorageMainFragment : } } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + private fun tabLayoutAction() { binding.storageTab.addOnTabSelectedListener( object : TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab?) { when (tab?.position) { 0 -> childFragmentManager.commit { + Analytics.logClickedItemEvent(EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START) replace(R.id.fl_main) Timber.tag("hu").d("내가 그린 코스로 이동하였음") } 1 -> childFragmentManager.commit { + Analytics.logClickedItemEvent(EVENT_CLICK_SCRAP_COURSE) replace(R.id.fl_main) Timber.tag("hu").d("스크랩으로 이동하였음") } + else -> IllegalArgumentException("${this::class.java.simpleName} Not found menu item id") } } @@ -91,6 +103,7 @@ class StorageMainFragment : // 다른 탭 버튼을 눌러 선택된 탭 버튼이 해제될 때 이벤트 override fun onTabUnselected(tab: TabLayout.Tab?) { } + // 선택된 탭 버튼을 다시 선택할 때 이벤트 override fun onTabReselected(tab: TabLayout.Tab?) { } @@ -98,6 +111,9 @@ class StorageMainFragment : } ) } - + companion object { + const val EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START= "click_my_storage_course_drawing_start" + const val EVENT_CLICK_SCRAP_COURSE = "click_scrap_course" + } } diff --git a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt index 0c4d407d2..d37a35cf5 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt @@ -13,17 +13,22 @@ import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.bottomnavigation.BottomNavigationView +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentStorageMyDrawBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.mydrawdetail.MyDrawDetailActivity +import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity import com.runnect.runnect.presentation.search.SearchActivity import com.runnect.runnect.presentation.state.UiState import com.runnect.runnect.presentation.storage.adapter.StorageMyDrawAdapter -import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration +import com.runnect.runnect.util.analytics.Analytics import com.runnect.runnect.util.callback.ItemCount import com.runnect.runnect.util.callback.listener.OnMyDrawItemClick +import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration import com.runnect.runnect.util.extension.setFragmentDialog import dagger.hilt.android.AndroidEntryPoint import kotlinx.android.synthetic.main.custom_dialog_delete.view.* @@ -35,6 +40,7 @@ class StorageMyDrawFragment : BindingFragment(R.layout.fragment_storage_my_draw), OnMyDrawItemClick, ItemCount { + private lateinit var firebaseAnalytics: FirebaseAnalytics val viewModel: StorageViewModel by viewModels() lateinit var storageMyDrawAdapter: StorageMyDrawAdapter @@ -60,6 +66,7 @@ class StorageMyDrawFragment : initLayout() binding.lifecycleOwner = requireActivity() initAdapter() + initFirebaseAnalytics() editCourse() getCourse() requireCourse() @@ -95,6 +102,10 @@ class StorageMyDrawFragment : binding.recyclerViewStorageMyDraw.adapter = storageMyDrawAdapter } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + fun hideBottomNav() { animDown = AnimationUtils.loadAnimation(requireActivity(), R.anim.slide_out_down) @@ -214,6 +225,7 @@ class StorageMyDrawFragment : } private fun handleSuccessfulUploadDeletion() { + Analytics.logClickedItemEvent(EVENT_MY_STORAGE_TRY_REMOVE) binding.indeterminateBar.isVisible = false storageMyDrawAdapter.removeItems(viewModel.itemsToDelete) storageMyDrawAdapter.clearSelection() @@ -355,5 +367,8 @@ class StorageMyDrawFragment : const val EXTRA_COURSE_ID = "courseId" const val EXTRA_ROOT_SCREEN = "rootScreen" const val EDIT_MODE = "선택" + const val EVENT_MY_STORAGE_TRY_MODIFY = "click_my_storage_try_modify" + const val EVENT_MY_STORAGE_TRY_REMOVE = "click_my_storage_try_remove" + } } From 51d48d0e6b531de312f40af1eb6e7cbdb662b7ff Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 19 Jan 2024 13:21:29 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[ADD]=20#315=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EB=B0=9C=EA=B2=AC=20=EC=9D=BC=EB=B6=80=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/discover/DiscoverFragment.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt index a3a49ba67..d9a66333a 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt @@ -13,21 +13,25 @@ import androidx.fragment.app.viewModels import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase 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.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.custom.toast.RunnectToast import com.runnect.runnect.util.extension.applyScreenEnterAnimation import com.runnect.runnect.util.extension.getCompatibleParcelableExtra @@ -45,6 +49,7 @@ import timber.log.Timber class DiscoverFragment : BindingFragment(R.layout.fragment_discover) { private val viewModel: DiscoverViewModel by viewModels() + private lateinit var firebaseAnalytics: FirebaseAnalytics private lateinit var bannerAdapter: BannerAdapter private lateinit var bannerScrollJob: Job private var currentBannerPosition = 0 @@ -71,7 +76,7 @@ class DiscoverFragment : BindingFragment(R.layout.fragm super.onViewCreated(view, savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = viewLifecycleOwner - + initFirebaseAnalytics() createBannerScrollJob() addListener() addObserver() @@ -85,6 +90,10 @@ class DiscoverFragment : BindingFragment(R.layout.fragm } } + private fun initFirebaseAnalytics() { + firebaseAnalytics = Firebase.analytics + } + private fun registerCallback() { registerBannerPageChangeCallback() registerBackPressedCallback() @@ -195,6 +204,7 @@ class DiscoverFragment : BindingFragment(R.layout.fragm private fun initSearchButtonClickListener() { val context = context ?: return binding.ivDiscoverSearch.setOnClickListener { + Analytics.logClickedItemEvent(EVENT_CLICK_TRY_SEARCH_COURSE) startActivity(Intent(context, DiscoverSearchActivity::class.java)) activity?.applyScreenEnterAnimation() } @@ -216,6 +226,7 @@ class DiscoverFragment : BindingFragment(R.layout.fragm showCourseUploadWarningToast(context) return } + Analytics.logClickedItemEvent(EVENT_CLICK_UPLOAD_BUTTON) startActivity(Intent(context, DiscoverPickActivity::class.java)) activity?.applyScreenEnterAnimation() } @@ -472,5 +483,8 @@ class DiscoverFragment : BindingFragment(R.layout.fragm private const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" private const val EXTRA_ROOT_SCREEN = "rootScreen" const val EXTRA_EDITABLE_DISCOVER_COURSE = "editable_discover_course" + + const val EVENT_CLICK_UPLOAD_BUTTON = "click_upload_button" + const val EVENT_CLICK_TRY_SEARCH_COURSE = "click_try_search_course" } } \ No newline at end of file From ed29de8f2c8ae6b6725375d7cd8b7ef32bec9189 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 23 Jan 2024 16:16:29 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[MOD]=20#315=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A2=85=EB=A5=98=20Object=EB=A1=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/discover/DiscoverFragment.kt | 14 ++------- .../presentation/mypage/MyPageFragment.kt | 17 ++-------- .../mypage/history/MyHistoryActivity.kt | 12 +------ .../mypage/setting/MySettingFragment.kt | 9 +----- .../MySettingAccountInfoFragment.kt | 19 +++--------- .../mypage/upload/MyUploadActivity.kt | 11 +------ .../storage/StorageMainFragment.kt | 21 +++---------- .../storage/StorageMyDrawFragment.kt | 14 +-------- .../runnect/util/analytics/EventName.kt | 31 +++++++++++++++++++ 9 files changed, 50 insertions(+), 98 deletions(-) create mode 100644 app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt diff --git a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt index d9a66333a..a7b67d68b 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt @@ -13,9 +13,6 @@ import androidx.fragment.app.viewModels import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentDiscoverBinding @@ -32,6 +29,8 @@ 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_TRY_SEARCH_COURSE +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 @@ -49,7 +48,6 @@ import timber.log.Timber class DiscoverFragment : BindingFragment(R.layout.fragment_discover) { private val viewModel: DiscoverViewModel by viewModels() - private lateinit var firebaseAnalytics: FirebaseAnalytics private lateinit var bannerAdapter: BannerAdapter private lateinit var bannerScrollJob: Job private var currentBannerPosition = 0 @@ -76,7 +74,6 @@ class DiscoverFragment : BindingFragment(R.layout.fragm super.onViewCreated(view, savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = viewLifecycleOwner - initFirebaseAnalytics() createBannerScrollJob() addListener() addObserver() @@ -90,9 +87,7 @@ class DiscoverFragment : BindingFragment(R.layout.fragm } } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } + private fun registerCallback() { registerBannerPageChangeCallback() @@ -483,8 +478,5 @@ class DiscoverFragment : BindingFragment(R.layout.fragm private const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" private const val EXTRA_ROOT_SCREEN = "rootScreen" const val EXTRA_EDITABLE_DISCOVER_COURSE = "editable_discover_course" - - const val EVENT_CLICK_UPLOAD_BUTTON = "click_upload_button" - const val EVENT_CLICK_TRY_SEARCH_COURSE = "click_try_search_course" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt index 02696dd35..e0aebe72c 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt @@ -11,9 +11,6 @@ import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.fragment.app.commit import androidx.fragment.app.replace -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.kakao.sdk.common.util.KakaoCustomTabsClient import com.kakao.sdk.talk.TalkApiClient import com.runnect.runnect.BuildConfig @@ -29,6 +26,9 @@ 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 @@ -38,10 +38,8 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ private val viewModel: MyPageViewModel by activityViewModels() private lateinit var resultEditNameLauncher: ActivityResultLauncher var isVisitorMode: Boolean = MainActivity.isVisitorMode - private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - initFirebaseAnalytics() if (isVisitorMode) { activateVisitorMode() } else { @@ -50,10 +48,6 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } - private fun activateVisitorMode() { with(binding) { ivVisitorMode.isVisible = true @@ -194,10 +188,5 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ const val EXTRA_NICK_NAME = "nickname" const val EXTRA_PROFILE = "profile_img" const val ACCOUNT_INFO_TAG = "accountInfo" - - const val EVENT_CLICK_RUNNING_RECORD = "click_running_record" - const val EVENT_CLICK_GOAL_REWARD = "click_goal_reward" - const val EVENT_CLICK_UPLOADED_COURSE = "click_uploaded_course" - } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt index 7d60d64b1..f21edbb5e 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/history/MyHistoryActivity.kt @@ -9,9 +9,6 @@ import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.data.dto.HistoryInfoDTO @@ -21,6 +18,7 @@ import com.runnect.runnect.presentation.mypage.history.detail.MyHistoryDetailAct import com.runnect.runnect.presentation.search.SearchActivity import com.runnect.runnect.presentation.state.UiState 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 @@ -36,14 +34,12 @@ class MyHistoryActivity : BindingActivity(R.layout.act private val viewModel: MyHistoryViewModel by viewModels() private lateinit var adapter: MyHistoryAdapter private lateinit var dialog: AlertDialog - private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this initLayout() - initFirebaseAnalytics() addListener() addObserver() initDialog() @@ -64,10 +60,6 @@ class MyHistoryActivity : BindingActivity(R.layout.act binding.rvMyPageHistory.addItemDecoration(RecyclerOffsetDecorationHeight(this, 10)) } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } - private fun getRecord() { viewModel.getRecord() } @@ -265,7 +257,5 @@ class MyHistoryActivity : BindingActivity(R.layout.act const val DELETE_BTN = "삭제하기" const val EXTRA_HISTORY_DATA = "historyData" const val BUNDLE_HISTORY = "historyDataBundle" - - const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "click_course_drawing_in_running_record" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt index 4d3720110..303f11fb9 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/MySettingFragment.kt @@ -8,9 +8,6 @@ import androidx.activity.OnBackPressedCallback import androidx.core.view.isVisible import androidx.fragment.app.commit import androidx.fragment.app.replace -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.BuildConfig import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment @@ -20,17 +17,13 @@ import com.runnect.runnect.presentation.mypage.setting.accountinfo.MySettingAcco import com.runnect.runnect.util.extension.showWebBrowser class MySettingFragment : BindingFragment(R.layout.fragment_my_setting) { - private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - initFirebaseAnalytics() addListener() setVisibleDeveloperMode() registerBackPressedCallback() } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } + private fun registerBackPressedCallback() { val callback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt index 294c315be..9f9e40d6a 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt @@ -10,9 +10,6 @@ import androidx.core.view.isVisible import androidx.fragment.app.commit import androidx.fragment.app.replace import androidx.fragment.app.viewModels -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.application.PreferenceManager import com.runnect.runnect.binding.BindingFragment @@ -21,6 +18,10 @@ 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 @@ -33,7 +34,6 @@ class MySettingAccountInfoFragment : BindingFragment(R.layout.fragment_my_setting_account_info) { private lateinit var logoutDialog: AlertDialog private lateinit var withdrawalDialog: AlertDialog - private lateinit var firebaseAnalytics: FirebaseAnalytics private val viewModel: MySettingAccountInfoViewModel by viewModels() private val backPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { @@ -49,7 +49,6 @@ class MySettingAccountInfoFragment : initLogoutDialog() setLogoutDialogClickEvent() initWithdrawalDialog() - initFirebaseAnalytics() setWithdrawalDialogClickEvent() } @@ -57,10 +56,6 @@ class MySettingAccountInfoFragment : setEmailFromMySetting() } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } - private fun addListener() { binding.ivSettingAccountInfoBack.setOnClickListener { moveToMySetting() @@ -174,11 +169,5 @@ class MySettingAccountInfoFragment : const val DESCRIPTION_WITHDRAWAL_NO = "아니오" const val TOKEN_KEY_ACCESS = "access" const val TOKEN_KEY_REFRESH = "refresh" - - const val EVENT_VIEW_SUCCESS_LOGOUT = "view_success_logout" - const val EVENT_CLICK_TRY_LOGOUT = "click_try_logout" - const val EVENT_VIEW_SUCCESS_WITHDRAW = "view_success_withdraw" - const val EVENT_CLICK_TRY_WITHDRAW = "click_try_withdraw" - } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt index 035e66fac..120d8d75d 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/upload/MyUploadActivity.kt @@ -9,9 +9,6 @@ import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels import androidx.core.view.isVisible import androidx.recyclerview.widget.GridLayoutManager -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.databinding.ActivityMyUploadBinding @@ -21,6 +18,7 @@ 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.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 @@ -37,14 +35,12 @@ class MyUploadActivity : BindingActivity(R.layout.activ private val viewModel: MyUploadViewModel by viewModels() private lateinit var adapter: MyUploadAdapter private lateinit var dialog: AlertDialog - private lateinit var firebaseAnalytics: FirebaseAnalytics override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this viewModel.getUserUploadCourse() - initFirebaseAnalytics() initLayout() addListener() addObserver() @@ -57,9 +53,6 @@ class MyUploadActivity : BindingActivity(R.layout.activ initRecyclerView() } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } private fun initRecyclerView() { binding.rvMyPageUpload.layoutManager = GridLayoutManager(this, 2) @@ -278,7 +271,5 @@ class MyUploadActivity : BindingActivity(R.layout.activ const val DELETE_BTN = "삭제하기" const val EXTRA_PUBLIC_COURSE_ID = "publicCourseId" const val EXTRA_ROOT_SCREEN = "rootScreen" - - const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "click_course_upload_in_uploaded_course" } } \ No newline at end of file diff --git a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt index ce4d66c05..b7576fb0a 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMainFragment.kt @@ -9,29 +9,25 @@ import androidx.fragment.app.commit import androidx.fragment.app.replace import androidx.fragment.app.viewModels import com.google.android.material.tabs.TabLayout -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentStorageMainBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.login.LoginActivity -import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START +import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_SCRAP_COURSE import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber @AndroidEntryPoint class StorageMainFragment : BindingFragment(R.layout.fragment_storage_main) { - private lateinit var firebaseAnalytics: FirebaseAnalytics val viewModel: StorageViewModel by viewModels() var isVisitorMode: Boolean = MainActivity.isVisitorMode override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - initFirebaseAnalytics() if (isVisitorMode) { activateVisitorMode() } else { @@ -75,17 +71,15 @@ class StorageMainFragment : } } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } - private fun tabLayoutAction() { binding.storageTab.addOnTabSelectedListener( object : TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab?) { when (tab?.position) { 0 -> childFragmentManager.commit { - Analytics.logClickedItemEvent(EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START) + Analytics.logClickedItemEvent( + EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START + ) replace(R.id.fl_main) Timber.tag("hu").d("내가 그린 코스로 이동하였음") } @@ -111,9 +105,4 @@ class StorageMainFragment : } ) } - companion object { - const val EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START= "click_my_storage_course_drawing_start" - const val EVENT_CLICK_SCRAP_COURSE = "click_scrap_course" - } - } diff --git a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt index d37a35cf5..6a78e36ba 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/storage/StorageMyDrawFragment.kt @@ -13,19 +13,16 @@ import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.bottomnavigation.BottomNavigationView -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.analytics.ktx.analytics -import com.google.firebase.ktx.Firebase import com.runnect.runnect.R import com.runnect.runnect.binding.BindingFragment import com.runnect.runnect.databinding.FragmentStorageMyDrawBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.mydrawdetail.MyDrawDetailActivity -import com.runnect.runnect.presentation.mypage.upload.MyUploadActivity import com.runnect.runnect.presentation.search.SearchActivity import com.runnect.runnect.presentation.state.UiState import com.runnect.runnect.presentation.storage.adapter.StorageMyDrawAdapter import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.EVENT_MY_STORAGE_TRY_REMOVE import com.runnect.runnect.util.callback.ItemCount import com.runnect.runnect.util.callback.listener.OnMyDrawItemClick import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration @@ -39,8 +36,6 @@ import timber.log.Timber class StorageMyDrawFragment : BindingFragment(R.layout.fragment_storage_my_draw), OnMyDrawItemClick, ItemCount { - - private lateinit var firebaseAnalytics: FirebaseAnalytics val viewModel: StorageViewModel by viewModels() lateinit var storageMyDrawAdapter: StorageMyDrawAdapter @@ -66,7 +61,6 @@ class StorageMyDrawFragment : initLayout() binding.lifecycleOwner = requireActivity() initAdapter() - initFirebaseAnalytics() editCourse() getCourse() requireCourse() @@ -102,9 +96,6 @@ class StorageMyDrawFragment : binding.recyclerViewStorageMyDraw.adapter = storageMyDrawAdapter } - private fun initFirebaseAnalytics() { - firebaseAnalytics = Firebase.analytics - } fun hideBottomNav() { animDown = AnimationUtils.loadAnimation(requireActivity(), R.anim.slide_out_down) @@ -367,8 +358,5 @@ class StorageMyDrawFragment : const val EXTRA_COURSE_ID = "courseId" const val EXTRA_ROOT_SCREEN = "rootScreen" const val EDIT_MODE = "선택" - const val EVENT_MY_STORAGE_TRY_MODIFY = "click_my_storage_try_modify" - const val EVENT_MY_STORAGE_TRY_REMOVE = "click_my_storage_try_remove" - } } diff --git a/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt new file mode 100644 index 000000000..485e3be8b --- /dev/null +++ b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt @@ -0,0 +1,31 @@ +package com.runnect.runnect.util.analytics + +object EventName { + // Discover + const val EVENT_CLICK_UPLOAD_BUTTON = "click_upload_button" + const val EVENT_CLICK_TRY_SEARCH_COURSE = "click_try_search_course" + + // MyPage + const val EVENT_CLICK_RUNNING_RECORD = "click_running_record" + const val EVENT_CLICK_GOAL_REWARD = "click_goal_reward" + const val EVENT_CLICK_UPLOADED_COURSE = "click_uploaded_course" + + // MyHistory + const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "click_course_drawing_in_running_record" + + // MySettingAccountInfo + const val EVENT_VIEW_SUCCESS_LOGOUT = "view_success_logout" + const val EVENT_CLICK_TRY_LOGOUT = "click_try_logout" + const val EVENT_VIEW_SUCCESS_WITHDRAW = "view_success_withdraw" + const val EVENT_CLICK_TRY_WITHDRAW = "click_try_withdraw" + + // MyUpload + const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "click_course_upload_in_uploaded_course" + + // StorageMain + const val EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START= "click_my_storage_course_drawing_start" + const val EVENT_CLICK_SCRAP_COURSE = "click_scrap_course" + + // StorageMyDraw + const val EVENT_MY_STORAGE_TRY_REMOVE = "click_my_storage_try_remove" +} \ No newline at end of file From c05cbe4aeb5e7468ff49c37a66f70dbca70432eb Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sun, 11 Feb 2024 12:19:10 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[ADD]=20#315=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EB=B0=9C=EA=B2=AC=20=EB=82=98=EB=A8=B8=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=ED=83=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/CourseDetailActivity.kt | 8 +++++++ .../presentation/discover/DiscoverFragment.kt | 21 +++++++++++++++++-- .../discover/search/DiscoverSearchActivity.kt | 8 +++++-- .../discover/upload/DiscoverUploadActivity.kt | 7 ++++++- .../presentation/profile/ProfileActivity.kt | 3 +++ .../runnect/util/analytics/EventName.kt | 20 +++++++++++++++--- 6 files changed, 59 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/detail/CourseDetailActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/detail/CourseDetailActivity.kt index 59c90fde6..d67dd2ab8 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/detail/CourseDetailActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/detail/CourseDetailActivity.kt @@ -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 @@ -84,6 +88,8 @@ class CourseDetailActivity : binding.vm = viewModel binding.lifecycleOwner = this + Analytics.logClickedItemEvent(VIEW_COURSE_DETAIL) + initIntentExtraData() updatePublicCourseIdFromDeepLink() getCourseDetail() @@ -142,6 +148,7 @@ class CourseDetailActivity : startActivity(this) } applyScreenEnterAnimation() + Analytics.logClickedItemEvent(EVENT_CLICK_USER_PROFILE) } private fun handleBackButtonByCurrentScreenMode() { @@ -238,6 +245,7 @@ class CourseDetailActivity : desc = courseDetail.description, image = courseDetail.image ) + Analytics.logClickedItemEvent(EVENT_CLICK_SHARE) } } diff --git a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt index 4e48e08b7..e16b446a8 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/discover/DiscoverFragment.kt @@ -17,17 +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 @@ -39,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(R.layout.fragment_discover) { @@ -97,12 +104,22 @@ class DiscoverFragment : BindingFragment(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 { @@ -236,7 +253,6 @@ class DiscoverFragment : BindingFragment(R.layout.fragm private fun initSearchButtonClickListener() { val context = context ?: return binding.ivDiscoverSearch.setOnClickListener { - Analytics.logClickedItemEvent(EVENT_CLICK_TRY_SEARCH_COURSE) startActivity(Intent(context, DiscoverSearchActivity::class.java)) activity?.applyScreenEnterAnimation() } @@ -311,6 +327,7 @@ class DiscoverFragment : BindingFragment(R.layout.fragm banners = banners, onBannerItemClick = { url -> showPromotionWebsite(url) + Analytics.logClickedItemEvent(EVENT_CLICK_TRY_BANNER) } ).apply { binding.vpDiscoverBanner.adapter = this diff --git a/app/src/main/java/com/runnect/runnect/presentation/discover/search/DiscoverSearchActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/discover/search/DiscoverSearchActivity.kt index d93179ddc..993c2c953 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/discover/search/DiscoverSearchActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/discover/search/DiscoverSearchActivity.kt @@ -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 @@ -52,7 +55,7 @@ class DiscoverSearchActivity : super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this@DiscoverSearchActivity - + Analytics.logClickedItemEvent(VIEW_COURSE_SEARCH) showSearchKeyboard() initSearchAdapter() initSearchRecyclerView() @@ -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) } diff --git a/app/src/main/java/com/runnect/runnect/presentation/discover/upload/DiscoverUploadActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/discover/upload/DiscoverUploadActivity.kt index 7dbce9df4..2131dd7d8 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/discover/upload/DiscoverUploadActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/discover/upload/DiscoverUploadActivity.kt @@ -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 @@ -27,7 +30,7 @@ class DiscoverUploadActivity : super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this - + Analytics.logClickedItemEvent(VIEW_COURSE_UPLOAD) initLayout() addListener() addObserver() @@ -54,6 +57,7 @@ class DiscoverUploadActivity : if (it.isActivated) { viewModel.postUploadMyCourse() } + Analytics.logClickedItemEvent(EVENT_CLICK_COURSE_UPLOAD) } //키보드 이벤트에 따른 동작 정의 binding.root.viewTreeObserver.addOnGlobalLayoutListener { @@ -84,6 +88,7 @@ class DiscoverUploadActivity : UiState.Success -> { handleReturnToDiscover() } + UiState.Failure -> { binding.indeterminateBar.isVisible = false Timber.tag(ContentValues.TAG) diff --git a/app/src/main/java/com/runnect/runnect/presentation/profile/ProfileActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/profile/ProfileActivity.kt index 21d30c6d7..5781284a3 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/profile/ProfileActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/profile/ProfileActivity.kt @@ -9,6 +9,8 @@ import com.runnect.runnect.binding.BindingActivity import com.runnect.runnect.databinding.ActivityProfileBinding import com.runnect.runnect.presentation.detail.CourseDetailActivity import com.runnect.runnect.presentation.state.UiStateV2 +import com.runnect.runnect.util.analytics.Analytics +import com.runnect.runnect.util.analytics.EventName.VIEW_USER_PROFILE import com.runnect.runnect.util.extension.applyScreenEnterAnimation import com.runnect.runnect.util.extension.showSnackbar import dagger.hilt.android.AndroidEntryPoint @@ -22,6 +24,7 @@ class ProfileActivity : BindingActivity(R.layout.activit super.onCreate(savedInstanceState) binding.vm = viewModel binding.lifecycleOwner = this + Analytics.logClickedItemEvent(VIEW_USER_PROFILE) initAdapter() addListener() addObserver() diff --git a/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt index 485e3be8b..9dda34dca 100644 --- a/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt +++ b/app/src/main/java/com/runnect/runnect/util/analytics/EventName.kt @@ -3,7 +3,18 @@ package com.runnect.runnect.util.analytics object EventName { // Discover const val EVENT_CLICK_UPLOAD_BUTTON = "click_upload_button" + const val EVENT_CLICK_DATE = "click_date_sort" + const val EVENT_CLICK_SCRAP = "click_scrap_sort" + const val EVENT_CLICK_TRY_BANNER = "click_try_banner" const val EVENT_CLICK_TRY_SEARCH_COURSE = "click_try_search_course" + const val EVENT_CLICK_SHARE = "click_share" + const val EVENT_CLICK_USER_PROFILE = "click_user_profile" + const val EVENT_CLICK_COURSE_UPLOAD = "click_course_upload" + + const val VIEW_COURSE_SEARCH = "view_course_search" + const val VIEW_COURSE_DETAIL = "view_course_detail" + const val VIEW_USER_PROFILE = "view_user_profile" + const val VIEW_COURSE_UPLOAD = "view_course_upload" // MyPage const val EVENT_CLICK_RUNNING_RECORD = "click_running_record" @@ -11,7 +22,8 @@ object EventName { const val EVENT_CLICK_UPLOADED_COURSE = "click_uploaded_course" // MyHistory - const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = "click_course_drawing_in_running_record" + const val EVENT_CLICK_COURSE_DRAWING_IN_RUNNING_RECORD = + "click_course_drawing_in_running_record" // MySettingAccountInfo const val EVENT_VIEW_SUCCESS_LOGOUT = "view_success_logout" @@ -20,10 +32,12 @@ object EventName { const val EVENT_CLICK_TRY_WITHDRAW = "click_try_withdraw" // MyUpload - const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = "click_course_upload_in_uploaded_course" + const val EVENT_CLICK_COURSE_UPLOAD_IN_UPLOADED_COURSE = + "click_course_upload_in_uploaded_course" // StorageMain - const val EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START= "click_my_storage_course_drawing_start" + const val EVENT_CLICK_MY_DRAW_STORAGE_COURSE_DRAWING_START = + "click_my_storage_course_drawing_start" const val EVENT_CLICK_SCRAP_COURSE = "click_scrap_course" // StorageMyDraw