mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1735 Analytics | Type change event (#470)
This commit is contained in:
parent
766c52b7c4
commit
43357af5e4
3 changed files with 38 additions and 4 deletions
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue