Updated on 2026-08-14
This commit is contained in:
parent
8971ebef55
commit
96478230a0
9 changed files with 112 additions and 4 deletions
|
|
@ -33,13 +33,14 @@ class CustomerIoAnalyticsHandler(
|
|||
|
||||
class Builder : AnalyticsHandlerBuilder {
|
||||
override fun build(data: AnalyticsHandlerBuilder.Data): AnalyticsHandler? {
|
||||
val cdpApiKey = data.config.customerIoCdpApiKey
|
||||
return if (data.logConfig.isCustomerIoLogEnabled) {
|
||||
CustomerIoAnalyticsHandler(client = CustomerIoLogClient())
|
||||
} else if (data.config.customerIoCdpApiKey.isNotBlank()) {
|
||||
} else if (!cdpApiKey.isNullOrBlank()) {
|
||||
CustomerIoAnalyticsHandler(
|
||||
client = CustomerIoClient(
|
||||
application = data.application,
|
||||
cdpApiKey = data.config.customerIoCdpApiKey,
|
||||
cdpApiKey = cdpApiKey,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -28,5 +28,7 @@ data class EnvironmentConfig(
|
|||
val bffStaticTokenDev: String? = null,
|
||||
val gaslessTxApiKeyDev: String? = null,
|
||||
val gaslessTxApiKey: String? = null,
|
||||
val customerIoCdpApiKey: String = "",
|
||||
val customerIoCdpApiKey: String? = null,
|
||||
val surveySparrowDomain: String? = null,
|
||||
val surveySparrowToken: String? = null,
|
||||
)
|
||||
|
|
@ -49,6 +49,7 @@ dependencies {
|
|||
implementation(deps.arrow.core)
|
||||
implementation(deps.kotlin.immutable.collections)
|
||||
implementation(deps.timber)
|
||||
implementation(deps.surveysparrow)
|
||||
|
||||
/** Core modules */
|
||||
implementation(projects.core.datasource)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
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
|
||||
|
|
@ -17,6 +18,7 @@ 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
|
||||
|
|
@ -35,9 +37,10 @@ import com.tangem.feature.tester.presentation.menu.ui.TesterMenuScreen
|
|||
import com.tangem.feature.tester.presentation.navigation.InnerTesterRouter
|
||||
import com.tangem.feature.tester.presentation.navigation.TesterScreen
|
||||
import com.tangem.feature.tester.presentation.providers.ui.BlockchainProvidersScreen
|
||||
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.providers.viewmodel.BlockchainProvidersViewModel
|
||||
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 dagger.hilt.android.AndroidEntryPoint
|
||||
|
|
@ -60,6 +63,9 @@ internal class TesterActivity : ComposeActivity() {
|
|||
@Inject
|
||||
lateinit var appRouter: AppRouter
|
||||
|
||||
@Inject
|
||||
lateinit var environmentConfig: EnvironmentConfig
|
||||
|
||||
@Composable
|
||||
override fun ScreenContent(modifier: Modifier) {
|
||||
val systemBarsColor = TangemTheme.colors.background.secondary
|
||||
|
|
@ -89,6 +95,7 @@ internal class TesterActivity : ComposeActivity() {
|
|||
ButtonUM.ACCOUNTS,
|
||||
ButtonUM.ADDRESSES_INFO,
|
||||
ButtonUM.STORY_BOOK,
|
||||
ButtonUM.SURVEY_SPARROW,
|
||||
),
|
||||
onButtonClick = { buttonUM ->
|
||||
val route = when (buttonUM) {
|
||||
|
|
@ -101,6 +108,7 @@ internal class TesterActivity : ComposeActivity() {
|
|||
ButtonUM.ACCOUNTS -> TesterScreen.ACCOUNTS
|
||||
ButtonUM.ADDRESSES_INFO -> TesterScreen.ADDRESSES_INFO
|
||||
ButtonUM.STORY_BOOK -> TesterScreen.STORY_BOOK
|
||||
ButtonUM.SURVEY_SPARROW -> TesterScreen.SURVEY_SPARROW
|
||||
}
|
||||
|
||||
innerTesterRouter.open(route)
|
||||
|
|
@ -192,6 +200,42 @@ internal class TesterActivity : ComposeActivity() {
|
|||
|
||||
StoryBookScreen(state)
|
||||
}
|
||||
|
||||
composable(route = TesterScreen.SURVEY_SPARROW.name) {
|
||||
LaunchedEffect(Unit) {
|
||||
val isSuccess = startSurveySparrow()
|
||||
if (isSuccess) {
|
||||
innerTesterRouter.back()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startSurveySparrow(): Boolean {
|
||||
val domain = environmentConfig.surveySparrowDomain
|
||||
val token = environmentConfig.surveySparrowToken
|
||||
|
||||
if (domain.isNullOrEmpty() || token.isNullOrEmpty()) {
|
||||
val toast = Toast.makeText(
|
||||
this,
|
||||
"Survey Sparrow is not configured. Domain or token is missing.",
|
||||
Toast.LENGTH_LONG,
|
||||
)
|
||||
|
||||
toast.show()
|
||||
return false
|
||||
}
|
||||
|
||||
SurveySparrowManager(domain = domain, token = token).startSurveyForResult(
|
||||
activity = this,
|
||||
requestCode = SURVEY_SPARROW_REQUEST_CODE,
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val SURVEY_SPARROW_REQUEST_CODE = 1001
|
||||
}
|
||||
}
|
||||
|
|
@ -27,5 +27,6 @@ data class TesterMenuUM(
|
|||
ACCOUNTS(R.string.accounts),
|
||||
ADDRESSES_INFO(R.string.addresses_info),
|
||||
STORY_BOOK(R.string.story_book),
|
||||
SURVEY_SPARROW(R.string.survey_sparrow),
|
||||
}
|
||||
}
|
||||
|
|
@ -16,4 +16,5 @@ internal enum class TesterScreen {
|
|||
ACCOUNTS,
|
||||
ADDRESSES_INFO,
|
||||
STORY_BOOK,
|
||||
SURVEY_SPARROW,
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
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 timber.log.Timber
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
Timber.e(e, "Failed to create SurveySparrow survey")
|
||||
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)
|
||||
Timber.d("SurveySparrow survey started with requestCode: $requestCode")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,4 +23,5 @@
|
|||
<string name="news_details_bottom_sheet" translatable="false">News details (Bottom Sheet)</string>
|
||||
<string name="addresses_info" translatable="false">Addresses info</string>
|
||||
<string name="story_book" translatable="false">Story book</string>
|
||||
<string name="survey_sparrow" translatable="false">Survey Sparrow</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ sumsub = "1.38.0"
|
|||
haze = "1.7.1"
|
||||
kotlinpoet = "1.18.1"
|
||||
customerio = "4.6.3"
|
||||
surveysparrow = "1.2.9"
|
||||
# endregion Other libraries
|
||||
|
||||
# region Tools
|
||||
|
|
@ -316,4 +317,5 @@ haze = { module = "dev.chrisbanes.haze:haze", version.ref = "haze" }
|
|||
haze-materials = { module = "dev.chrisbanes.haze:haze-materials", version.ref = "haze" }
|
||||
customerio-analytics = { module = "io.customer.android:datapipelines", version.ref = "customerio" }
|
||||
customerio-messaging = { module = "io.customer.android:messaging-push-fcm", version.ref = "customerio" }
|
||||
surveysparrow = { module = "com.github.surveysparrow:surveysparrow-android-sdk", version.ref = "surveysparrow" }
|
||||
# endregion Other
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue