Add SDK git SHA to user agent (#2548)
This commit is contained in:
committed by
GitHub
parent
6c1f90ed77
commit
90304a268e
@@ -148,7 +148,7 @@ class DefaultBugReporterTest {
|
||||
systemClock = FakeSystemClock(),
|
||||
coroutineDispatchers = testCoroutineDispatchers(),
|
||||
okHttpClient = { OkHttpClient.Builder().build() },
|
||||
userAgentProvider = DefaultUserAgentProvider(buildMeta),
|
||||
userAgentProvider = DefaultUserAgentProvider(buildMeta, FakeSdkMetadata("123456789")),
|
||||
sessionStore = InMemorySessionStore(),
|
||||
buildMeta = buildMeta,
|
||||
bugReporterUrlProvider = { server.url("/") },
|
||||
|
||||
@@ -37,6 +37,7 @@ dependencies {
|
||||
implementation(libs.dagger)
|
||||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.di)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
implementation(platform(libs.network.okhttp.bom))
|
||||
implementation(libs.network.okhttp)
|
||||
implementation(libs.network.okhttp.logging)
|
||||
|
||||
@@ -21,12 +21,14 @@ import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.core.meta.BuildMeta
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
import io.element.android.libraries.matrix.api.SdkMetadata
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultUserAgentProvider @Inject constructor(
|
||||
private val buildMeta: BuildMeta,
|
||||
private val sdkMeta: SdkMetadata,
|
||||
) : UserAgentProvider {
|
||||
private val userAgent: String by lazy { buildUserAgent() }
|
||||
|
||||
@@ -34,7 +36,7 @@ class DefaultUserAgentProvider @Inject constructor(
|
||||
|
||||
/**
|
||||
* Create an user agent with the application version.
|
||||
* Ex: Element X/1.5.0 (Xiaomi Mi 9T; Android 11; RKQ1.200826.002; Sdk 0.1.0)
|
||||
* Ex: Element X/1.5.0 (Xiaomi Mi 9T; Android 11; RKQ1.200826.002; Sdk c344b155c)
|
||||
*/
|
||||
private fun buildUserAgent(): String {
|
||||
val appName = buildMeta.applicationName
|
||||
@@ -43,7 +45,7 @@ class DefaultUserAgentProvider @Inject constructor(
|
||||
val deviceModel = Build.MODEL
|
||||
val androidVersion = Build.VERSION.RELEASE
|
||||
val deviceBuildId = Build.DISPLAY
|
||||
val matrixSdkVersion = "TODO"
|
||||
val matrixSdkVersion = sdkMeta.sdkGitSha
|
||||
|
||||
return buildString {
|
||||
append(appName)
|
||||
|
||||
Reference in New Issue
Block a user