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

DROID-972 Analytics | Fix | createObject event (#2926)

* DROID-972 legacy flag isDraft removed

* DROID-972 send createObject event

* DROID-972 createObject event

* DROID-972 update useCase

* DROID-972 pr fix
This commit is contained in:
Konstantin Ivanov 2023-02-14 17:43:21 +01:00 committed by uburoiubu
parent ac1758a00b
commit 25d825777f
8 changed files with 39 additions and 23 deletions

View file

@ -50,7 +50,6 @@ data class Block(
}
val id: Id? by default
val isDraft: Boolean? by default
val snippet: String? by default
val layout: Double?

View file

@ -83,8 +83,6 @@ sealed class ObjectWrapper {
val description: String? by default
val isDraft: Boolean? by default
val url: String? by default
val featuredRelations: List<String>? by default

View file

@ -26,13 +26,9 @@ object Relations {
const val TARGET_OBJECT_TYPE = "targetObjectType"
const val DONE = "done"
const val FEATURED_RELATIONS = "featuredRelations"
const val FILE_EXT = "fileExt"
const val FILE_MIME_TYPE = "fileMimeType"
const val SNIPPET = "snippet"
const val IS_DRAFT = "isDraft"
const val WORKSPACE_ID = "workspaceId"
const val SET_OF = "setOf"
const val IS_HIGHLIGHTED = "isHighlighted"
const val URL = "url"
const val SOURCE = "source"
const val SMARTBLOCKTYPES = "smartblockTypes"

View file

@ -52,7 +52,9 @@ class CreateObject(
return Result(
objectId = result.id,
event = result.event
event = result.event,
appliedTemplate = template,
type = type
)
}
@ -62,6 +64,8 @@ class CreateObject(
data class Result(
val objectId: Id,
val event: Payload
val event: Payload,
val appliedTemplate: String? = null,
val type: String? = null
)
}

View file

@ -168,8 +168,7 @@ object Flags {
val skipRefreshKeys = listOf(
Relations.NAME,
Relations.LAST_MODIFIED_DATE,
Relations.SNIPPET,
Relations.IS_DRAFT
Relations.SNIPPET
)
}

View file

@ -1416,6 +1416,11 @@ class EditorViewModel(
) {
Timber.d("onEndLineEnterClicked, id:[$id] text:[$text] marks:[$marks]")
if (isObjectTypesWidgetVisible) {
dispatchObjectCreateEvent()
proceedWithHidingObjectTypeWidget()
}
val target = blocks.first { it.id == id }
val content = target.content<Content.Text>().copy(
@ -2902,6 +2907,12 @@ class EditorViewModel(
fun onOutsideClicked() {
Timber.d("onOutsideClicked, ")
if (isObjectTypesWidgetVisible) {
dispatchObjectCreateEvent()
proceedWithHidingObjectTypeWidget()
}
if (mode is EditorMode.Styling) {
onExitBlockStyleToolbarClicked()
return
@ -3132,7 +3143,17 @@ class EditorViewModel(
jobs += viewModelScope.launch {
createObject.execute(CreateObject.Param(type = null))
.fold(
onSuccess = { result -> proceedWithOpeningObject(result.objectId) },
onSuccess = { result ->
if (result.appliedTemplate != null) {
sendAnalyticsObjectCreateEvent(
analytics = analytics,
objType = result.type,
route = EventsDictionary.Routes.objPowerTool,
context = analyticsContext
)
}
proceedWithOpeningObject(result.objectId)
},
onFailure = { e -> Timber.e(e, "Error while creating a new page") }
)
}
@ -5876,7 +5897,6 @@ class EditorViewModel(
private fun dispatchObjectCreateEvent(objectType: String? = null) {
val details = orchestrator.stores.details.current()
val wrapper = ObjectWrapper.Basic(details.details[context]?.map ?: emptyMap())
if (wrapper.isDraft != true) return
if (objectType != null) {
viewModelScope.launch {
val type = storeOfObjectTypes.get(objectType)
@ -5910,15 +5930,6 @@ class EditorViewModel(
}
}
private fun getObjectSmartBlockType(): SmartBlockType {
val block = blocks.firstOrNull { it.id == context }
return if (block?.content is Content.Smart) {
block.content<Content.Smart>().type
} else {
SmartBlockType.PAGE
}
}
private fun proceedWithOpeningSelectingObjectTypeScreen() {
val excludeTypes = orchestrator.stores.details.current().details[context]?.type
val command = if (isObjectTypesWidgetVisible) {

View file

@ -734,7 +734,7 @@ fun CoroutineScope.sendAnalyticsRemoveSortEvent(
fun CoroutineScope.sendAnalyticsObjectCreateEvent(
analytics: Analytics,
objType: String?,
layout: Double?,
layout: Double? = null,
route: String,
startTime: Long? = null,
middleTime: Long? = null,

View file

@ -50,6 +50,7 @@ import com.anytypeio.anytype.presentation.editor.editor.Proxy
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
import com.anytypeio.anytype.presentation.editor.model.TextUpdate
import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectCreateEvent
import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowSetEvent
import com.anytypeio.anytype.presentation.navigation.AppNavigation
import com.anytypeio.anytype.presentation.navigation.SupportNavigation
@ -1038,6 +1039,14 @@ class ObjectSetViewModel(
jobs += viewModelScope.launch {
createObject.execute(CreateObject.Param(type = null)).fold(
onSuccess = { result ->
if (result.appliedTemplate != null) {
sendAnalyticsObjectCreateEvent(
analytics = analytics,
objType = result.type,
route = EventsDictionary.Routes.objCreateSet,
context = analyticsContext
)
}
proceedWithOpeningObject(result.objectId)
},
onFailure = { e ->