Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:56:56 +01:00
parent 75dc487a7a
commit 39c29d175b
6317 changed files with 388324 additions and 2 deletions

View file

@ -0,0 +1,16 @@
plugins {
id(ThunderbirdPlugins.Library.android)
}
android {
namespace = "app.k9mail.feature.telemetry.glean"
resourcePrefix = "telemetry_glean_"
}
dependencies {
api(projects.feature.telemetry.api)
api(libs.okhttp)
implementation(libs.mozilla.components.glean)
implementation(libs.mozilla.components.fetch.okhttp)
}

View file

@ -0,0 +1,15 @@
package app.k9mail.feature.telemetry
import app.k9mail.feature.telemetry.api.TelemetryManager
import app.k9mail.feature.telemetry.glean.GleanTelemetryManager
import org.koin.core.module.Module
import org.koin.dsl.module
val telemetryModule: Module = module {
single<TelemetryManager> {
GleanTelemetryManager(
context = get(),
okHttpClient = lazy { get() },
)
}
}

View file

@ -0,0 +1,46 @@
package app.k9mail.feature.telemetry.glean
import android.content.Context
import app.k9mail.feature.telemetry.api.TelemetryManager
import java.util.Calendar
import mozilla.components.lib.fetch.okhttp.OkHttpClient
import mozilla.components.service.glean.net.ConceptFetchHttpUploader
import mozilla.telemetry.glean.BuildInfo
import mozilla.telemetry.glean.Glean
import mozilla.telemetry.glean.config.Configuration
class GleanTelemetryManager(
private val context: Context,
private val okHttpClient: Lazy<okhttp3.OkHttpClient>,
) : TelemetryManager {
override fun isTelemetryFeatureIncluded(): Boolean = true
override fun setEnabled(enable: Boolean) {
Glean.setCollectionEnabled(enable)
}
override fun init(uploadEnabled: Boolean, releaseChannel: String?, versionCode: Int, versionName: String) {
val httpClient = lazy { OkHttpClient(okHttpClient.value, context) }
val configuration = Configuration(
httpClient = ConceptFetchHttpUploader(httpClient),
channel = releaseChannel,
)
// We don't care for the build date (and including it would make reproducible builds harder).
val buildDate = Calendar.getInstance().apply { clear() }
val buildInfo = BuildInfo(
versionCode = versionCode.toString(),
versionName = versionName,
buildDate = buildDate,
)
Glean.initialize(
context,
uploadEnabled,
configuration,
buildInfo,
)
}
}