Click replaced with Compose on message sent

Identity replaced with UserProperty
added missing param for JoinedRoom
This commit is contained in:
NIkita Fedrunov 2022-02-09 14:23:45 +01:00
parent 1369d1fa2f
commit f78446c1e7
7 changed files with 22 additions and 16 deletions

View File

@ -18,7 +18,7 @@ package im.vector.app.features.analytics
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
import im.vector.app.features.analytics.plan.Identity
import im.vector.app.features.analytics.plan.UserProperties
interface AnalyticsTracker {
/**
@ -34,5 +34,5 @@ interface AnalyticsTracker {
/**
* Update user specific properties
*/
fun updateUserProperties(identity: Identity)
fun updateUserProperties(userProperties: UserProperties)
}

View File

@ -19,6 +19,7 @@ package im.vector.app.features.analytics.extensions
import im.vector.app.features.analytics.plan.JoinedRoom
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.RoomType
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
fun Int?.toAnalyticsRoomSize(): JoinedRoom.RoomSize {
@ -35,6 +36,7 @@ fun Int?.toAnalyticsRoomSize(): JoinedRoom.RoomSize {
fun RoomSummary?.toAnalyticsJoinedRoom(): JoinedRoom {
return JoinedRoom(
isDM = this?.isDirect.orFalse(),
isSpace = this?.roomType == RoomType.SPACE,
roomSize = this?.joinedMembersCount?.toAnalyticsRoomSize() ?: JoinedRoom.RoomSize.Two
)
}
@ -42,6 +44,7 @@ fun RoomSummary?.toAnalyticsJoinedRoom(): JoinedRoom {
fun PublicRoom.toAnalyticsJoinedRoom(): JoinedRoom {
return JoinedRoom(
isDM = false,
isSpace = false,
roomSize = numJoinedMembers.toAnalyticsRoomSize()
)
}

View File

@ -16,14 +16,14 @@
package im.vector.app.features.analytics.extensions
import im.vector.app.features.analytics.plan.Identity
import im.vector.app.features.analytics.plan.UserProperties
import im.vector.app.features.onboarding.FtueUseCase
fun FtueUseCase.toTrackingValue(): Identity.FtueUseCaseSelection {
fun FtueUseCase.toTrackingValue(): UserProperties.FtueUseCaseSelection {
return when (this) {
FtueUseCase.FRIENDS_FAMILY -> Identity.FtueUseCaseSelection.PersonalMessaging
FtueUseCase.TEAMS -> Identity.FtueUseCaseSelection.WorkMessaging
FtueUseCase.COMMUNITIES -> Identity.FtueUseCaseSelection.CommunityMessaging
FtueUseCase.SKIP -> Identity.FtueUseCaseSelection.Skip
FtueUseCase.FRIENDS_FAMILY -> UserProperties.FtueUseCaseSelection.PersonalMessaging
FtueUseCase.TEAMS -> UserProperties.FtueUseCaseSelection.WorkMessaging
FtueUseCase.COMMUNITIES -> UserProperties.FtueUseCaseSelection.CommunityMessaging
FtueUseCase.SKIP -> UserProperties.FtueUseCaseSelection.Skip
}
}

View File

@ -26,7 +26,7 @@ import im.vector.app.features.analytics.VectorAnalytics
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
import im.vector.app.features.analytics.log.analyticsTag
import im.vector.app.features.analytics.plan.Identity
import im.vector.app.features.analytics.plan.UserProperties
import im.vector.app.features.analytics.store.AnalyticsStore
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.Flow
@ -175,8 +175,8 @@ class DefaultVectorAnalytics @Inject constructor(
?.screen(screen.getName(), screen.getProperties()?.toPostHogProperties())
}
override fun updateUserProperties(identity: Identity) {
posthog?.identify(REUSE_EXISTING_ID, identity.getProperties().toPostHogProperties(), IGNORED_OPTIONS)
override fun updateUserProperties(userProperties: UserProperties) {
posthog?.identify(REUSE_EXISTING_ID, userProperties.getProperties().toPostHogProperties(), IGNORED_OPTIONS)
}
private fun Map<String, Any?>?.toPostHogProperties(): Properties? {

View File

@ -119,7 +119,7 @@ import im.vector.app.core.utils.startInstallFromSourceIntent
import im.vector.app.core.utils.toast
import im.vector.app.databinding.DialogReportContentBinding
import im.vector.app.databinding.FragmentTimelineBinding
import im.vector.app.features.analytics.plan.Click
import im.vector.app.features.analytics.plan.Composer
import im.vector.app.features.analytics.plan.Screen
import im.vector.app.features.attachments.AttachmentTypeSelectorView
import im.vector.app.features.attachments.AttachmentsHelper
@ -1499,7 +1499,9 @@ class TimelineFragment @Inject constructor(
return
}
if (text.isNotBlank()) {
analyticsTracker.capture(Click(name = Click.Name.SendMessageButton))
withState(messageComposerViewModel) { state ->
analyticsTracker.capture(Composer(isThreadTimeLine(), isEditing = state.sendMode is SendMode.Edit, isReply = state.sendMode is SendMode.Reply))
}
// We collapse ASAP, if not there will be a slight annoying delay
views.composerLayout.collapse(true)
lockSendButton = true

View File

@ -39,7 +39,7 @@ import im.vector.app.core.utils.ensureTrailingSlash
import im.vector.app.features.VectorFeatures
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.analytics.extensions.toTrackingValue
import im.vector.app.features.analytics.plan.Identity
import im.vector.app.features.analytics.plan.UserProperties
import im.vector.app.features.login.HomeServerConnectionConfigFactory
import im.vector.app.features.login.LoginConfig
import im.vector.app.features.login.LoginMode
@ -465,13 +465,13 @@ class OnboardingViewModel @AssistedInject constructor(
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
setState { copy(useCase = action.useCase) }
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = action.useCase.toTrackingValue()))
analyticsTracker.updateUserProperties(UserProperties(ftueUseCaseSelection = action.useCase.toTrackingValue()))
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
}
private fun resetUseCase() {
setState { copy(useCase = null) }
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = null))
analyticsTracker.updateUserProperties(UserProperties(ftueUseCaseSelection = null))
}
private fun handleUpdateServerType(action: OnboardingAction.UpdateServerType) {

View File

@ -251,6 +251,7 @@ class RoomPreviewViewModel @AssistedInject constructor(
analyticsTracker.capture(JoinedRoom(
// Always false in this case (?)
isDM = false,
isSpace = false,
roomSize = state.numJoinMembers.toAnalyticsRoomSize()
))
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.