mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Analytics: Send JoinedRoom event - room preview (#4716)
This commit is contained in:
parent
55a6257cee
commit
a8c29f55f5
@ -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<String> = emptyList(),
|
||||
@ -69,6 +70,7 @@ class RoomPreviewActivity : VectorBaseActivity<ActivitySimpleBinding>(), Toolbar
|
||||
roomName = publicRoom.name,
|
||||
roomAlias = publicRoom.getPrimaryAlias(),
|
||||
topic = publicRoom.topic,
|
||||
numJoinedMembers = publicRoom.numJoinedMembers,
|
||||
worldReadable = publicRoom.worldReadable,
|
||||
avatarUrl = publicRoom.avatarUrl,
|
||||
homeServers = listOfNotNull(roomDirectoryData.homeServer)
|
||||
|
@ -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<RoomPreviewViewState, RoomPreviewAction, EmptyViewEvents>(initialState) {
|
||||
class RoomPreviewViewModel @AssistedInject constructor(
|
||||
@Assisted private val initialState: RoomPreviewViewState,
|
||||
private val analyticsTracker: AnalyticsTracker,
|
||||
private val session: Session
|
||||
) : VectorViewModel<RoomPreviewViewState, RoomPreviewAction, EmptyViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory : MavericksAssistedViewModelFactory<RoomPreviewViewModel, RoomPreviewViewState> {
|
||||
@ -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) {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user