diff --git a/analytics/src/main/java/com/anytypeio/anytype/analytics/base/EventsDictionary.kt b/analytics/src/main/java/com/anytypeio/anytype/analytics/base/EventsDictionary.kt index de09c76ef3..929f1b9667 100644 --- a/analytics/src/main/java/com/anytypeio/anytype/analytics/base/EventsDictionary.kt +++ b/analytics/src/main/java/com/anytypeio/anytype/analytics/base/EventsDictionary.kt @@ -166,6 +166,7 @@ object EventsDictionary { const val editTemplate = "EditTemplate" const val duplicateTemplate = "DuplicateTemplate" const val createTemplate = "CreateTemplate" + const val logScreenTemplateSelector = "ScreenTemplateSelector" // Onboarding events const val screenOnboarding = "ScreenOnboarding" @@ -178,6 +179,7 @@ object EventsDictionary { const val logClickConflictFieldHelp = "ClickConflictFieldHelp" const val logAddConflictRelation = "AddConflictRelation" const val logResetToTypeDefault = "ResetToTypeDefault" + const val logScreenTypeTemplateSelector = "ScreenTypeTemplateSelector" // Vault events diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt index 14c6e74f6c..efea6adde1 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt @@ -262,6 +262,7 @@ import com.anytypeio.anytype.presentation.editor.model.OnEditorDatePickerEvent.O import com.anytypeio.anytype.presentation.extension.getFileDetailsForBlock import com.anytypeio.anytype.presentation.extension.getTypeForObject import com.anytypeio.anytype.presentation.extension.getUrlForFileContent +import com.anytypeio.anytype.presentation.extension.sendAnalyticsScreenTemplateSelectorEvent import com.anytypeio.anytype.presentation.navigation.NavPanelState import com.anytypeio.anytype.presentation.navigation.leftButtonClickAnalytics import com.anytypeio.anytype.presentation.objects.getCreateObjectParams @@ -4661,7 +4662,7 @@ class EditorViewModel( else EventsDictionary.relationChangeValue, storeOfRelations = storeOfRelations, relationKey = key, - spaceParams = provideParams(spaceManager.get()) + spaceParams = provideParams(vmParams.space.id) ) }, failure = { @@ -6831,7 +6832,11 @@ class EditorViewModel( EventWrapper( AppNavigation.Command.OpenTemplates(typeId = state.typeId) ) - ) + ).also { + viewModelScope.launch { + sendAnalyticsScreenTemplateSelectorEvent(analytics, provideParams(vmParams.space.id)) + } + } } else { Timber.e("State of templates widget is invalid when clicked, should be SelectTemplateViewState.Activ") } @@ -7526,7 +7531,7 @@ class EditorViewModel( eventName = EventsDictionary.relationAdd, storeOfRelations = storeOfRelations, relationKey = view.key, - spaceParams = provideParams(spaceManager.get()) + spaceParams = provideParams(vmParams.space.id) ) action.invoke() } diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt index 8a564a0618..bc5e6ef3ce 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt @@ -17,6 +17,7 @@ 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.logScreenTemplateSelector import com.anytypeio.anytype.analytics.base.EventsDictionary.objectCreate import com.anytypeio.anytype.analytics.base.EventsDictionary.objectCreateLink import com.anytypeio.anytype.analytics.base.EventsDictionary.objectDuplicate @@ -1503,6 +1504,17 @@ fun CoroutineScope.logEvent( props = buildProps(route = route, spaceParams = spaceParams) ) } + ObjectStateAnalyticsEvent.SCREEN_TYPE_TEMPLATE_SELECTOR -> { + if (state is ObjectState.DataView.TypeSet) { + scope.sendEvent( + analytics = analytics, + eventName = EventsDictionary.logScreenTypeTemplateSelector, + startTime = startTime, + middleTime = middleTime, + props = buildProps(spaceParams = spaceParams) + ) + } + } } } @@ -1557,7 +1569,8 @@ enum class ObjectStateAnalyticsEvent { DUPLICATE_TEMPLATE, DELETE_TEMPLATE, SET_AS_DEFAULT_TYPE, - CHANGE_DEFAULT_TEMPLATE + CHANGE_DEFAULT_TEMPLATE, + SCREEN_TYPE_TEMPLATE_SELECTOR } fun CoroutineScope.sendEditWidgetsEvent( @@ -2112,6 +2125,22 @@ fun CoroutineScope.sendAnalyticsSelectTemplateEvent( ) } +fun CoroutineScope.sendAnalyticsScreenTemplateSelectorEvent( + analytics: Analytics, + spaceParams: AnalyticSpaceHelperDelegate.Params +) { + sendEvent( + analytics = analytics, + eventName = logScreenTemplateSelector, + props = Props( + buildMap { + put(EventsPropertiesKey.permissions, spaceParams.permission) + put(EventsPropertiesKey.spaceType, spaceParams.spaceType) + } + ) + ) +} + fun CoroutineScope.sendAnalyticsCreateTemplateEvent( analytics: Analytics, details: Map, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt index 181efd3fe3..e87de6d81e 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt @@ -2131,6 +2131,7 @@ class ObjectSetViewModel( selectedTypeFlow.value = type } logEvent(ObjectStateAnalyticsEvent.SHOW_TEMPLATES) + logEvent(ObjectStateAnalyticsEvent.SCREEN_TYPE_TEMPLATE_SELECTOR) } fun onTypeTemplatesWidgetAction(action: TypeTemplatesWidgetUIAction) {