diff --git a/vector/src/main/java/im/vector/app/features/analytics/extensions/AnalyticsExtensions.kt b/vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt similarity index 100% rename from vector/src/main/java/im/vector/app/features/analytics/extensions/AnalyticsExtensions.kt rename to vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt index 394d738b26..a317019d49 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt @@ -40,6 +40,7 @@ data class RoomPreviewData( val roomAlias: String? = null, val roomType: String? = null, val topic: String? = null, + val numJoinedMembers: Int? = null, val worldReadable: Boolean = false, val avatarUrl: String? = null, val homeServers: List = emptyList(), @@ -69,6 +70,7 @@ class RoomPreviewActivity : VectorBaseActivity(), Toolbar roomName = publicRoom.name, roomAlias = publicRoom.getPrimaryAlias(), topic = publicRoom.topic, + numJoinedMembers = publicRoom.numJoinedMembers, worldReadable = publicRoom.worldReadable, avatarUrl = publicRoom.avatarUrl, homeServers = listOfNotNull(roomDirectoryData.homeServer) diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index bdb0a96e9e..b1fa0e974a 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -27,6 +27,9 @@ import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.extensions.exhaustive import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.VectorViewModel +import im.vector.app.features.analytics.AnalyticsTracker +import im.vector.app.features.analytics.extensions.toAnalyticsRoomSize +import im.vector.app.features.analytics.plan.JoinedRoom import im.vector.app.features.roomdirectory.JoinState import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn @@ -44,9 +47,11 @@ import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams import org.matrix.android.sdk.flow.flow import timber.log.Timber -class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val initialState: RoomPreviewViewState, - private val session: Session) : - VectorViewModel(initialState) { +class RoomPreviewViewModel @AssistedInject constructor( + @Assisted private val initialState: RoomPreviewViewState, + private val analyticsTracker: AnalyticsTracker, + private val session: Session +) : VectorViewModel(initialState) { @AssistedFactory interface Factory : MavericksAssistedViewModelFactory { @@ -243,6 +248,11 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val ini viewModelScope.launch { try { session.joinRoom(state.roomId, viaServers = state.homeServers) + analyticsTracker.capture(JoinedRoom( + // Always false in this case (?) + isDM = false, + roomSize = state.numJoinMembers.toAnalyticsRoomSize() + )) // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined } catch (failure: Throwable) { diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewState.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewState.kt index 8488dd7267..b2cb43115d 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewState.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewState.kt @@ -33,6 +33,7 @@ data class RoomPreviewViewState( val roomName: String? = null, val roomTopic: String? = null, + val numJoinMembers: Int? = null, val avatarUrl: String? = null, val shouldPeekFromServer: Boolean = false, @@ -56,6 +57,7 @@ data class RoomPreviewViewState( homeServers = args.homeServers, roomName = args.roomName, roomTopic = args.topic, + numJoinMembers = args.numJoinedMembers, avatarUrl = args.avatarUrl, shouldPeekFromServer = args.peekFromServer, fromEmailInvite = args.fromEmailInvite, @@ -64,6 +66,6 @@ data class RoomPreviewViewState( fun matrixItem(): MatrixItem { return if (roomType == RoomType.SPACE) MatrixItem.SpaceItem(roomId, roomName ?: roomAlias, avatarUrl) - else MatrixItem.RoomItem(roomId, roomName ?: roomAlias, avatarUrl) + else MatrixItem.RoomItem(roomId, roomName ?: roomAlias, avatarUrl) } }