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

feat: Report Metric of Personal User creating a team in Countly (WPB-11318) #3552

Merged
merged 32 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
71f73a0
feat: personal to team migration flow
ohassine Oct 16, 2024
c8ae19e
feat: make some round corner shape
ohassine Oct 16, 2024
f2fe3fd
Merge branch 'develop' into team_upgrade_flow
ohassine Oct 16, 2024
e6ea363
chore: remove unused composable
ohassine Oct 18, 2024
8465e85
chore: add contentDescription
ohassine Oct 18, 2024
85d6c9f
Merge remote-tracking branch 'origin/develop' into team_upgrade_flow
ohassine Oct 21, 2024
c4c68eb
feat: open screen to create a team
ohassine Oct 21, 2024
58e8467
Merge branch 'develop' into team_upgrade_flow
ohassine Oct 22, 2024
c003dd4
chore: address comments
ohassine Oct 22, 2024
7b2eaca
Merge remote-tracking branch 'origin/team_upgrade_flow' into team_upg…
ohassine Oct 22, 2024
9832761
Merge branch 'develop' into team_upgrade_flow
ohassine Oct 22, 2024
065eb41
feat: Report Metric of Personal User creating a team in Countly
ohassine Oct 23, 2024
e8c230b
Merge remote-tracking branch 'origin/develop' into team_upgrade_countly
ohassine Oct 23, 2024
7f44fef
Merge remote-tracking branch 'origin/develop' into team_upgrade_countly
ohassine Oct 23, 2024
0bfe555
chore: detekt
ohassine Oct 23, 2024
d211b8e
chore: cleanup
ohassine Oct 23, 2024
885f69f
chore: unit test
ohassine Oct 24, 2024
05658c2
Merge remote-tracking branch 'origin/develop' into team_upgrade_countly
ohassine Oct 24, 2024
d4c5091
chore: detekt
ohassine Oct 24, 2024
002df22
chore: remove duplicated composable
ohassine Oct 24, 2024
70bd13c
chore: cleanup
ohassine Oct 24, 2024
b1e30c7
chore: cover TeamMigrationViewModel with unit test
ohassine Oct 24, 2024
48479aa
Merge branch 'develop' into team_upgrade_countly
ohassine Oct 24, 2024
1596206
chore: Empty-Commit
ohassine Oct 29, 2024
e018694
Merge remote-tracking branch 'origin/develop' into team_upgrade_countly
ohassine Oct 31, 2024
4a5f1a4
feat: send only the required segmentations
ohassine Oct 31, 2024
6332dfd
Merge remote-tracking branch 'origin/team_upgrade_countly' into team_…
ohassine Oct 31, 2024
87c88bf
feat: update default value
ohassine Oct 31, 2024
654afcd
feat: send segmentations
ohassine Oct 31, 2024
04cda67
feat: detekt
ohassine Oct 31, 2024
8e79ee9
Merge branch 'develop' into team_upgrade_countly
ohassine Oct 31, 2024
ebdfbb7
feat: unit test
ohassine Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class UserDataStore(private val context: Context, userId: UserId) {
}

fun isCreateTeamNoticeRead(): Flow<Boolean> = context.dataStore.data.map {
it[IS_CREATE_TEAM_NOTICE_READ] ?: true
it[IS_CREATE_TEAM_NOTICE_READ] ?: false
}

suspend fun setIsCreateTeamNoticeRead(isRead: Boolean) {
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
Expand Down Expand Up @@ -167,7 +166,10 @@ fun HomeScreen(
homeDrawerState = homeDrawerViewModel.drawerState,
homeStateHolder = homeScreenState,
onNewConversationClick = { navigator.navigate(NavigationCommand(NewConversationSearchPeopleScreenDestination)) },
onSelfUserClick = remember(navigator) { { navigator.navigate(NavigationCommand(SelfUserProfileScreenDestination)) } }
onSelfUserClick = {
homeViewModel.sendOpenProfileEvent()
navigator.navigate(NavigationCommand(SelfUserProfileScreenDestination))
}
)

BackHandler(homeScreenState.drawerState.isOpen) {
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/kotlin/com/wire/android/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

package com.wire.android.ui.home

import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.datastore.UserDataStore
import com.wire.android.feature.analytics.AnonymousAnalyticsManager
import com.wire.android.feature.analytics.model.AnalyticsEvent
import com.wire.android.migration.userDatabase.ShouldTriggerMigrationForUserUserCase
import com.wire.android.model.ImageAsset.UserAvatarAsset
import com.wire.android.model.NameBasedAvatar
Expand All @@ -51,9 +54,11 @@ class HomeViewModel @Inject constructor(
private val needsToRegisterClient: NeedsToRegisterClientUseCase,
private val observeLegalHoldStatusForSelfUser: ObserveLegalHoldStateForSelfUserUseCase,
private val wireSessionImageLoader: WireSessionImageLoader,
private val shouldTriggerMigrationForUser: ShouldTriggerMigrationForUserUserCase
private val shouldTriggerMigrationForUser: ShouldTriggerMigrationForUserUserCase,
private val analyticsManager: AnonymousAnalyticsManager
) : SavedStateViewModel(savedStateHandle) {

@VisibleForTesting
var homeState by mutableStateOf(HomeState())
private set

Expand Down Expand Up @@ -136,4 +141,8 @@ class HomeViewModel @Inject constructor(
homeState = homeState.copy(shouldDisplayWelcomeMessage = false)
}
}

fun sendOpenProfileEvent() {
analyticsManager.sendEvent(AnalyticsEvent.UserProfileOpened(homeState.shouldShowCreateTeamUnreadIndicator))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fun SelfUserProfileScreen(
navigator.navigate(NavigationCommand(SelfQRCodeScreenDestination(viewModelSelf.userProfileState.userName)))
},
onCreateAccount = {
viewModelSelf.sendPersonalToTeamMigrationEvent()
navigator.navigate(NavigationCommand(TeamMigrationScreenDestination))
},
isUserInCall = viewModelSelf::isUserInCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SelfUserProfileViewModel @Inject constructor(
private val notificationManager: WireNotificationManager,
private val globalDataStore: GlobalDataStore,
private val qualifiedIdMapper: QualifiedIdMapper,
private val analyticsManager: AnonymousAnalyticsManager
private val anonymousAnalyticsManager: AnonymousAnalyticsManager
) : ViewModel() {

var userProfileState by mutableStateOf(SelfUserProfileState(userId = selfUserId, isAvatarLoading = true))
Expand Down Expand Up @@ -342,10 +342,18 @@ class SelfUserProfileViewModel @Inject constructor(
}

fun trackQrCodeClick() {
analyticsManager.sendEvent(AnalyticsEvent.QrCode.Click(!userProfileState.teamName.isNullOrBlank()))
anonymousAnalyticsManager.sendEvent(AnalyticsEvent.QrCode.Click(!userProfileState.teamName.isNullOrBlank()))
}

fun sendPersonalToTeamMigrationEvent() {
anonymousAnalyticsManager.sendEvent(
AnalyticsEvent.PersonalTeamMigration.ClickedPersonalTeamMigrationCta(
createTeamButtonClicked = true
)
)
}

sealed class ErrorCodes {
object DownloadUserInfoError : ErrorCodes()
data object DownloadUserInfoError : ErrorCodes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
package com.wire.android.ui.userprofile.teammigration

import com.ramcosta.composedestinations.annotation.NavGraph
import com.ramcosta.composedestinations.annotation.RootNavGraph

@RootNavGraph
@NavGraph
annotation class PersonalToTeamMigrationNavGraph(
val start: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -99,6 +98,7 @@ fun TeamMigrationScreen(
if (navController.currentDestination?.route == NavGraphs.personalToTeamMigration.destinations.last().route) {
navigator.navigateBack()
} else {
teamMigrationViewModel.sendPersonalToTeamMigrationDismissed()
teamMigrationViewModel.showMigrationLeaveDialog()
}
}
Expand All @@ -116,10 +116,7 @@ fun TeamMigrationScreen(
dependenciesContainerBuilder = {
dependency(navigator)
dependency(NavGraphs.personalToTeamMigration) {
val parentEntry = remember(navBackStackEntry) {
navController.getBackStackEntry(NavGraphs.personalToTeamMigration.route)
}
hiltViewModel<TeamMigrationViewModel>(parentEntry)
teamMigrationViewModel
}
}
)
Expand All @@ -128,10 +125,16 @@ fun TeamMigrationScreen(
if (teamMigrationViewModel.teamMigrationState.shouldShowMigrationLeaveDialog) {
ConfirmMigrationLeaveDialog(
onContinue = {
teamMigrationViewModel.sendPersonalTeamCreationFlowCanceledEvent(
modalContinueClicked = true
)
teamMigrationViewModel.hideMigrationLeaveDialog()
}
) {
teamMigrationViewModel.hideMigrationLeaveDialog()
teamMigrationViewModel.sendPersonalTeamCreationFlowCanceledEvent(
modalLeaveClicked = true
)
navigator.navigateBack()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import com.wire.android.feature.analytics.AnonymousAnalyticsManager
import com.wire.android.feature.analytics.model.AnalyticsEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class TeamMigrationViewModel @Inject constructor() : ViewModel() {
class TeamMigrationViewModel @Inject constructor(
private val anonymousAnalyticsManager: AnonymousAnalyticsManager
) : ViewModel() {

var teamMigrationState by mutableStateOf(TeamMigrationState())
private set
Expand All @@ -37,4 +41,44 @@ class TeamMigrationViewModel @Inject constructor() : ViewModel() {
fun hideMigrationLeaveDialog() {
teamMigrationState = teamMigrationState.copy(shouldShowMigrationLeaveDialog = false)
}

fun sendPersonalToTeamMigrationDismissed() {
anonymousAnalyticsManager.sendEvent(
AnalyticsEvent.PersonalTeamMigration.ClickedPersonalTeamMigrationCta(
dismissCreateTeamButtonClicked = true
)
)
}

fun sendPersonalTeamCreationFlowStartedEvent(step: Int) {
anonymousAnalyticsManager.sendEvent(
AnalyticsEvent.PersonalTeamMigration.PersonalTeamCreationFlowStarted(step)
)
}

fun sendPersonalTeamCreationFlowCanceledEvent(
modalLeaveClicked: Boolean? = null,
modalContinueClicked: Boolean? = null
) {
anonymousAnalyticsManager.sendEvent(
AnalyticsEvent.PersonalTeamMigration.PersonalTeamCreationFlowCanceled(
teamName = teamMigrationState.teamNameTextState.text.toString(),
modalLeaveClicked = modalLeaveClicked,
modalContinueClicked = modalContinueClicked
)
)
}

fun sendPersonalTeamCreationFlowCompletedEvent(
modalOpenTeamManagementButtonClicked: Boolean? = null,
backToWireButtonClicked: Boolean? = null
) {
anonymousAnalyticsManager.sendEvent(
AnalyticsEvent.PersonalTeamMigration.PersonalTeamCreationFlowCompleted(
teamName = teamMigrationState.teamNameTextState.text.toString(),
modalOpenTeamManagementButtonClicked = modalOpenTeamManagementButtonClicked,
backToWireButtonClicked = backToWireButtonClicked
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.material.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -55,6 +56,7 @@ import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireTypography
import com.wire.android.ui.userprofile.teammigration.common.BottomLineButtons
import com.wire.android.ui.userprofile.teammigration.PersonalToTeamMigrationNavGraph
import com.wire.android.ui.userprofile.teammigration.TeamMigrationViewModel
import com.wire.android.util.CustomTabsHelper
import com.wire.android.util.ui.PreviewMultipleThemes

Expand All @@ -64,13 +66,18 @@ import com.wire.android.util.ui.PreviewMultipleThemes
)
@Composable
fun TeamMigrationTeamPlanStepScreen(
navigator: DestinationsNavigator
navigator: DestinationsNavigator,
teamMigrationViewModel: TeamMigrationViewModel
) {
TeamMigrationTeamPlanStepScreenContent(
onContinueButtonClicked = {
navigator.navigate(TeamMigrationTeamNameStepScreenDestination)
}
)

LaunchedEffect(Unit) {
teamMigrationViewModel.sendPersonalTeamCreationFlowStartedEvent(1)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
Expand Down Expand Up @@ -66,6 +67,9 @@ fun TeamMigrationTeamNameStepScreen(
},
teamNameTextFieldState = teamMigrationViewModel.teamMigrationState.teamNameTextState
)
LaunchedEffect(Unit) {
teamMigrationViewModel.sendPersonalTeamCreationFlowStartedEvent(2)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -72,6 +73,7 @@ fun TeamMigrationConfirmationStepScreen(
navigator: DestinationsNavigator,
teamMigrationViewModel: TeamMigrationViewModel
) {

TeamMigrationConfirmationStepScreenContent(
onContinueButtonClicked = {
// TODO: call the API to migrate the user to the team, if successful navigate to next screen
Expand All @@ -82,6 +84,9 @@ fun TeamMigrationConfirmationStepScreen(
},
passwordTextState = teamMigrationViewModel.teamMigrationState.passwordTextState
)
LaunchedEffect(Unit) {
teamMigrationViewModel.sendPersonalTeamCreationFlowStartedEvent(3)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ fun TeamMigrationDoneStepScreen(
val teamManagementUrl = stringResource(R.string.url_team_management)
TeamMigrationDoneStepContent(
onBackToWireClicked = {
teamMigrationViewModel.sendPersonalTeamCreationFlowCompletedEvent(
backToWireButtonClicked = true
)
navigator.navigate(
NavigationCommand(
HomeScreenDestination,
Expand All @@ -73,6 +76,9 @@ fun TeamMigrationDoneStepScreen(
)
},
onOpenTeamManagementClicked = {
teamMigrationViewModel.sendPersonalTeamCreationFlowCompletedEvent(
modalOpenTeamManagementButtonClicked = true
)
CustomTabsHelper.launchUrl(context, teamManagementUrl)
},
teamName = teamMigrationViewModel.teamMigrationState.teamNameTextState.text.toString()
Expand Down
Loading
Loading