mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3195 Primitives | Analytics (#2315)
This commit is contained in:
parent
4125b8d759
commit
f3f9cb9301
11 changed files with 172 additions and 8 deletions
|
@ -171,6 +171,13 @@ object EventsDictionary {
|
|||
const val clickOnboarding = "ClickOnboarding"
|
||||
const val clickLogin = "ClickLogin"
|
||||
|
||||
//Primitives
|
||||
const val logScreenEditType = "ScreenEditType"
|
||||
const val logReorderRelation = "ReorderRelation"
|
||||
const val logClickConflictFieldHelp = "ClickConflictFieldHelp"
|
||||
const val logAddConflictRelation = "AddConflictRelation"
|
||||
const val logResetToTypeDefault = "ResetToTypeDefault"
|
||||
|
||||
// Vault events
|
||||
|
||||
const val screenVault = "ScreenVault"
|
||||
|
@ -325,6 +332,8 @@ object EventsDictionary {
|
|||
const val gallery = "Gallery"
|
||||
const val notification = "Notification"
|
||||
const val featuredRelations = "FeaturedRelations"
|
||||
const val objectRoute = "Object"
|
||||
const val typeRoute = "Type"
|
||||
}
|
||||
|
||||
object Type {
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.anytypeio.anytype.presentation.editor.layout.ObjectLayoutViewModel
|
|||
import com.anytypeio.anytype.presentation.objects.ObjectLayoutView
|
||||
import javax.inject.Inject
|
||||
|
||||
@Deprecated("epic Primitives")
|
||||
@Deprecated("epic Primitives, to Delete")
|
||||
class ObjectLayoutFragment : BaseBottomSheetFragment<FragmentObjectLayoutBinding>() {
|
||||
|
||||
private val ctx: String get() = argString(CONTEXT_ID_KEY)
|
||||
|
|
|
@ -62,7 +62,7 @@ class ObjectTypeFieldsFragment : BaseBottomSheetComposeFragment() {
|
|||
subscribe(vm.commands) { command ->
|
||||
Timber.d("Received command: $command")
|
||||
when (command) {
|
||||
is ObjectTypeCommand.OpenEditTypePropertiesScreen -> {
|
||||
is ObjectTypeCommand.OpenAddNewPropertyScreen -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
R.id.editTypePropertiesScreen,
|
||||
|
|
|
@ -93,11 +93,11 @@ class ObjectTypeFragment : BaseComposeFragment() {
|
|||
)
|
||||
}
|
||||
|
||||
ObjectTypeCommand.OpenFieldsScreen -> {
|
||||
ObjectTypeCommand.OpenTypePropertiesListScreen -> {
|
||||
navComposeController.navigate(OBJ_TYPE_PROPERTIES)
|
||||
}
|
||||
|
||||
is ObjectTypeCommand.OpenEditTypePropertiesScreen -> {
|
||||
is ObjectTypeCommand.OpenAddNewPropertyScreen -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
R.id.editTypePropertiesScreen,
|
||||
|
@ -116,6 +116,7 @@ class ObjectTypeFragment : BaseComposeFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
vm.sendAnalyticsScreenObjectType()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
|
|
@ -29,11 +29,11 @@ sealed class ObjectTypeCommand {
|
|||
val spaceId: Id
|
||||
) : ObjectTypeCommand()
|
||||
|
||||
data object OpenFieldsScreen : ObjectTypeCommand()
|
||||
data object OpenTypePropertiesListScreen : ObjectTypeCommand()
|
||||
|
||||
data object CloseFieldsScreen : ObjectTypeCommand()
|
||||
|
||||
data class OpenEditTypePropertiesScreen(val typeId: Id, val space: Id) : ObjectTypeCommand()
|
||||
data class OpenAddNewPropertyScreen(val typeId: Id, val space: Id) : ObjectTypeCommand()
|
||||
}
|
||||
|
||||
//region OBJECT TYPE HEADER (title + icon)
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.feature_object_type.viewmodel
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -61,7 +62,11 @@ import com.anytypeio.anytype.feature_properties.edit.UiEditPropertyState.Visible
|
|||
import com.anytypeio.anytype.feature_properties.edit.UiPropertyLimitTypeItem
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsLocalPropertyResolve
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsPropertiesLocalInfo
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsReorderRelationEvent
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsScreenObjectType
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowObjectTypeScreen
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.custom_icon.CustomIconColor
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants.defaultKeys
|
||||
|
@ -183,6 +188,9 @@ class ObjectTypeViewModel(
|
|||
fun onStart() {
|
||||
Timber.d("onStart, vmParams: $vmParams")
|
||||
startSubscriptions()
|
||||
}
|
||||
|
||||
fun sendAnalyticsScreenObjectType() {
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsScreenObjectType(
|
||||
analytics = analytics
|
||||
|
@ -465,7 +473,14 @@ class ObjectTypeViewModel(
|
|||
when (event) {
|
||||
TypeEvent.OnFieldsButtonClick -> {
|
||||
viewModelScope.launch {
|
||||
commands.emit(ObjectTypeCommand.OpenFieldsScreen)
|
||||
commands.emit(ObjectTypeCommand.OpenTypePropertiesListScreen)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsShowObjectTypeScreen(
|
||||
analytics = analytics,
|
||||
route = EventsDictionary.Routes.typeRoute,
|
||||
spaceParams = provideParams(vmParams.spaceId.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -737,12 +752,15 @@ class ObjectTypeViewModel(
|
|||
|
||||
FieldEvent.Section.OnLocalInfoClick -> {
|
||||
uiFieldLocalInfoState.value = UiLocalsFieldsInfoState.Visible
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsPropertiesLocalInfo(analytics, provideParams(vmParams.spaceId.id))
|
||||
}
|
||||
}
|
||||
|
||||
FieldEvent.Section.OnAddToSidebarIconClick -> {
|
||||
viewModelScope.launch {
|
||||
commands.emit(
|
||||
OpenEditTypePropertiesScreen(
|
||||
OpenAddNewPropertyScreen(
|
||||
typeId = vmParams.objectId,
|
||||
space = vmParams.spaceId.id,
|
||||
)
|
||||
|
@ -860,6 +878,9 @@ class ObjectTypeViewModel(
|
|||
val currentRecommendedFields = _objTypeState.value?.recommendedRelations.orEmpty()
|
||||
val newRecommendedFields = currentRecommendedFields + event.item.id
|
||||
proceedWithSetRecommendedFields(newRecommendedFields)
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsLocalPropertyResolve(analytics, provideParams(vmParams.spaceId.id))
|
||||
}
|
||||
}
|
||||
|
||||
is FieldEvent.FieldItemMenu.OnMoveToBinClick -> {
|
||||
|
@ -966,6 +987,10 @@ class ObjectTypeViewModel(
|
|||
onSuccess = {
|
||||
Timber.d("Properties updated")
|
||||
proceedWithGetObjectTypeConflictingFields()
|
||||
sendAnalyticsReorderRelationEvent(
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(vmParams.spaceId.id)
|
||||
)
|
||||
},
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while updating properties")
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary.defaultTypeChanged
|
|||
import com.anytypeio.anytype.analytics.base.EventsDictionary.duplicateTemplate
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.duplicateView
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.editTemplate
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.logScreenEditType
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.objectCreate
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.objectCreateLink
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary.objectDuplicate
|
||||
|
@ -316,6 +317,95 @@ fun CoroutineScope.sendAnalyticsObjectShowEvent(
|
|||
)
|
||||
}
|
||||
|
||||
fun CoroutineScope.sendAnalyticsShowObjectTypeScreen(
|
||||
route: String,
|
||||
analytics: Analytics,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
) {
|
||||
val props = Props(
|
||||
mapOf(
|
||||
EventsPropertiesKey.route to route,
|
||||
EventsPropertiesKey.permissions to spaceParams.permission,
|
||||
EventsPropertiesKey.spaceType to spaceParams.spaceType
|
||||
)
|
||||
)
|
||||
sendEvent(
|
||||
analytics = analytics,
|
||||
eventName = logScreenEditType,
|
||||
props = props
|
||||
)
|
||||
}
|
||||
|
||||
fun CoroutineScope.sendAnalyticsReorderRelationEvent(
|
||||
analytics: Analytics,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
) {
|
||||
val props = Props(
|
||||
mapOf(
|
||||
EventsPropertiesKey.permissions to spaceParams.permission,
|
||||
EventsPropertiesKey.spaceType to spaceParams.spaceType
|
||||
)
|
||||
)
|
||||
sendEvent(
|
||||
analytics = analytics,
|
||||
props = props,
|
||||
eventName = EventsDictionary.logReorderRelation
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun CoroutineScope.sendAnalyticsResolveObjectConflict(
|
||||
analytics: Analytics,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
) {
|
||||
val props = Props(
|
||||
mapOf(
|
||||
EventsPropertiesKey.route to EventsDictionary.Routes.objectRoute,
|
||||
EventsPropertiesKey.permissions to spaceParams.permission,
|
||||
EventsPropertiesKey.spaceType to spaceParams.spaceType
|
||||
)
|
||||
)
|
||||
sendEvent(
|
||||
analytics = analytics,
|
||||
props = props,
|
||||
eventName = EventsDictionary.logResetToTypeDefault
|
||||
)
|
||||
}
|
||||
|
||||
fun CoroutineScope.sendAnalyticsPropertiesLocalInfo(
|
||||
analytics: Analytics,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
) {
|
||||
val props = Props(
|
||||
mapOf(
|
||||
EventsPropertiesKey.permissions to spaceParams.permission,
|
||||
EventsPropertiesKey.spaceType to spaceParams.spaceType
|
||||
)
|
||||
)
|
||||
sendEvent(
|
||||
analytics = analytics,
|
||||
props = props,
|
||||
eventName = EventsDictionary.logClickConflictFieldHelp
|
||||
)
|
||||
}
|
||||
|
||||
fun CoroutineScope.sendAnalyticsLocalPropertyResolve(
|
||||
analytics: Analytics,
|
||||
spaceParams: AnalyticSpaceHelperDelegate.Params
|
||||
) {
|
||||
val props = Props(
|
||||
mapOf(
|
||||
EventsPropertiesKey.permissions to spaceParams.permission,
|
||||
EventsPropertiesKey.spaceType to spaceParams.spaceType
|
||||
)
|
||||
)
|
||||
sendEvent(
|
||||
analytics = analytics,
|
||||
props = props,
|
||||
eventName = EventsDictionary.logAddConflictRelation
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchResult - event code
|
||||
* index - number of position of chosen item, started from 1
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.anytypeio.anytype.domain.relations.DeleteRelationFromObject
|
|||
import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsResolveObjectConflict
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
import com.anytypeio.anytype.presentation.objects.isTemplatesAllowed
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -594,6 +595,13 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsResolveObjectConflict(
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(space)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.anytypeio.anytype.presentation.common.Action
|
|||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
import com.anytypeio.anytype.presentation.common.PayloadDelegator
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsResolveObjectConflict
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectAction
|
||||
import com.anytypeio.anytype.presentation.sets.dataViewState
|
||||
import com.anytypeio.anytype.presentation.sets.state.ObjectState
|
||||
|
@ -349,5 +350,12 @@ class ObjectSetMenuViewModel(
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsResolveObjectConflict(
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(space)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ import com.anytypeio.anytype.domain.workspace.SpaceManager
|
|||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.common.BaseListViewModel
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsRelationEvent
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowObjectTypeScreen
|
||||
import com.anytypeio.anytype.presentation.mapper.mapToSimpleRelationView
|
||||
import com.anytypeio.anytype.presentation.sets.dataViewState
|
||||
import com.anytypeio.anytype.presentation.sets.filterHiddenRelations
|
||||
|
@ -91,6 +92,13 @@ class ObjectSetSettingsViewModel(
|
|||
viewModelScope.launch {
|
||||
commands.emit(Command.OpenTypePropertiesScreen)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsShowObjectTypeScreen(
|
||||
route = EventsDictionary.Routes.objectRoute,
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(spaceManager.get())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +116,13 @@ class ObjectSetSettingsViewModel(
|
|||
viewModelScope.launch {
|
||||
commands.emit(Command.OpenTypePropertiesScreen)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsShowObjectTypeScreen(
|
||||
route = EventsDictionary.Routes.objectRoute,
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(spaceManager.get())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.anytypeio.anytype.presentation.common.BaseViewModel
|
|||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getStruct
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsRelationEvent
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowObjectTypeScreen
|
||||
import com.anytypeio.anytype.presentation.objects.LockedStateProvider
|
||||
import com.anytypeio.anytype.presentation.objects.getTypeForObjectAndTargetTypeForTemplate
|
||||
import com.anytypeio.anytype.presentation.objects.isTemplateObject
|
||||
|
@ -268,6 +269,13 @@ class RelationListViewModel(
|
|||
viewModelScope.launch {
|
||||
commands.emit(Command.NavigateToObjectType(objTypeId))
|
||||
}
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsShowObjectTypeScreen(
|
||||
route = EventsDictionary.Routes.objectRoute,
|
||||
analytics = analytics,
|
||||
spaceParams = provideParams(vmParams.spaceId.id),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onAddToTypeClicked(item: Model.Item) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue