1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2039 Analytics | Any objects creation analytics (#687)

This commit is contained in:
Konstantin Ivanov 2023-12-12 17:03:53 +01:00 committed by uburoiubu
parent e074d8273e
commit a2e7e33863
No known key found for this signature in database
GPG key ID: C8FB80E0A595FBB6
5 changed files with 27 additions and 13 deletions

View file

@ -218,6 +218,7 @@ object EventsDictionary {
const val settings = "Settings"
const val screenDeletion = "ScreenDeletion"
const val navigation = "Navigation"
const val longTap = "LongTap"
}
object Type {

View file

@ -94,7 +94,7 @@ class HomeScreenFragment : BaseComposeFragment() {
onClick = {
val dialog = CreateObjectOfTypeFragment().apply {
onTypeSelected = {
vm.onCreateNewObjectClicked(it.uniqueKey)
vm.onCreateNewObjectClicked(it)
dismiss()
}
}

View file

@ -4412,7 +4412,8 @@ class EditorViewModel(
analytics = analytics,
startTime = startTime,
sourceObject = SET_MARKETPLACE_ID,
containsFlagType = true
containsFlagType = true,
route = EventsDictionary.Routes.navigation,
)
}
)
@ -4429,7 +4430,8 @@ class EditorViewModel(
analytics = analytics,
startTime = startTime,
sourceObject = COLLECTION_MARKETPLACE_ID,
containsFlagType = true
containsFlagType = true,
route = EventsDictionary.Routes.navigation
)
}
)
@ -6066,7 +6068,8 @@ class EditorViewModel(
analytics = analytics,
startTime = startTime,
sourceObject = objType.sourceObject,
containsFlagType = containsTypeFlag
containsFlagType = containsTypeFlag,
route = EventsDictionary.Routes.navigation
)
onSuccess?.invoke()
}

View file

@ -638,12 +638,14 @@ fun CoroutineScope.sendAnalyticsObjectTypeSelectOrChangeEvent(
analytics: Analytics,
startTime: Long,
sourceObject: Id? = null,
containsFlagType: Boolean
containsFlagType: Boolean,
route: String? = null
) {
val objType = sourceObject ?: OBJ_TYPE_CUSTOM
val props = Props(
mapOf(
EventsPropertiesKey.objectType to objType
EventsPropertiesKey.objectType to objType,
EventsPropertiesKey.route to route
)
)
val event = if (containsFlagType) {
@ -742,8 +744,6 @@ fun CoroutineScope.sendAnalyticsObjectCreateEvent(
eventName = objectCreate,
props = propsForObjectEvents(
route = route,
context = analytics.getContext(),
originalId = analytics.getOriginalId(),
sourceObject = objType?.sourceObject,
view = view
),

View file

@ -59,6 +59,7 @@ import com.anytypeio.anytype.domain.workspace.SpaceManager
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.extension.sendAddWidgetEvent
import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectCreateEvent
import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectTypeSelectOrChangeEvent
import com.anytypeio.anytype.presentation.extension.sendDeleteWidgetEvent
import com.anytypeio.anytype.presentation.extension.sendEditWidgetsEvent
import com.anytypeio.anytype.presentation.extension.sendReorderWidgetEvent
@ -1058,19 +1059,19 @@ class HomeScreenViewModel(
}
}
fun onCreateNewObjectClicked(type: Key? = null) {
Timber.d("onCreateNewObjectClicked, type:[$type]")
fun onCreateNewObjectClicked(objType: ObjectWrapper.Type? = null) {
Timber.d("onCreateNewObjectClicked, type:[${objType?.uniqueKey}]")
val startTime = System.currentTimeMillis()
viewModelScope.launch {
val params = CreateObject.Param(
internalFlags = buildList {
add(InternalFlags.ShouldSelectTemplate)
add(InternalFlags.ShouldEmptyDelete)
if (type.isNullOrBlank()) {
if (objType == null) {
add(InternalFlags.ShouldSelectType)
}
},
type = if (type != null) TypeKey(key = type) else null
type = if (objType != null) TypeKey(key = objType.uniqueKey) else null
)
createObject.stream(params).collect { createObjectResponse ->
createObjectResponse.fold(
@ -1083,7 +1084,16 @@ class HomeScreenViewModel(
startTime = startTime,
view = EventsDictionary.View.viewHome
)
if (type == ObjectTypeUniqueKeys.SET || type == ObjectTypeUniqueKeys.COLLECTION) {
if (objType != null) {
sendAnalyticsObjectTypeSelectOrChangeEvent(
analytics = analytics,
startTime = startTime,
sourceObject = objType.sourceObject,
containsFlagType = true,
route = EventsDictionary.Routes.longTap
)
}
if (objType?.uniqueKey == ObjectTypeUniqueKeys.SET || objType?.uniqueKey == ObjectTypeUniqueKeys.COLLECTION) {
navigate(Navigation.OpenSet(result.objectId))
} else {
navigate(Navigation.OpenObject(result.objectId))