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() {
super.onPause()
screenEvent?.send(analyticsTracker)
screenEvent?.send(analyticsTracker, analyticsScreenName)
Timber.i("onPause Activity ${javaClass.simpleName}")
rageShake.stop()

View file

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

View file

@ -30,7 +30,11 @@ class ScreenEvent(val screenName: Screen.ScreenName) {
// Protection to avoid multiple sending
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) {
Timber.w("Event $screenName Already sent!")
return
@ -38,7 +42,7 @@ class ScreenEvent(val screenName: Screen.ScreenName) {
isSent = true
analyticsTracker.screen(
Screen(
screenName = screenName,
screenName = screenNameOverride ?: screenName,
durationMs = (SystemClock.elapsedRealtime() - startTime).toInt()
)
)

View file

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