Updated on 2026-08-14
This commit is contained in:
parent
4caff5dc00
commit
dd0a223583
5 changed files with 33 additions and 2 deletions
|
|
@ -495,6 +495,8 @@ internal class ChildFactory @Inject constructor(
|
|||
context = context,
|
||||
params = UsedeskComponent.Params(
|
||||
userWalletId = route.walletMetaInfo.userWalletId?.stringValue,
|
||||
source = route.source,
|
||||
prefilledMessage = route.prefilledMessage,
|
||||
),
|
||||
componentFactory = usedeskComponentFactory,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -100,9 +100,19 @@ sealed class AppRoute(val path: String) : Route {
|
|||
val userWalletId: UserWalletId,
|
||||
) : AppRoute(path = "/details/security")
|
||||
|
||||
/**
|
||||
* Support chat (Usedesk) screen.
|
||||
*
|
||||
* @property walletMetaInfo wallet meta info; its user wallet id is sent to Usedesk as the client email
|
||||
* @property source source of the chat opening (Settings by default, Swap for FR-02). Drives both
|
||||
* analytics and the Usedesk additional fields mapped by the component.
|
||||
* @property prefilledMessage optional message sent to the chat on behalf of the user right after init
|
||||
*/
|
||||
@Serializable
|
||||
data class Usedesk(
|
||||
val walletMetaInfo: WalletMetaInfo,
|
||||
val source: AnalyticsParam.ScreensSources = AnalyticsParam.ScreensSources.Settings,
|
||||
val prefilledMessage: String? = null,
|
||||
) : AppRoute(path = "/usedesk/${walletMetaInfo.userWalletId}")
|
||||
|
||||
@Serializable
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@ dependencies {
|
|||
/** Core */
|
||||
implementation(projects.core.decompose)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.analytics.models)
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.feature.usedesk.api
|
||||
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.decompose.factory.ComponentFactory
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
|
||||
|
|
@ -8,6 +9,13 @@ interface UsedeskComponent : ComposableContentComponent {
|
|||
data class Params(
|
||||
/** User wallet id (hex string) sent to Usedesk as the client email to identify the user. */
|
||||
val userWalletId: String? = null,
|
||||
/**
|
||||
* Source of the chat opening. Drives the analytics source and the Usedesk additional fields,
|
||||
* which the component maps internally (e.g. [AnalyticsParam.ScreensSources.Swap] -> `swap`).
|
||||
*/
|
||||
val source: AnalyticsParam.ScreensSources = AnalyticsParam.ScreensSources.Settings,
|
||||
/** Optional message sent to the chat on behalf of the user right after initialization. */
|
||||
val prefilledMessage: String? = null,
|
||||
)
|
||||
|
||||
interface Factory : ComponentFactory<Params, UsedeskComponent>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.feature.usedesk.model
|
|||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.analytics.models.AnalyticsParam.ScreensSources
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
|
|
@ -52,6 +52,8 @@ internal class UsedeskModel @Inject constructor(
|
|||
channelId = CHANNEL_ID,
|
||||
clientId = clientId,
|
||||
clientEmail = params.userWalletId,
|
||||
clientInitMessage = params.prefilledMessage,
|
||||
additionalFields = additionalFieldsFor(params.source),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -61,7 +63,7 @@ internal class UsedeskModel @Inject constructor(
|
|||
if (isScreenLoadEventSent) return
|
||||
isScreenLoadEventSent = true
|
||||
analyticsEventHandler.send(
|
||||
UsedeskAnalyticsEvents.ChatScreenOpened(source = AnalyticsParam.ScreensSources.Settings),
|
||||
UsedeskAnalyticsEvents.ChatScreenOpened(source = params.source),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -87,6 +89,11 @@ internal class UsedeskModel @Inject constructor(
|
|||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun additionalFieldsFor(source: ScreensSources): Map<Long, String> = when (source) {
|
||||
ScreensSources.Swap -> mapOf(SWAP_ADDITIONAL_FIELD_ID to SWAP_ADDITIONAL_FIELD_VALUE)
|
||||
else -> emptyMap()
|
||||
}
|
||||
|
||||
private suspend fun getOrCreateClientId(): String {
|
||||
var clientId = ""
|
||||
appPreferencesStore.editData { preferences ->
|
||||
|
|
@ -105,5 +112,8 @@ internal class UsedeskModel @Inject constructor(
|
|||
const val URL_CHAT_API = "https://ud.tangem.org"
|
||||
const val COMPANY_ID = "2"
|
||||
const val CHANNEL_ID = "54"
|
||||
|
||||
const val SWAP_ADDITIONAL_FIELD_ID = 245L
|
||||
const val SWAP_ADDITIONAL_FIELD_VALUE = "swap"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue