mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-24 16:51:07 +01:00
Merge pull request #5257 from vector-im/feature/nfe/track_screen_on_enter
track screen event when user enters the screen
This commit is contained in:
commit
33e5a9c2ef
1
changelog.d/5256.misc
Normal file
1
changelog.d/5256.misc
Normal file
@ -0,0 +1 @@
|
||||
Analytics screen events are now tracked on screen enter instead of screen leave
|
@ -68,7 +68,6 @@ import im.vector.app.features.MainActivity
|
||||
import im.vector.app.features.MainActivityArgs
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import im.vector.app.features.configuration.VectorConfiguration
|
||||
import im.vector.app.features.consent.ConsentNotGivenHelper
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
@ -98,7 +97,6 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
||||
* ========================================================================================== */
|
||||
|
||||
protected var analyticsScreenName: MobileScreen.ScreenName? = null
|
||||
private var screenEvent: ScreenEvent? = null
|
||||
|
||||
protected lateinit var analyticsTracker: AnalyticsTracker
|
||||
|
||||
@ -337,7 +335,9 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Timber.i("onResume Activity ${javaClass.simpleName}")
|
||||
screenEvent = analyticsScreenName?.let { ScreenEvent(it) }
|
||||
analyticsScreenName?.let {
|
||||
analyticsTracker.screen(MobileScreen(screenName = it))
|
||||
}
|
||||
configurationViewModel.onActivityResumed()
|
||||
|
||||
if (this !is BugReportActivity && vectorPreferences.useRageshake()) {
|
||||
@ -376,7 +376,6 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
screenEvent?.send(analyticsTracker, analyticsScreenName)
|
||||
Timber.i("onPause Activity ${javaClass.simpleName}")
|
||||
|
||||
rageShake.stop()
|
||||
|
@ -39,7 +39,6 @@ import im.vector.app.core.extensions.toMvRxBundle
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import reactivecircus.flowbinding.android.view.clicks
|
||||
@ -54,7 +53,6 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe
|
||||
* ========================================================================================== */
|
||||
|
||||
protected var analyticsScreenName: MobileScreen.ScreenName? = null
|
||||
private var screenEvent: ScreenEvent? = null
|
||||
|
||||
protected lateinit var analyticsTracker: AnalyticsTracker
|
||||
|
||||
@ -139,12 +137,9 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Timber.i("onResume BottomSheet ${javaClass.simpleName}")
|
||||
screenEvent = analyticsScreenName?.let { ScreenEvent(it) }
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
screenEvent?.send(analyticsTracker)
|
||||
analyticsScreenName?.let {
|
||||
analyticsTracker.screen(MobileScreen(screenName = it))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
@ -45,7 +45,6 @@ import im.vector.app.core.extensions.toMvRxBundle
|
||||
import im.vector.app.core.utils.ToolbarConfig
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.lib.ui.styles.dialogs.MaterialProgressDialog
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
@ -59,7 +58,6 @@ abstract class VectorBaseFragment<VB : ViewBinding> : Fragment(), MavericksView
|
||||
* ========================================================================================== */
|
||||
|
||||
protected var analyticsScreenName: MobileScreen.ScreenName? = null
|
||||
private var screenEvent: ScreenEvent? = null
|
||||
|
||||
protected lateinit var analyticsTracker: AnalyticsTracker
|
||||
|
||||
@ -145,14 +143,15 @@ abstract class VectorBaseFragment<VB : ViewBinding> : Fragment(), MavericksView
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Timber.i("onResume Fragment ${javaClass.simpleName}")
|
||||
screenEvent = analyticsScreenName?.let { ScreenEvent(it) }
|
||||
analyticsScreenName?.let {
|
||||
analyticsTracker.screen(MobileScreen(screenName = it))
|
||||
}
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
Timber.i("onPause Fragment ${javaClass.simpleName}")
|
||||
screenEvent?.send(analyticsTracker)
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.analytics.screen
|
||||
|
||||
import android.os.SystemClock
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Track a screen display. Unique usage.
|
||||
*/
|
||||
class ScreenEvent(val screenName: MobileScreen.ScreenName) {
|
||||
private val startTime = SystemClock.elapsedRealtime()
|
||||
|
||||
// Protection to avoid multiple sending
|
||||
private var isSent = false
|
||||
|
||||
/**
|
||||
* @param screenNameOverride can be used to override the screen name passed in constructor parameter
|
||||
*/
|
||||
fun send(analyticsTracker: AnalyticsTracker,
|
||||
screenNameOverride: MobileScreen.ScreenName? = null) {
|
||||
if (isSent) {
|
||||
Timber.w("Event $screenName Already sent!")
|
||||
return
|
||||
}
|
||||
isSent = true
|
||||
analyticsTracker.screen(
|
||||
MobileScreen(
|
||||
screenName = screenNameOverride ?: screenName,
|
||||
durationMs = (SystemClock.elapsedRealtime() - startTime).toInt()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -41,7 +41,6 @@ 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.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
class DialPadFragment : Fragment(), TextWatcher {
|
||||
@ -66,15 +65,9 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||
analyticsTracker = singletonEntryPoint.analyticsTracker()
|
||||
}
|
||||
|
||||
private var screenEvent: ScreenEvent? = null
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
screenEvent = ScreenEvent(MobileScreen.ScreenName.Dialpad)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
screenEvent?.send(analyticsTracker)
|
||||
analyticsTracker.screen(MobileScreen(screenName = MobileScreen.ScreenName.Dialpad))
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -49,7 +49,6 @@ import im.vector.app.features.MainActivity
|
||||
import im.vector.app.features.MainActivityArgs
|
||||
import im.vector.app.features.analytics.accountdata.AnalyticsAccountDataViewModel
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import im.vector.app.features.disclaimer.showDisclaimerDialog
|
||||
import im.vector.app.features.matrixto.MatrixToBottomSheet
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
@ -163,14 +162,8 @@ class HomeActivity :
|
||||
}
|
||||
|
||||
private val drawerListener = object : DrawerLayout.SimpleDrawerListener() {
|
||||
private var drawerScreenEvent: ScreenEvent? = null
|
||||
override fun onDrawerOpened(drawerView: View) {
|
||||
drawerScreenEvent = ScreenEvent(MobileScreen.ScreenName.Sidebar)
|
||||
}
|
||||
|
||||
override fun onDrawerClosed(drawerView: View) {
|
||||
drawerScreenEvent?.send(analyticsTracker)
|
||||
drawerScreenEvent = null
|
||||
analyticsTracker.screen(MobileScreen(screenName = MobileScreen.ScreenName.Sidebar))
|
||||
}
|
||||
|
||||
override fun onDrawerStateChanged(newState: Int) {
|
||||
|
@ -36,7 +36,6 @@ import im.vector.app.core.extensions.replaceFragment
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivityRoomDetailBinding
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import im.vector.app.features.home.room.breadcrumbs.BreadcrumbsFragment
|
||||
import im.vector.app.features.home.room.detail.arguments.TimelineArgs
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker
|
||||
@ -158,14 +157,8 @@ class RoomDetailActivity :
|
||||
}
|
||||
|
||||
private val drawerListener = object : DrawerLayout.SimpleDrawerListener() {
|
||||
private var drawerScreenEvent: ScreenEvent? = null
|
||||
override fun onDrawerOpened(drawerView: View) {
|
||||
drawerScreenEvent = ScreenEvent(MobileScreen.ScreenName.Breadcrumbs)
|
||||
}
|
||||
|
||||
override fun onDrawerClosed(drawerView: View) {
|
||||
drawerScreenEvent?.send(analyticsTracker)
|
||||
drawerScreenEvent = null
|
||||
analyticsTracker.screen(MobileScreen(screenName = MobileScreen.ScreenName.Breadcrumbs))
|
||||
}
|
||||
|
||||
override fun onDrawerStateChanged(newState: Int) {
|
||||
|
@ -31,7 +31,6 @@ import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.core.utils.toast
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.screen.ScreenEvent
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
@ -44,7 +43,6 @@ abstract class VectorSettingsBaseFragment : PreferenceFragmentCompat(), Maverick
|
||||
* ========================================================================================== */
|
||||
|
||||
protected var analyticsScreenName: MobileScreen.ScreenName? = null
|
||||
private var screenEvent: ScreenEvent? = null
|
||||
|
||||
protected lateinit var analyticsTracker: AnalyticsTracker
|
||||
|
||||
@ -91,17 +89,14 @@ abstract class VectorSettingsBaseFragment : PreferenceFragmentCompat(), Maverick
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Timber.i("onResume Fragment ${javaClass.simpleName}")
|
||||
screenEvent = analyticsScreenName?.let { ScreenEvent(it) }
|
||||
analyticsScreenName?.let {
|
||||
analyticsTracker.screen(MobileScreen(screenName = it))
|
||||
}
|
||||
vectorActivity.supportActionBar?.setTitle(titleRes)
|
||||
// find the view from parent activity
|
||||
mLoadingView = vectorActivity.findViewById(R.id.vector_settings_spinner_views)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
screenEvent?.send(analyticsTracker)
|
||||
}
|
||||
|
||||
abstract fun bindPref()
|
||||
|
||||
abstract var titleRes: Int
|
||||
|
Loading…
Reference in New Issue
Block a user