Analytics: login/register screens

This commit is contained in:
Benoit Marty 2021-12-30 18:03:04 +01:00 committed by Benoit Marty
parent 54108b8f8d
commit 1e3733fe8e
4 changed files with 29 additions and 26 deletions

View file

@ -373,7 +373,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
screenEvent?.send(analyticsTracker) screenEvent?.send(analyticsTracker, analyticsScreenName)
Timber.i("onPause Activity ${javaClass.simpleName}") Timber.i("onPause Activity ${javaClass.simpleName}")
rageShake.stop() rageShake.stop()

View file

@ -43,6 +43,11 @@ data class Screen(
*/ */
DeactivateAccount, DeactivateAccount,
/**
* The form for the forgot password use case
*/
ForgotPassword,
/** /**
* Legacy: The screen that shows information about a specific group. * Legacy: The screen that shows information about a specific group.
*/ */
@ -53,6 +58,11 @@ data class Screen(
*/ */
Home, Home,
/**
* The screen that displays the login flow (when the user already has an account).
*/
Login,
/** /**
* The screen that displays the user's breadcrumbs. * The screen that displays the user's breadcrumbs.
*/ */
@ -73,11 +83,6 @@ data class Screen(
*/ */
MobileInviteFriends, MobileInviteFriends,
/**
* The screen that displays the login flow.
*/
MobileLogin,
/** /**
* The People tab on mobile that lists all the DM rooms you have joined. * The People tab on mobile that lists all the DM rooms you have joined.
*/ */
@ -123,6 +128,11 @@ data class Screen(
*/ */
MyGroups, MyGroups,
/**
* The screen that displays the registration flow (when the user wants to create an account)
*/
Register,
/** /**
* The screen that displays the messages and events received in a room. * The screen that displays the messages and events received in a room.
*/ */
@ -208,35 +218,20 @@ data class Screen(
*/ */
WebE2ESetup, WebE2ESetup,
/**
* ?
*/
WebForgotPassword,
/** /**
* ? * ?
*/ */
WebLoading, WebLoading,
/**
* ?
*/
WebLogin,
/**
* ?
*/
WebRegister,
/** /**
* ? * ?
*/ */
WebSoftLogout, WebSoftLogout,
/** /**
* ? * The splash screen.
*/ */
WebWelcome, Welcome,
} }
override fun getName() = screenName.name override fun getName() = screenName.name

View file

@ -30,7 +30,11 @@ class ScreenEvent(val screenName: Screen.ScreenName) {
// Protection to avoid multiple sending // Protection to avoid multiple sending
private var isSent = false private var isSent = false
fun send(analyticsTracker: AnalyticsTracker) { /**
* @param screenNameOverride can be used to override the screen name passed in constructor parameter
*/
fun send(analyticsTracker: AnalyticsTracker,
screenNameOverride: Screen.ScreenName? = null) {
if (isSent) { if (isSent) {
Timber.w("Event $screenName Already sent!") Timber.w("Event $screenName Already sent!")
return return
@ -38,7 +42,7 @@ class ScreenEvent(val screenName: Screen.ScreenName) {
isSent = true isSent = true
analyticsTracker.screen( analyticsTracker.screen(
Screen( Screen(
screenName = screenName, screenName = screenNameOverride ?: screenName,
durationMs = (SystemClock.elapsedRealtime() - startTime).toInt() durationMs = (SystemClock.elapsedRealtime() - startTime).toInt()
) )
) )

View file

@ -83,7 +83,7 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), ToolbarCo
override fun getCoordinatorLayout() = views.coordinatorLayout override fun getCoordinatorLayout() = views.coordinatorLayout
override fun initUiAndData() { override fun initUiAndData() {
analyticsScreenName = Screen.ScreenName.MobileLogin analyticsScreenName = Screen.ScreenName.Login
if (isFirstCreation()) { if (isFirstCreation()) {
addFirstFragment() addFirstFragment()
@ -203,6 +203,10 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), ToolbarCo
private fun updateWithState(loginViewState: LoginViewState) { private fun updateWithState(loginViewState: LoginViewState) {
if (loginViewState.isUserLogged()) { if (loginViewState.isUserLogged()) {
if (loginViewState.signMode == SignMode.SignUp) {
// change the screen name
analyticsScreenName = Screen.ScreenName.Register
}
val intent = HomeActivity.newIntent( val intent = HomeActivity.newIntent(
this, this,
accountCreation = loginViewState.signMode == SignMode.SignUp accountCreation = loginViewState.signMode == SignMode.SignUp