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 2b8a34a827..a096de371b 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 @@ -12,6 +12,7 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary.changeViewType import com.anytypeio.anytype.analytics.base.EventsDictionary.clickNewOption import com.anytypeio.anytype.analytics.base.EventsDictionary.collectionScreenShow import com.anytypeio.anytype.analytics.base.EventsDictionary.createTemplate +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 @@ -1314,6 +1315,23 @@ fun CoroutineScope.logEvent( ) ) } + + ObjectStateAnalyticsEvent.SET_AS_DEFAULT_TYPE -> { + val route = when (state) { + is ObjectState.DataView.Collection -> EventsDictionary.Routes.objCreateCollection + is ObjectState.DataView.Set -> EventsDictionary.Routes.objCreateSet + } + scope.sendEvent( + analytics = analytics, + eventName = defaultTypeChanged, + startTime = startTime, + middleTime = middleTime, + props = buildProps( + route = route, + objectType = type ?: OBJ_TYPE_CUSTOM + ) + ) + } } } @@ -1361,7 +1379,8 @@ enum class ObjectStateAnalyticsEvent { CREATE_TEMPLATE, EDIT_TEMPLATE, DUPLICATE_TEMPLATE, - DELETE_TEMPLATE + DELETE_TEMPLATE, + SET_AS_DEFAULT_TYPE } fun CoroutineScope.sendEditWidgetsEvent( 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 191a7b1a28..381da3f090 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 @@ -1659,6 +1659,10 @@ class ObjectSetViewModel( when (templateView) { is TemplateView.Blank -> { logEvent(ObjectStateAnalyticsEvent.SELECT_TEMPLATE) + logEvent( + event = ObjectStateAnalyticsEvent.SET_AS_DEFAULT_TYPE, + type = templateView.targetTypeKey.key + ) proceedWithUpdateViewer( viewerId = getWidgetViewerId() ) { @@ -1671,9 +1675,14 @@ class ObjectSetViewModel( typeChosenBy = templateView.targetTypeKey, templateId = templateView.id ) + } is TemplateView.Template -> { logEvent(ObjectStateAnalyticsEvent.SELECT_TEMPLATE) + logEvent( + event = ObjectStateAnalyticsEvent.SET_AS_DEFAULT_TYPE, + type = templateView.targetTypeKey.key + ) proceedWithUpdateViewer( viewerId = getWidgetViewerId() ) { @@ -1696,12 +1705,13 @@ class ObjectSetViewModel( } } - private fun logEvent(event: ObjectStateAnalyticsEvent) { + private fun logEvent(event: ObjectStateAnalyticsEvent, type: Id? = null) { viewModelScope.launch { logEvent( state = stateReducer.state.value, analytics = analytics, - event = event + event = event, + type = type ) } } diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/OtherSettingsViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/OtherSettingsViewModel.kt index 067a839d36..07c39a7e90 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/OtherSettingsViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/settings/OtherSettingsViewModel.kt @@ -107,7 +107,12 @@ class OtherSettingsViewModel( analytics.registerEvent( EventAnalytics.Anytype( name = defaultTypeChanged, - props = Props(mapOf(EventsPropertiesKey.objectType to type)), + props = Props( + mapOf( + EventsPropertiesKey.objectType to key, + EventsPropertiesKey.route to "Settings" + ) + ), duration = null ) )