diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/server/ServerConfig.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/server/ServerConfig.kt index 149493abf25..3bb8a0273a8 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/server/ServerConfig.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/server/ServerConfig.kt @@ -134,6 +134,19 @@ data class ServerConfig( isOnPremises = false, apiProxy = null ) + + val DUMMY = Links( + api = """https://dummy-nginz-https.zinfra.io""", + accounts = """https://wire-account-dummy.zinfra.io""", + webSocket = """https://dummy-nginz-ssl.zinfra.io""", + teams = """https://wire-teams-dummy.zinfra.io""", + blackList = """https://clientblacklist.wire.com/dummy""", + website = """https://dummy.wire.com""", + title = "dummy", + isOnPremises = false, + apiProxy = null + ) + val DEFAULT = PRODUCTION private const val FORGOT_PASSWORD_PATH = "forgot" diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt index f787659532b..d6e3e4b2581 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt @@ -153,6 +153,7 @@ import com.wire.kalium.logic.di.PlatformUserStorageProperties import com.wire.kalium.logic.di.RootPathsProvider import com.wire.kalium.logic.di.UserStorageProvider import com.wire.kalium.logic.feature.analytics.AnalyticsIdentifierManager +import com.wire.kalium.logic.feature.analytics.GetCurrentAnalyticsTrackingIdentifierUseCase import com.wire.kalium.logic.feature.analytics.ObserveAnalyticsTrackingIdentifierStatusUseCase import com.wire.kalium.logic.feature.applock.AppLockTeamFeatureConfigObserver import com.wire.kalium.logic.feature.applock.AppLockTeamFeatureConfigObserverImpl @@ -1495,6 +1496,9 @@ class UserSessionScope internal constructor( val observeAnalyticsTrackingIdentifierStatus: ObserveAnalyticsTrackingIdentifierStatusUseCase get() = ObserveAnalyticsTrackingIdentifierStatusUseCase(userConfigRepository, userScopedLogger) + val getCurrentAnalyticsTrackingIdentifier: GetCurrentAnalyticsTrackingIdentifierUseCase + get() = GetCurrentAnalyticsTrackingIdentifierUseCase(userConfigRepository) + val analyticsIdentifierManager: AnalyticsIdentifierManager get() = AnalyticsIdentifierManager( messages.messageSender, diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCase.kt new file mode 100644 index 00000000000..03896e59a41 --- /dev/null +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCase.kt @@ -0,0 +1,40 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.logic.feature.analytics + +import com.wire.kalium.logic.configuration.UserConfigRepository + +/** + * Use case that returns the current analytics tracking identifier + */ +interface GetCurrentAnalyticsTrackingIdentifierUseCase { + /** + * Use case [GetCurrentAnalyticsTrackingIdentifierUseCase] operation + * + * @return a [String] containing the current tracking identifier + */ + suspend operator fun invoke(): String? +} + +@Suppress("FunctionNaming") +internal fun GetCurrentAnalyticsTrackingIdentifierUseCase( + userConfigRepository: UserConfigRepository +) = object : GetCurrentAnalyticsTrackingIdentifierUseCase { + + override suspend fun invoke(): String? = userConfigRepository.getCurrentTrackingIdentifier() +} diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCaseTest.kt new file mode 100644 index 00000000000..566e174e0e6 --- /dev/null +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/analytics/GetCurrentAnalyticsTrackingIdentifierUseCaseTest.kt @@ -0,0 +1,63 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.logic.feature.analytics + +import com.wire.kalium.logic.util.arrangement.repository.UserConfigRepositoryArrangement +import com.wire.kalium.logic.util.arrangement.repository.UserConfigRepositoryArrangementImpl +import io.mockative.coVerify +import io.mockative.once +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals + +class GetCurrentAnalyticsTrackingIdentifierUseCaseTest { + + @Test + fun givenCurrentAnalyticsTrackingId_whenGettingTrackingId_thenCurrentTrackingIdIsReturned() = runTest { + // given + val (arrangement, useCase) = Arrangement().arrange { + withGetTrackingIdentifier(CURRENT_IDENTIFIER) + } + + // when + val result = useCase() + + // then + assertEquals(CURRENT_IDENTIFIER, result) + coVerify { + arrangement.userConfigRepository.getCurrentTrackingIdentifier() + }.wasInvoked(exactly = once) + } + + private companion object { + const val CURRENT_IDENTIFIER = "efgh-5678" + } + + private class Arrangement : UserConfigRepositoryArrangement by UserConfigRepositoryArrangementImpl() { + + private val useCase: GetCurrentAnalyticsTrackingIdentifierUseCase = GetCurrentAnalyticsTrackingIdentifierUseCase( + userConfigRepository = userConfigRepository + ) + + fun arrange(block: suspend Arrangement.() -> Unit): Pair { + runBlocking { block() } + return this to useCase + } + } +}