Add SDK git SHA to user agent (#2548)
This commit is contained in:
parent
6c1f90ed77
commit
90304a268e
3 changed files with 6 additions and 3 deletions
|
|
@ -148,7 +148,7 @@ class DefaultBugReporterTest {
|
||||||
systemClock = FakeSystemClock(),
|
systemClock = FakeSystemClock(),
|
||||||
coroutineDispatchers = testCoroutineDispatchers(),
|
coroutineDispatchers = testCoroutineDispatchers(),
|
||||||
okHttpClient = { OkHttpClient.Builder().build() },
|
okHttpClient = { OkHttpClient.Builder().build() },
|
||||||
userAgentProvider = DefaultUserAgentProvider(buildMeta),
|
userAgentProvider = DefaultUserAgentProvider(buildMeta, FakeSdkMetadata("123456789")),
|
||||||
sessionStore = InMemorySessionStore(),
|
sessionStore = InMemorySessionStore(),
|
||||||
buildMeta = buildMeta,
|
buildMeta = buildMeta,
|
||||||
bugReporterUrlProvider = { server.url("/") },
|
bugReporterUrlProvider = { server.url("/") },
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ dependencies {
|
||||||
implementation(libs.dagger)
|
implementation(libs.dagger)
|
||||||
implementation(projects.libraries.core)
|
implementation(projects.libraries.core)
|
||||||
implementation(projects.libraries.di)
|
implementation(projects.libraries.di)
|
||||||
|
implementation(projects.libraries.matrix.api)
|
||||||
implementation(platform(libs.network.okhttp.bom))
|
implementation(platform(libs.network.okhttp.bom))
|
||||||
implementation(libs.network.okhttp)
|
implementation(libs.network.okhttp)
|
||||||
implementation(libs.network.okhttp.logging)
|
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.core.meta.BuildMeta
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.di.SingleIn
|
import io.element.android.libraries.di.SingleIn
|
||||||
|
import io.element.android.libraries.matrix.api.SdkMetadata
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SingleIn(AppScope::class)
|
@SingleIn(AppScope::class)
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
class DefaultUserAgentProvider @Inject constructor(
|
class DefaultUserAgentProvider @Inject constructor(
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
|
private val sdkMeta: SdkMetadata,
|
||||||
) : UserAgentProvider {
|
) : UserAgentProvider {
|
||||||
private val userAgent: String by lazy { buildUserAgent() }
|
private val userAgent: String by lazy { buildUserAgent() }
|
||||||
|
|
||||||
|
|
@ -34,7 +36,7 @@ class DefaultUserAgentProvider @Inject constructor(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an user agent with the application version.
|
* 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 {
|
private fun buildUserAgent(): String {
|
||||||
val appName = buildMeta.applicationName
|
val appName = buildMeta.applicationName
|
||||||
|
|
@ -43,7 +45,7 @@ class DefaultUserAgentProvider @Inject constructor(
|
||||||
val deviceModel = Build.MODEL
|
val deviceModel = Build.MODEL
|
||||||
val androidVersion = Build.VERSION.RELEASE
|
val androidVersion = Build.VERSION.RELEASE
|
||||||
val deviceBuildId = Build.DISPLAY
|
val deviceBuildId = Build.DISPLAY
|
||||||
val matrixSdkVersion = "TODO"
|
val matrixSdkVersion = sdkMeta.sdkGitSha
|
||||||
|
|
||||||
return buildString {
|
return buildString {
|
||||||
append(appName)
|
append(appName)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue