From 54108b8f8dd2fcd01fd1ba6baa43fc8962bbe57a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 15 Dec 2021 16:59:05 +0100 Subject: [PATCH] Analytics: Track some screen (#4715) --- .../features/call/dialpad/DialPadFragment.kt | 24 +++++++++++++++++++ .../room/filtered/FilteredRoomsActivity.kt | 2 ++ .../app/features/login/LoginActivity.kt | 3 +++ 3 files changed, 29 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadFragment.kt b/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadFragment.kt index 16e7c01b5c..5fc866a4dd 100644 --- a/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadFragment.kt +++ b/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadFragment.kt @@ -17,6 +17,7 @@ package im.vector.app.features.call.dialpad import android.content.ClipboardManager +import android.content.Context import android.content.res.ColorStateList import android.os.Bundle import android.telephony.PhoneNumberFormattingTextWatcher @@ -37,6 +38,10 @@ import androidx.fragment.app.Fragment import com.android.dialer.dialpadview.DialpadView import com.android.dialer.dialpadview.DigitsEditText import im.vector.app.R +import im.vector.app.core.extensions.singletonEntryPoint +import im.vector.app.features.analytics.AnalyticsTracker +import im.vector.app.features.analytics.plan.Screen +import im.vector.app.features.analytics.screen.ScreenEvent import im.vector.app.features.themes.ThemeUtils class DialPadFragment : Fragment(), TextWatcher { @@ -53,6 +58,25 @@ class DialPadFragment : Fragment(), TextWatcher { private var enableDelete = true private var enableFabOk = true + private lateinit var analyticsTracker: AnalyticsTracker + + override fun onAttach(context: Context) { + super.onAttach(context) + val singletonEntryPoint = context.singletonEntryPoint() + analyticsTracker = singletonEntryPoint.analyticsTracker() + } + + private var screenEvent: ScreenEvent? = null + override fun onResume() { + super.onResume() + screenEvent = ScreenEvent(Screen.ScreenName.MobileDialpad) + } + + override fun onPause() { + super.onPause() + screenEvent?.send(analyticsTracker) + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt index 5f8ccc794a..dbfa319b86 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt @@ -24,6 +24,7 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityFilteredRoomsBinding +import im.vector.app.features.analytics.plan.Screen import im.vector.app.features.home.RoomListDisplayMode import im.vector.app.features.home.room.list.RoomListFragment import im.vector.app.features.home.room.list.RoomListParams @@ -42,6 +43,7 @@ class FilteredRoomsActivity : VectorBaseActivity() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + analyticsScreenName = Screen.ScreenName.RoomFilter configureToolbar(views.filteredRoomsToolbar) if (isFirstCreation()) { val params = RoomListParams(RoomListDisplayMode.FILTERED) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index 5ab08ffff7..df0ab4623e 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -40,6 +40,7 @@ import im.vector.app.core.extensions.exhaustive import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityLoginBinding +import im.vector.app.features.analytics.plan.Screen import im.vector.app.features.home.HomeActivity import im.vector.app.features.login.terms.LoginTermsFragment import im.vector.app.features.login.terms.LoginTermsFragmentArgument @@ -82,6 +83,8 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo override fun getCoordinatorLayout() = views.coordinatorLayout override fun initUiAndData() { + analyticsScreenName = Screen.ScreenName.MobileLogin + if (isFirstCreation()) { addFirstFragment() }