mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1260 App | Analytics params (#3184)
* DROID-1260 analytics id * DROID-1260 send analytics id to amplitude * DROID-1260 fix tests
This commit is contained in:
parent
c662515cb4
commit
25fd0ad5d6
14 changed files with 43 additions and 24 deletions
|
@ -210,7 +210,8 @@ object SetupNewAccountModule {
|
|||
analytics: Analytics,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
spaceGradientProvider: SpaceGradientProvider
|
||||
spaceGradientProvider: SpaceGradientProvider,
|
||||
configStorage: ConfigStorage
|
||||
): SetupNewAccountViewModelFactory {
|
||||
return SetupNewAccountViewModelFactory(
|
||||
createAccount = createAccount,
|
||||
|
@ -218,7 +219,8 @@ object SetupNewAccountModule {
|
|||
analytics = analytics,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager = objectTypesSubscriptionManager,
|
||||
spaceGradientProvider = spaceGradientProvider
|
||||
spaceGradientProvider = spaceGradientProvider,
|
||||
configStorage = configStorage
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ object MainEntryModule {
|
|||
logout: Logout,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
checkAuthorizationStatus: CheckAuthorizationStatus
|
||||
checkAuthorizationStatus: CheckAuthorizationStatus,
|
||||
configStorage: ConfigStorage
|
||||
): MainViewModelFactory = MainViewModelFactory(
|
||||
resumeAccount = resumeAccount,
|
||||
analytics = analytics,
|
||||
|
@ -65,7 +66,8 @@ object MainEntryModule {
|
|||
logout = logout,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager = objectTypesSubscriptionManager,
|
||||
checkAuthorizationStatus = checkAuthorizationStatus
|
||||
checkAuthorizationStatus = checkAuthorizationStatus,
|
||||
configStorage = configStorage
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -12,5 +12,6 @@ data class Config(
|
|||
val profile: Id,
|
||||
val gateway: Url,
|
||||
val workspace: Id,
|
||||
val widgets: Id
|
||||
val widgets: Id,
|
||||
val analytics: Id
|
||||
)
|
|
@ -36,7 +36,7 @@ class LaunchAccount(
|
|||
)
|
||||
configStorage.set(config = setup.config)
|
||||
workspaceManager.setCurrentWorkspace(setup.config.workspace)
|
||||
Either.Right(setup.account.id)
|
||||
Either.Right(setup.config.analytics)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Either.Left(e)
|
||||
|
|
|
@ -35,7 +35,7 @@ class SelectAccount(
|
|||
)
|
||||
configStorage.set(config = setup.config)
|
||||
workspaceManager.setCurrentWorkspace(setup.config.workspace)
|
||||
StartAccountResult(setup.account.id, setup.status)
|
||||
StartAccountResult(setup.config.analytics, setup.status)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -156,7 +156,7 @@ class StartAccountTest {
|
|||
|
||||
val result = selectAccount.run(params)
|
||||
|
||||
assertTrue { result == Either.Right(Pair(account.id, AccountStatus.Active)) }
|
||||
assertTrue { result == Either.Right(Pair(config.analytics, AccountStatus.Active)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -206,7 +206,7 @@ class StartAccountTest {
|
|||
enableSpaces = false
|
||||
)
|
||||
|
||||
assertTrue { result == Either.Right(Pair(account.id, AccountStatus.Active)) }
|
||||
assertTrue { result == Either.Right(Pair(config.analytics, AccountStatus.Active)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -256,7 +256,7 @@ class StartAccountTest {
|
|||
enableSpaces = false
|
||||
)
|
||||
|
||||
assertTrue { result == Either.Right(Pair(account.id, AccountStatus.Active)) }
|
||||
assertTrue { result == Either.Right(Pair(config.analytics, AccountStatus.Active)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -35,7 +35,8 @@ fun Rpc.Account.Create.Response.toAccountSetup() : AccountSetup {
|
|||
profile = info.profileObjectId,
|
||||
gateway = info.gatewayUrl,
|
||||
workspace = info.accountSpaceId,
|
||||
widgets = info.widgetsId
|
||||
widgets = info.widgetsId,
|
||||
analytics = info.analyticsId
|
||||
),
|
||||
status = status.core()
|
||||
)
|
||||
|
@ -69,7 +70,8 @@ fun Rpc.Account.Select.Response.toAccountSetup(): AccountSetup {
|
|||
profile = info.profileObjectId,
|
||||
gateway = info.gatewayUrl,
|
||||
workspace = info.accountSpaceId,
|
||||
widgets = info.widgetsId
|
||||
widgets = info.widgetsId,
|
||||
analytics = info.analyticsId
|
||||
),
|
||||
status = status.core()
|
||||
)
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.analytics.props.UserProperty
|
|||
import com.anytypeio.anytype.core_models.exceptions.CreateAccountException
|
||||
import com.anytypeio.anytype.core_utils.common.EventWrapper
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CreateAccount
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||
import com.anytypeio.anytype.presentation.auth.model.Session
|
||||
|
@ -36,7 +37,8 @@ class SetupNewAccountViewModel(
|
|||
private val analytics: Analytics,
|
||||
private val relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
private val objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
private val spaceGradientProvider: SpaceGradientProvider
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModel(), SupportNavigation<EventWrapper<AppNavigation.Command>> {
|
||||
|
||||
override val navigation: MutableLiveData<EventWrapper<AppNavigation.Command>> =
|
||||
|
@ -103,7 +105,7 @@ class SetupNewAccountViewModel(
|
|||
Timber.e(error, "Error while creating account")
|
||||
},
|
||||
fnR = { account ->
|
||||
updateUserProps(account.id)
|
||||
updateUserProps(configStorage.get().analytics)
|
||||
sendAuthEvent(startTime)
|
||||
_state.postValue(SetupNewAccountViewState.Success)
|
||||
relationsSubscriptionManager.onStart()
|
||||
|
|
|
@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.domain.auth.interactor.CreateAccount
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||
import com.anytypeio.anytype.presentation.auth.model.Session
|
||||
|
@ -15,7 +16,8 @@ class SetupNewAccountViewModelFactory(
|
|||
private val analytics: Analytics,
|
||||
private val relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
private val objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
private val spaceGradientProvider: SpaceGradientProvider
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -26,7 +28,8 @@ class SetupNewAccountViewModelFactory(
|
|||
analytics = analytics,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager = objectTypesSubscriptionManager,
|
||||
spaceGradientProvider = spaceGradientProvider
|
||||
spaceGradientProvider = spaceGradientProvider,
|
||||
configStorage = configStorage
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -69,10 +69,10 @@ class SetupSelectedAccountViewModel(
|
|||
error.postValue("$ERROR_MESSAGE: $msg")
|
||||
}
|
||||
},
|
||||
success = { (accountId, status) ->
|
||||
success = { (analyticsId, status) ->
|
||||
migrationMessageJob.cancel()
|
||||
isMigrationInProgress.value = false
|
||||
updateUserProps(accountId)
|
||||
updateUserProps(analyticsId)
|
||||
sendEvent(startTime)
|
||||
if (status is AccountStatus.PendingDeletion) {
|
||||
navigation.postValue(
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.anytypeio.anytype.domain.auth.interactor.ResumeAccount
|
|||
import com.anytypeio.anytype.domain.auth.model.AuthStatus
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Interactor
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.wallpaper.ObserveWallpaper
|
||||
|
@ -35,6 +36,7 @@ class MainViewModel(
|
|||
private val relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
private val objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
private val checkAuthorizationStatus: CheckAuthorizationStatus,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModel() {
|
||||
|
||||
val wallpaper = MutableStateFlow<Wallpaper>(Wallpaper.Default)
|
||||
|
@ -105,7 +107,7 @@ class MainViewModel(
|
|||
objectTypesSubscriptionManager.onStart()
|
||||
updateUserProperties(
|
||||
analytics = analytics,
|
||||
userProperty = UserProperty.AccountId(id)
|
||||
userProperty = UserProperty.AccountId(configStorage.get().analytics)
|
||||
)
|
||||
Timber.d("Restored account after activity recreation")
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.anytypeio.anytype.domain.account.InterceptAccountStatus
|
|||
import com.anytypeio.anytype.domain.auth.interactor.CheckAuthorizationStatus
|
||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||
import com.anytypeio.anytype.domain.auth.interactor.ResumeAccount
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||
import com.anytypeio.anytype.domain.wallpaper.ObserveWallpaper
|
||||
|
@ -22,6 +23,7 @@ class MainViewModelFactory(
|
|||
private val relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
private val objectTypesSubscriptionManager: ObjectTypesSubscriptionManager,
|
||||
private val checkAuthorizationStatus: CheckAuthorizationStatus,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(
|
||||
|
@ -35,6 +37,7 @@ class MainViewModelFactory(
|
|||
logout = logout,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager = objectTypesSubscriptionManager,
|
||||
checkAuthorizationStatus = checkAuthorizationStatus
|
||||
checkAuthorizationStatus = checkAuthorizationStatus,
|
||||
configStorage = configStorage
|
||||
) as T
|
||||
}
|
|
@ -99,8 +99,8 @@ class SplashViewModel(
|
|||
val startTime = System.currentTimeMillis()
|
||||
viewModelScope.launch {
|
||||
launchAccount(BaseUseCase.None).proceed(
|
||||
success = { accountId ->
|
||||
updateUserProps(accountId)
|
||||
success = { analyticsId ->
|
||||
updateUserProps(analyticsId)
|
||||
val props = Props.empty()
|
||||
sendEvent(startTime, openAccount, props)
|
||||
proceedWithGlobalSubscriptions()
|
||||
|
|
|
@ -31,13 +31,15 @@ fun StubConfig(
|
|||
profile: Id = MockDataFactory.randomUuid(),
|
||||
gateway: Url = MockDataFactory.randomUuid(),
|
||||
workspace: Id = MockDataFactory.randomUuid(),
|
||||
widgets: Id = MockDataFactory.randomUuid()
|
||||
widgets: Id = MockDataFactory.randomUuid(),
|
||||
analytics: Id = MockDataFactory.randomUuid()
|
||||
) : Config = Config(
|
||||
home = home,
|
||||
profile = profile,
|
||||
gateway = gateway,
|
||||
workspace = workspace,
|
||||
widgets = widgets
|
||||
widgets = widgets,
|
||||
analytics = analytics
|
||||
)
|
||||
|
||||
fun StubFeatureConfig(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue