Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-29 21:49:35 +03:00
parent bb5d6848d9
commit 0ee2f48898
29 changed files with 660 additions and 82 deletions

View file

@ -47,7 +47,6 @@ dependencies {
/** Other libraries */
implementation(deps.arrow.core)
implementation(deps.kotlin.immutable.collections)
implementation(deps.surveysparrow)
/** Core modules */
implementation(projects.core.datasource)
@ -60,6 +59,7 @@ dependencies {
/** Feature Apis */
implementation(projects.features.tester.api)
implementation(projects.features.pushNotifications.api)
implementation(projects.features.survey.api)
/* SDK */
implementation(tangemDeps.blockchain)

View file

@ -1,6 +1,5 @@
package com.tangem.feature.tester.presentation
import android.widget.Toast
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -18,7 +17,6 @@ import com.tangem.core.navigation.finisher.AppFinisher
import com.tangem.core.ui.UiDependencies
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.screen.ComposeActivity
import com.tangem.datasource.local.config.environment.EnvironmentConfig
import com.tangem.feature.tester.presentation.accounts.ui.AccountsScreen
import com.tangem.feature.tester.presentation.accounts.viewmodel.TesterAccountsViewModel
import com.tangem.feature.tester.presentation.actions.TesterActionsScreen
@ -40,9 +38,10 @@ import com.tangem.feature.tester.presentation.providers.ui.BlockchainProvidersSc
import com.tangem.feature.tester.presentation.providers.viewmodel.BlockchainProvidersViewModel
import com.tangem.feature.tester.presentation.storybook.ui.StoryBookScreen
import com.tangem.feature.tester.presentation.storybook.viewmodel.StoryBookViewModel
import com.tangem.feature.tester.presentation.surveysparrow.SurveySparrowManager
import com.tangem.feature.tester.presentation.testpush.ui.TestPushScreen
import com.tangem.feature.tester.presentation.testpush.viewmodel.TestPushViewModel
import com.tangem.features.survey.SurveyLaunchData
import com.tangem.features.survey.SurveySparrowLauncher
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.collections.immutable.persistentSetOf
import javax.inject.Inject
@ -64,7 +63,7 @@ internal class TesterActivity : ComposeActivity() {
lateinit var appRouter: AppRouter
@Inject
lateinit var environmentConfig: EnvironmentConfig
lateinit var surveySparrowLauncher: SurveySparrowLauncher
@Composable
override fun ScreenContent(modifier: Modifier) {
@ -217,29 +216,16 @@ internal class TesterActivity : ComposeActivity() {
}
private fun startSurveySparrow(): Boolean {
val token = environmentConfig.surveySparrowToken
if (token.isNullOrEmpty()) {
val toast = Toast.makeText(
this,
"Survey Sparrow is not configured. Token is missing.",
Toast.LENGTH_LONG,
)
toast.show()
return false
}
SurveySparrowManager(domain = DOMAIN, token = token).startSurveyForResult(
surveySparrowLauncher.present(
activity = this,
requestCode = SURVEY_SPARROW_REQUEST_CODE,
data = SurveyLaunchData(domain = DOMAIN, token = TEST_SHARE_TOKEN, customParams = emptyMap()),
)
return true
}
private companion object {
const val DOMAIN = "tangem.com"
const val SURVEY_SPARROW_REQUEST_CODE = 1001
const val DOMAIN = "tangem.surveysparrow.com"
const val TEST_SHARE_TOKEN = "ntt-84iF22PDajmervYneMW4kv"
}
}

View file

@ -1,55 +0,0 @@
package com.tangem.feature.tester.presentation.surveysparrow
import android.app.Activity
import com.surveysparrow.ss_android_sdk.SsSurvey
import com.surveysparrow.ss_android_sdk.SurveySparrow
import com.tangem.utils.logging.TangemLogger
/**
* Manager for Survey Sparrow SDK.
*
* @param domain Survey Sparrow domain (e.g., "yourcompany")
* @param token Survey Sparrow SDK token
*/
class SurveySparrowManager(
private val domain: String,
private val token: String,
) {
/**
* Create a SurveySparrow instance to start a survey.
*
* @param activity The activity context
* @param customVariables Optional custom variables to pass to the survey
* @return SurveySparrow instance ready to start
*/
fun createSurvey(activity: Activity, customVariables: Map<String, String>? = null): SurveySparrow? {
return try {
val survey = SsSurvey(domain, token).apply {
customVariables?.forEach { (key, value) ->
addCustomParam(key, value)
}
}
SurveySparrow(activity, survey)
} catch (e: Exception) {
TangemLogger.e("Failed to create SurveySparrow survey", e)
null
}
}
/**
* Start a survey for result.
*
* @param activity The activity context
* @param requestCode The request code for onActivityResult
* @param customVariables Optional custom variables to pass to the survey
*/
fun startSurveyForResult(activity: Activity, requestCode: Int, customVariables: Map<String, String>? = null) {
val surveySparrow = createSurvey(activity, customVariables)
if (surveySparrow != null) {
surveySparrow.startSurveyForResult(requestCode)
TangemLogger.d("SurveySparrow survey started with requestCode: $requestCode")
}
}
}