analytics

This commit is contained in:
NIkita Fedrunov 2022-05-23 15:15:32 +02:00
parent 2d32d0da54
commit 7437b71b24
4 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.analytics.experiment
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
data class ExperimentInteraction(
/**
* The unique name of this element.
*/
val name: Name,
val extra: Map<String, Any> = emptyMap()
) : VectorAnalyticsEvent {
enum class Name {
SpaceSwitchHeader,
SpaceSwitchHeaderAdd,
SpaceSwitchHeaderCreate,
}
override fun getName() = "Interaction"
override fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
put("name", name.name)
putAll(extra)
}.takeIf { it.isNotEmpty() }
}
}

View File

@ -45,6 +45,7 @@ import im.vector.app.core.ui.views.CurrentCallsView
import im.vector.app.core.ui.views.CurrentCallsViewPresenter
import im.vector.app.core.ui.views.KeysBackupBanner
import im.vector.app.databinding.FragmentHomeDetailBinding
import im.vector.app.features.analytics.experiment.ExperimentInteraction
import im.vector.app.features.call.SharedKnownCallsViewModel
import im.vector.app.features.call.VectorCallActivity
import im.vector.app.features.call.dialpad.DialPadFragment
@ -279,6 +280,12 @@ class HomeDetailFragment @Inject constructor(
.setInterpolator(DecelerateInterpolator())
.start()
} else {
val extraProperties = if (getCurrentSpace() != null) {
mapOf("isSubspace" to true)
} else {
mapOf("isSubspace" to false)
}
analyticsTracker.capture(ExperimentInteraction(ExperimentInteraction.Name.SpaceSwitchHeader, extraProperties))
showModal()
}
}

View File

@ -29,7 +29,10 @@ import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.singletonEntryPoint
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.VectorOverrides
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.analytics.extensions.toAnalyticsViewRoom
import im.vector.app.features.analytics.plan.Interaction
import im.vector.app.features.analytics.plan.ViewRoom
import im.vector.app.features.call.dialpad.DialPadLookup
import im.vector.app.features.call.lookup.CallProtocolsChecker
import im.vector.app.features.call.webrtc.WebRtcCallManager
@ -75,7 +78,8 @@ class HomeDetailViewModel @AssistedInject constructor(
private val directRoomHelper: DirectRoomHelper,
private val appStateHandler: AppStateHandler,
private val autoAcceptInvites: AutoAcceptInvites,
private val vectorOverrides: VectorOverrides
private val vectorOverrides: VectorOverrides,
private val analyticsTracker: AnalyticsTracker
) : VectorViewModel<HomeDetailViewState, HomeDetailAction, HomeDetailViewEvents>(initialState),
CallProtocolsChecker.Listener {
@ -290,6 +294,9 @@ class HomeDetailViewModel @AssistedInject constructor(
hasUnreadMessages = dmRooms.totalCount + otherRooms.totalCount > 0
)
}
groupingMethod.spaceSummary?.toAnalyticsViewRoom(null, groupingMethod)?.let {
analyticsTracker.capture(it)
}
}
null -> Unit
}

View File

@ -29,6 +29,8 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentSpaceListModalBinding
import im.vector.app.features.analytics.experiment.ExperimentInteraction
import im.vector.app.features.analytics.plan.Interaction
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
import im.vector.app.features.spaces.SpaceListAction
import im.vector.app.features.spaces.SpaceListViewModel
@ -90,8 +92,10 @@ class SpaceListModalFragment : VectorBaseFragment<FragmentSpaceListModalBinding>
binding.addSpaceLayout.setOnClickListener {
val currentSpace = sharedActionViewModel.space.value
if (currentSpace != null) {
analyticsTracker.capture(ExperimentInteraction(ExperimentInteraction.Name.SpaceSwitchHeaderAdd))
startActivity(SpaceManageActivity.newIntent(requireActivity(), currentSpace.roomId, ManageType.AddRoomsOnlySpaces))
} else {
analyticsTracker.capture(ExperimentInteraction(ExperimentInteraction.Name.SpaceSwitchHeaderCreate))
sharedActionViewModel.post(HomeActivitySharedAction.AddSpace)
}
}