mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2866 All content | Analytics (#1631)
This commit is contained in:
parent
b24e2b94fe
commit
d37cbb4ece
5 changed files with 189 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.feature_allcontent.models
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVSortType
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
|
@ -142,7 +143,7 @@ sealed class UiContentItem {
|
|||
|
||||
// MENU
|
||||
@Immutable
|
||||
sealed class UiMenuState{
|
||||
sealed class UiMenuState {
|
||||
|
||||
data object Hidden : UiMenuState()
|
||||
|
||||
|
@ -245,4 +246,38 @@ fun ObjectWrapper.Basic.toAllContentType(
|
|||
editable = !obj.restrictions.contains(ObjectRestriction.DETAILS)
|
||||
)
|
||||
}
|
||||
|
||||
fun AllContentSort.toAnalyticsSortType(): Pair<String, String> {
|
||||
return when (this) {
|
||||
is AllContentSort.ByName -> "Name" to sortType.toAnalyticsSortType()
|
||||
is AllContentSort.ByDateUpdated -> "Updated" to sortType.toAnalyticsSortType()
|
||||
is AllContentSort.ByDateCreated -> "Created" to sortType.toAnalyticsSortType()
|
||||
}
|
||||
}
|
||||
|
||||
fun DVSortType.toAnalyticsSortType(): String {
|
||||
return when (this) {
|
||||
DVSortType.ASC -> "Asc"
|
||||
DVSortType.DESC -> "Desc"
|
||||
DVSortType.CUSTOM -> "Custom"
|
||||
}
|
||||
}
|
||||
|
||||
fun AllContentTab.toAnalyticsTabType(): String {
|
||||
return when (this) {
|
||||
AllContentTab.PAGES -> "Pages"
|
||||
AllContentTab.LISTS -> "Lists"
|
||||
AllContentTab.MEDIA -> "Media"
|
||||
AllContentTab.BOOKMARKS -> "Bookmarks"
|
||||
AllContentTab.FILES -> "Files"
|
||||
AllContentTab.TYPES -> "Types"
|
||||
}
|
||||
}
|
||||
|
||||
fun AllContentMenuMode.toAnalyticsModeType(): String {
|
||||
return when (this) {
|
||||
is AllContentMenuMode.AllContent -> "All"
|
||||
is AllContentMenuMode.Unlinked -> "Unlinked"
|
||||
}
|
||||
}
|
||||
//endregion
|
|
@ -30,9 +30,19 @@ import com.anytypeio.anytype.feature_allcontent.models.UiTitleState
|
|||
import com.anytypeio.anytype.feature_allcontent.models.createSubscriptionParams
|
||||
import com.anytypeio.anytype.feature_allcontent.models.filtersForSearch
|
||||
import com.anytypeio.anytype.feature_allcontent.models.mapRelationKeyToSort
|
||||
import com.anytypeio.anytype.feature_allcontent.models.toAnalyticsModeType
|
||||
import com.anytypeio.anytype.feature_allcontent.models.toAnalyticsSortType
|
||||
import com.anytypeio.anytype.feature_allcontent.models.toAnalyticsTabType
|
||||
import com.anytypeio.anytype.feature_allcontent.models.toUiContentItems
|
||||
import com.anytypeio.anytype.feature_allcontent.models.toUiContentTypes
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentChangeMode
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentChangeSort
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentChangeType
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentResult
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentScreen
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentSearchInput
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAllContentToBin
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectCreateEvent
|
||||
import com.anytypeio.anytype.presentation.home.OpenObjectNavigation
|
||||
import com.anytypeio.anytype.presentation.home.navigation
|
||||
|
@ -414,6 +424,12 @@ class AllContentViewModel(
|
|||
uiItemsState.value = emptyList()
|
||||
uiTabsState.value = uiTabsState.value.copy(selectedTab = tab)
|
||||
restartSubscription.value++
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentChangeType(
|
||||
analytics = analytics,
|
||||
type = tab.toAnalyticsTabType()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onAllContentModeClicked(mode: AllContentMenuMode) {
|
||||
|
@ -425,6 +441,12 @@ class AllContentViewModel(
|
|||
is AllContentMenuMode.Unlinked -> UiTitleState.OnlyUnlinked
|
||||
}
|
||||
restartSubscription.value++
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentChangeMode(
|
||||
analytics = analytics,
|
||||
type = mode.toAnalyticsModeType()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onSortClicked(sort: AllContentSort) {
|
||||
|
@ -445,6 +467,13 @@ class AllContentViewModel(
|
|||
sortState.value = newSort
|
||||
proceedWithSortSaving(newSort)
|
||||
restartSubscription.value++
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentChangeSort(
|
||||
analytics = analytics,
|
||||
type = sort.toAnalyticsSortType().first,
|
||||
sort = sort.toAnalyticsSortType().second
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithSortSaving(sort: AllContentSort) {
|
||||
|
@ -466,10 +495,22 @@ class AllContentViewModel(
|
|||
|
||||
fun onFilterChanged(filter: String) {
|
||||
Timber.d("onFilterChanged: $filter")
|
||||
val currentFilter = userInput.value.isEmpty()
|
||||
viewModelScope.launch {
|
||||
if (currentFilter && filter.isNotEmpty()) {
|
||||
sendAnalyticsAllContentSearchInput(
|
||||
analytics = analytics,
|
||||
route = EventsDictionary.Routes.allContentRoute
|
||||
)
|
||||
}
|
||||
}
|
||||
userInput.value = filter
|
||||
}
|
||||
|
||||
fun onViewBinClicked() {
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentToBin(analytics = analytics)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
commands.emit(Command.NavigateToBin(vmParams.spaceId.id))
|
||||
}
|
||||
|
@ -484,6 +525,9 @@ class AllContentViewModel(
|
|||
space = vmParams.spaceId.id
|
||||
)
|
||||
)
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentResult(analytics = analytics)
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithNavigation(navigation: OpenObjectNavigation) {
|
||||
|
@ -557,7 +601,7 @@ class AllContentViewModel(
|
|||
)
|
||||
sendAnalyticsObjectCreateEvent(
|
||||
analytics = analytics,
|
||||
route = EventsDictionary.Routes.objCreateLibrary,
|
||||
route = EventsDictionary.Routes.allContentRoute,
|
||||
startTime = startTime,
|
||||
objType = objType ?: storeOfObjectTypes.getByKey(result.typeKey.key),
|
||||
view = EventsDictionary.View.viewHome,
|
||||
|
@ -579,6 +623,11 @@ class AllContentViewModel(
|
|||
fun onStart() {
|
||||
Timber.d("onStart")
|
||||
setupUiStateFlow()
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsAllContentScreen(
|
||||
analytics = analytics
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue