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

DROID-1835 Analytics | Added space-deletion events (#528)

This commit is contained in:
Evgenii Kozlov 2023-11-09 15:56:12 +01:00 committed by uburoiubu
parent eb51225b72
commit 5f642f6b99
No known key found for this signature in database
GPG key ID: C8FB80E0A595FBB6
5 changed files with 60 additions and 3 deletions

View file

@ -20,6 +20,9 @@ object EventsDictionary {
// Settings events
const val screenSettingSpacesSpaceIndex = "ScreenSettingsSpaceIndex"
const val clickDeleteSpace = "ClickDeleteSpace"
const val clickDeleteSpaceWarning = "ClickDeleteSpaceWarning"
const val deleteSpace = "DeleteSpace"
const val wallpaperSet = "SettingsWallpaperSet"
@ -207,6 +210,7 @@ object EventsDictionary {
const val objPowerTool = "Powertool"
const val objTurnInto = "TurnInto"
const val screenSettings = "ScreenSettings"
const val settings = "Settings"
const val screenDeletion = "ScreenDeletion"
const val navigation = "Navigation"
}

View file

@ -12,7 +12,9 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@ -47,7 +49,9 @@ fun PreviewWhatIsRecoveryPhraseScreen() {
@Composable
fun WhatIsRecoveryPhraseScreen() {
Column(
modifier = Modifier.padding(horizontal = 24.dp)
modifier = Modifier
.padding(horizontal = 24.dp)
.verticalScroll(rememberScrollState())
) {
Dragger(
modifier = Modifier

View file

@ -82,10 +82,14 @@ class SpaceSettingsFragment : BaseBottomSheetComposeFragment() {
spaceData = vm.spaceViewState.collectAsStateWithLifecycle().value,
onDeleteSpaceClicked = throttledClick(
onClick = {
vm.onDeleteSpaceClicked()
val dialog = DeleteSpaceWarning.new()
dialog.onDeletionAccepted = {
dialog.dismiss()
vm.onDeleteSpaceClicked()
vm.onDeleteSpaceAcceptedClicked()
}
dialog.onDeletionCancelled = {
vm.onDeleteSpaceWarningCancelled()
}
dialog.show(childFragmentManager, null)
}

View file

@ -20,6 +20,7 @@ class DeleteSpaceWarning : BaseBottomSheetComposeFragment() {
private val name: String get() = arg(ARG_NAME)
var onDeletionAccepted: () -> Unit = {}
var onDeletionCancelled: () -> Unit = {}
override fun onCreateView(
inflater: LayoutInflater,
@ -35,7 +36,10 @@ class DeleteSpaceWarning : BaseBottomSheetComposeFragment() {
cancelButtonText = stringResource(R.string.back),
title = stringResource(R.string.delete_space_title),
subtitle = stringResource(R.string.delete_space_subtitle),
onNegativeClick = { dismiss() },
onNegativeClick = {
onDeletionCancelled()
dismiss()
},
onPositiveClick = { onDeletionAccepted() },
isInProgress = false
)

View file

@ -4,6 +4,10 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.anytypeio.anytype.analytics.base.Analytics
import com.anytypeio.anytype.analytics.base.EventsDictionary
import com.anytypeio.anytype.analytics.base.EventsPropertiesKey
import com.anytypeio.anytype.analytics.base.sendEvent
import com.anytypeio.anytype.analytics.props.Props
import com.anytypeio.anytype.core_models.Filepath
import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.core_models.PERSONAL_SPACE_TYPE
@ -154,6 +158,42 @@ class SpaceSettingsViewModel(
}
fun onDeleteSpaceClicked() {
viewModelScope.launch {
analytics.sendEvent(
eventName = EventsDictionary.clickDeleteSpace,
props = Props(mapOf(EventsPropertiesKey.route to EventsDictionary.Routes.settings))
)
}
}
fun onDeleteSpaceWarningCancelled() {
viewModelScope.launch {
analytics.sendEvent(
eventName = EventsDictionary.clickDeleteSpaceWarning,
props = Props(
mapOf(
EventsPropertiesKey.type to "Cancel"
)
)
)
}
}
fun onDeleteSpaceAcceptedClicked() {
viewModelScope.launch {
analytics.sendEvent(
eventName = EventsDictionary.clickDeleteSpaceWarning,
props = Props(
mapOf(
EventsPropertiesKey.type to "Delete"
)
)
)
}
proceedWithSpaceDeletion()
}
private fun proceedWithSpaceDeletion() {
val state = spaceViewState.value
if (state is ViewState.Success) {
val space = state.data.spaceId
@ -167,6 +207,7 @@ class SpaceSettingsViewModel(
viewModelScope.launch {
deleteSpace.async(params = SpaceId(space)).fold(
onSuccess = {
analytics.sendEvent(eventName = EventsDictionary.deleteSpace)
fallbackToPersonalSpaceAfterDeletion(personalSpaceId)
},
onFailure = {