Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTUE - Sign up analytics #6042

Merged
merged 13 commits into from
Jun 6, 2022
Merged

FTUE - Sign up analytics #6042

merged 13 commits into from
Jun 6, 2022

Conversation

ouchadam
Copy link
Contributor

@ouchadam ouchadam commented May 13, 2022

Type of change

  • WIP Feature
  • Bugfix
  • Technical
  • Other :

Content

Fixes #5285

Adds SignUp event tracking after the user creates an account AND consents to tracking.

  • Creates an AuthenticationDescription abstraction and also sets the ground work for tracking sign in in the future.
  • Chains the AuthenticationDescription through to the HomeActivity in order to be tracked

Motivation and context

To enable the collection of sign up metrics (and sign up type)

Screenshots / GIFs

No UI changes

D/Analytics: capture(Signup(authenticationType=Password))

2022-05-13T09:09:08,565852105+01:00

Tests

  • With the combined login feature flag enabled
  • Create an account
  • Notice the SignUp tracking event in posthog

Tested devices

  • Physical
  • Emulator
  • OS version(s): 28

@ouchadam ouchadam added the Z-FTUE Issue is relevant to the first time use project or experience label May 13, 2022
@github-actions
Copy link

github-actions bot commented May 13, 2022

Unit Test Results

146 files  ±0  146 suites  ±0   2m 41s ⏱️ +9s
236 tests ±0  236 ✔️ ±0  0 💤 ±0  0 ±0 
788 runs  ±0  788 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit db3cb42. ± Comparison against base commit e6beb73.

♻️ This comment has been updated with latest results.

@ouchadam ouchadam force-pushed the feature/adm/ftue-analytics branch from 5391402 to 0999306 Compare May 17, 2022 09:46
@ouchadam ouchadam force-pushed the feature/adm/ftue-deeplinks branch from 48f0303 to 86c9e60 Compare May 25, 2022 12:36
Base automatically changed from feature/adm/ftue-deeplinks to develop May 31, 2022 08:30
@ouchadam ouchadam force-pushed the feature/adm/ftue-analytics branch 2 times, most recently from aea4d5e to 9878747 Compare May 31, 2022 10:01
@ouchadam ouchadam marked this pull request as ready for review May 31, 2022 10:01
@ouchadam ouchadam force-pushed the feature/adm/ftue-analytics branch from 62d9f72 to d002ab6 Compare June 1, 2022 08:11
@ouchadam ouchadam requested review from a team, bmarty and ericdecanini and removed request for a team June 1, 2022 08:11
@@ -113,9 +121,31 @@ class HomeActivityViewModel @AssistedInject constructor(
}
}
.launchIn(viewModelScope)

initialState.authenticationDescription?.let { recentAuthentication ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the view model handles the account sign up tracking (and potentially sign in in the future), if a authenticationDescription has been passed to the HomeActivity

@@ -202,11 +203,11 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment<FragmentLog
views.loginSocialLoginContainer.isVisible = true
views.loginSocialLoginButtons.ssoIdentityProviders = state.loginMode.ssoIdentityProviders?.sorted()
views.loginSocialLoginButtons.listener = object : SocialLoginButtonsView.InteractionListener {
override fun onProviderSelected(id: String?) {
override fun onProviderSelected(provider: SsoIdentityProvider?) {
Copy link
Contributor Author

@ouchadam ouchadam Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to know the SsoIdentityProvider in order to provide a tracking value (only used by the FTUE classes)

@@ -745,8 +754,12 @@ class OnboardingViewModel @AssistedInject constructor(
return loginConfig?.homeServerUrl
}

fun getSsoUrl(redirectUrl: String, deviceId: String?, providerId: String?): String? {
return authenticationService.getSsoUrl(redirectUrl, deviceId, providerId)
fun getSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
Copy link
Contributor Author

@ouchadam ouchadam Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about adding a side effect to store the current SSO Provider here but the activity results and web redirects lose the information about the currently selected SSO Provider

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly I think changing the name fetchSsoUrl would justify the side effect, since fetch communicates that it's more than just a simple getter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed! db3cb42

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few feedback.

@@ -113,9 +121,31 @@ class HomeActivityViewModel @AssistedInject constructor(
}
}
.launchIn(viewModelScope)

initialState.authenticationDescription?.let { recentAuthentication ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove this line and add null -> Unit case in the when below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -395,7 +425,7 @@ class HomeActivityViewModel @AssistedInject constructor(
HomeActivityViewActions.PushPromptHasBeenReviewed -> {
vectorPreferences.setDidAskUserToEnableSessionPush()
}
HomeActivityViewActions.ViewStarted -> {
is HomeActivityViewActions.ViewStarted -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not necessary I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! 6fcbd24 (originally the authentication description was held in the ViewStarted but develop moved the state to the initialState)

this,
accountCreation = loginViewState.signMode == SignMode.SignUp
)
val intent = HomeActivity.newIntent(this)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure to understand, why don't we pass a value for authenticationDescription param here?
Applicable to all HomeActivity.newIntent invocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because the sign up tracking has only been implemented for the FTUE flow, the previous accountCreation was unused , although now I can see that develop has changed make use of the flag for secure backup/cross signing

will look to reintroduce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@ericdecanini ericdecanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines 26 to 27
AuthenticationDescription.AuthenticationType.Github -> Signup.AuthenticationType.GitHub
AuthenticationDescription.AuthenticationType.Gitlab -> Signup.AuthenticationType.GitLab
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super optional nitpick

Suggested change
AuthenticationDescription.AuthenticationType.Github -> Signup.AuthenticationType.GitHub
AuthenticationDescription.AuthenticationType.Gitlab -> Signup.AuthenticationType.GitLab
AuthenticationDescription.AuthenticationType.GitHub -> Signup.AuthenticationType.GitHub
AuthenticationDescription.AuthenticationType.GitLab -> Signup.AuthenticationType.GitLab

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -745,8 +754,12 @@ class OnboardingViewModel @AssistedInject constructor(
return loginConfig?.homeServerUrl
}

fun getSsoUrl(redirectUrl: String, deviceId: String?, providerId: String?): String? {
return authenticationService.getSsoUrl(redirectUrl, deviceId, providerId)
fun getSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly I think changing the name fetchSsoUrl would justify the side effect, since fetch communicates that it's more than just a simple getter

…tains any data

- it's part of the initialstate instead
…uth description from the sign mode

- the type is set to other as the legacy viewmodel doesn't support tracking the sso provider
@ouchadam ouchadam merged commit a5f404f into develop Jun 6, 2022
@ouchadam ouchadam deleted the feature/adm/ftue-analytics branch June 6, 2022 12:52
@github-actions
Copy link

github-actions bot commented Jun 6, 2022

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    = passed=20 failures=0 errors=0 skipped=3
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-FTUE Issue is relevant to the first time use project or experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FTUE: Analytics tracking
3 participants