mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1823 Analytics | Create-space analytics (#529)
This commit is contained in:
parent
400417deac
commit
c8b3a92e8e
4 changed files with 31 additions and 6 deletions
|
@ -23,7 +23,10 @@ object EventsDictionary {
|
|||
const val screenSettingsAccount = "ScreenSettingsAccount"
|
||||
const val clickDeleteSpace = "ClickDeleteSpace"
|
||||
const val clickDeleteSpaceWarning = "ClickDeleteSpaceWarning"
|
||||
const val createSpace = "CreateSpace"
|
||||
const val switchSpace = "SwitchSpace"
|
||||
const val deleteSpace = "DeleteSpace"
|
||||
const val screenSettingsSpaceCreate = "ScreenSettingsSpaceCreate"
|
||||
|
||||
|
||||
const val wallpaperSet = "SettingsWallpaperSet"
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
|
|||
import com.anytypeio.anytype.CrashReporter
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary
|
||||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.exceptions.CreateAccountException
|
||||
|
@ -108,6 +109,9 @@ class OnboardingSetProfileNameViewModel @Inject constructor(
|
|||
}
|
||||
},
|
||||
fnR = {
|
||||
viewModelScope.launch {
|
||||
analytics.sendEvent(eventName = EventsDictionary.createSpace)
|
||||
}
|
||||
createAccountAnalytics(startTime)
|
||||
val config = configStorage.getOrNull()
|
||||
if (config != null) {
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.anytypeio.anytype.presentation.spaces
|
|||
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.sendEvent
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
|
@ -17,7 +20,8 @@ import timber.log.Timber
|
|||
class CreateSpaceViewModel(
|
||||
private val createSpace: CreateSpace,
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val spaceManager: SpaceManager
|
||||
private val spaceManager: SpaceManager,
|
||||
private val analytics: Analytics
|
||||
) : BaseViewModel() {
|
||||
|
||||
val isInProgress = MutableStateFlow(false)
|
||||
|
@ -33,6 +37,10 @@ class CreateSpaceViewModel(
|
|||
to = gradient.to
|
||||
)
|
||||
spaceGradient = MutableStateFlow(view)
|
||||
|
||||
viewModelScope.launch {
|
||||
analytics.sendEvent(eventName = EventsDictionary.screenSettingsSpaceCreate)
|
||||
}
|
||||
}
|
||||
|
||||
val isDismissed = MutableStateFlow(false)
|
||||
|
@ -57,6 +65,7 @@ class CreateSpaceViewModel(
|
|||
result.fold(
|
||||
onLoading = { isInProgress.value = true },
|
||||
onSuccess = { space: Id ->
|
||||
analytics.sendEvent(eventName = EventsDictionary.createSpace)
|
||||
setNewSpaceAsCurrentSpace(space)
|
||||
Timber.d("Successfully created space: $space").also {
|
||||
isDismissed.value = true
|
||||
|
@ -95,7 +104,8 @@ class CreateSpaceViewModel(
|
|||
class Factory @Inject constructor(
|
||||
private val createSpace: CreateSpace,
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val spaceManager: SpaceManager
|
||||
private val spaceManager: SpaceManager,
|
||||
private val analytics: Analytics
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(
|
||||
|
@ -103,7 +113,8 @@ class CreateSpaceViewModel(
|
|||
) = CreateSpaceViewModel(
|
||||
createSpace = createSpace,
|
||||
spaceGradientProvider = spaceGradientProvider,
|
||||
spaceManager = spaceManager
|
||||
spaceManager = spaceManager,
|
||||
analytics = analytics
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@ package com.anytypeio.anytype.presentation.spaces
|
|||
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.sendEvent
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
|
@ -45,7 +48,8 @@ class SelectSpaceViewModel(
|
|||
private val urlBuilder: UrlBuilder,
|
||||
private val saveCurrentSpace: SaveCurrentSpace,
|
||||
private val appActionManager: AppActionManager,
|
||||
private val getDefaultObjectType: GetDefaultObjectType
|
||||
private val getDefaultObjectType: GetDefaultObjectType,
|
||||
private val analytics: Analytics
|
||||
) : BaseViewModel() {
|
||||
|
||||
val views = MutableStateFlow<List<SelectSpaceView>>(emptyList())
|
||||
|
@ -181,6 +185,7 @@ class SelectSpaceViewModel(
|
|||
viewModelScope.launch {
|
||||
Timber.d("Setting space: $view")
|
||||
if (!view.isSelected) {
|
||||
analytics.sendEvent(eventName = EventsDictionary.switchSpace)
|
||||
spaceManager.set(view.space)
|
||||
saveCurrentSpace.async(SaveCurrentSpace.Params(SpaceId(view.space))).fold(
|
||||
onFailure = {
|
||||
|
@ -243,7 +248,8 @@ class SelectSpaceViewModel(
|
|||
private val urlBuilder: UrlBuilder,
|
||||
private val saveCurrentSpace: SaveCurrentSpace,
|
||||
private val appActionManager: AppActionManager,
|
||||
private val getDefaultObjectType: GetDefaultObjectType
|
||||
private val getDefaultObjectType: GetDefaultObjectType,
|
||||
private val analytics: Analytics
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(
|
||||
|
@ -255,7 +261,8 @@ class SelectSpaceViewModel(
|
|||
urlBuilder = urlBuilder,
|
||||
saveCurrentSpace = saveCurrentSpace,
|
||||
appActionManager = appActionManager,
|
||||
getDefaultObjectType = getDefaultObjectType
|
||||
getDefaultObjectType = getDefaultObjectType,
|
||||
analytics = analytics
|
||||
) as T
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue