Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ object EventsDictionary {
// Vault events

const val screenVault = "ScreenVault"
const val screenChatInfo = "ScreenChatInfo"

// About-app screen

Expand Down Expand Up @@ -362,6 +363,9 @@ object EventsDictionary {
const val chatClickScrollToMention = "ClickScrollToMention"
const val chatClickScrollToReply = "ClickScrollToReply"

// Notification changes
const val changeMessageNotificationState = "ChangeMessageNotificationState"

// --- Vault menu ---
const val chatScreenVaultCreateMenu = "ScreenVaultCreateMenu"
const val chatClickVaultCreateMenuChat = "ClickVaultCreateMenuChat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.anytypeio.anytype.di.feature.widgets

import androidx.lifecycle.ViewModelProvider
import com.anytypeio.anytype.analytics.base.Analytics
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
import com.anytypeio.anytype.di.common.ComponentDependencies
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
Expand Down Expand Up @@ -44,6 +45,7 @@ object CreateChatObjectModule {
}

interface CreateChatObjectDependencies : ComponentDependencies {
fun analytics(): Analytics
fun repo(): BlockRepository
fun dispatchers(): AppCoroutineDispatchers
fun settings(): UserSettingsRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,8 @@ class ChatViewModel @Inject constructor(
val headerView = header.value
if (headerView is HeaderView.ChatObject) {
val name = headerView.title
// Fire analytics event for opening chat info screen
analytics.sendEvent(eventName = EventsDictionary.screenChatInfo)
commands.emit(
ViewModelCommand.OpenChatInfo(
name = name,
Expand Down Expand Up @@ -2126,6 +2128,10 @@ class ChatViewModel @Inject constructor(
)
).onSuccess { payload ->
Timber.d("Notification setting changed successfully to: $setting")
// Fire analytics event for chat-level notification change
analytics.sendEvent(
eventName = EventsDictionary.changeMessageNotificationState
)
}.onFailure { e ->
Timber.e(e, "Failed to change notification setting")
// Revert header to previous state on error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,17 @@ class SpaceSettingsViewModel(
onSuccess = {
_notificationState.value = newState
Timber.d("Successfully set notification state to: $newState for space: $targetSpaceId")
// Fire analytics event for space-level notification change if it's a chat/one-to-one space
val spaceView = spaceViewContainer.get(vmParams.space)
if (spaceView != null &&
(spaceView.spaceUxType == SpaceUxType.CHAT || spaceView.spaceUxType == SpaceUxType.ONE_TO_ONE)) {
analytics.sendEvent(
eventName = EventsDictionary.changeMessageNotificationState,
props = Props(
mapOf(EventsPropertiesKey.uxType to "Chat")
)
)
}
},
onFailure = { error ->
Timber.e("Failed to set notification state: $error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package com.anytypeio.anytype.presentation.widgets
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.Block
import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.core_models.Name
Expand All @@ -26,6 +31,7 @@ import timber.log.Timber

class CreateChatObjectViewModel(
private val vmParams: VmParams,
private val analytics: Analytics,
private val createObject: CreateObject,
private val uploadFile: UploadFile,
private val setObjectDetails: SetObjectDetails
Expand Down Expand Up @@ -139,6 +145,13 @@ class CreateChatObjectViewModel(
}

private suspend fun finishCreation(objectId: Id) {
// Fire CreateObject analytics event
analytics.sendEvent(
eventName = EventsDictionary.objectCreate,
props = Props(
mapOf(EventsPropertiesKey.objectType to ObjectTypeIds.CHAT_DERIVED)
)
)
isLoading.value = false
commands.emit(Command.ChatObjectCreated(objectId = objectId))
}
Expand Down Expand Up @@ -171,6 +184,7 @@ class CreateChatObjectViewModel(

class Factory @Inject constructor(
private val vmParams: VmParams,
private val analytics: Analytics,
private val createObject: CreateObject,
private val uploadFile: UploadFile,
private val setObjectDetails: SetObjectDetails
Expand All @@ -180,6 +194,7 @@ class CreateChatObjectViewModel(
modelClass: Class<T>
) = CreateChatObjectViewModel(
vmParams = vmParams,
analytics = analytics,
createObject = createObject,
uploadFile = uploadFile,
setObjectDetails = setObjectDetails
Expand Down