From 7d807f5a0ac10366193cc975e6ee69b38f7fc68e Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Thu, 31 Jan 2019 17:27:36 +0100 Subject: [PATCH] Closes #263: Integrate service-glean component. --- app/build.gradle | 17 +++++++++++++++++ .../java/org/mozilla/fenix/FenixApplication.kt | 7 +++++++ buildSrc/src/main/java/Dependencies.kt | 1 + docs/telemetry.md | 7 +++++++ 4 files changed, 32 insertions(+) create mode 100644 docs/telemetry.md diff --git a/app/build.gradle b/app/build.gradle index 9770cb3bc..28a9ef1a5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,7 @@ +plugins { + id "com.jetbrains.python.envs" version "0.0.26" +} + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' @@ -119,7 +123,9 @@ dependencies { implementation Deps.mozilla_feature_session implementation Deps.mozilla_feature_toolbar implementation Deps.mozilla_feature_tabs + implementation Deps.mozilla_service_fretboard + implementation Deps.mozilla_service_glean implementation Deps.mozilla_support_ktx @@ -152,4 +158,15 @@ android.applicationVariants.all { variant -> } else { buildConfigField 'boolean', 'CRASH_REPORTING', 'false' } + + // Activating telemetry only if command line parameter was provided (in automation) + if (project.hasProperty("telemetry") && project.property("telemetry") == "true") { + buildConfigField 'boolean', 'TELEMETRY', 'true' + } else { + buildConfigField 'boolean', 'TELEMETRY', 'false' + } } + +// Normally this should use the same version as the glean dependency. But since we are currently using AC snapshots we +// can't reference a git tag with a specific version here. So we are just using "master" and hoping for the best. +apply from: 'https://github.com/mozilla-mobile/android-components/raw/master/components/service/glean/scripts/sdk_generator.gradle' diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 6385a1f41..971c7d19a 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -13,6 +13,7 @@ import mozilla.components.service.fretboard.Fretboard import mozilla.components.service.fretboard.ValuesProvider import mozilla.components.service.fretboard.source.kinto.KintoExperimentSource import mozilla.components.service.fretboard.storage.flatfile.FlatFileExperimentStorage +import mozilla.components.service.glean.Glean import mozilla.components.support.base.log.Log import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.sink.AndroidLogSink @@ -29,9 +30,15 @@ class FenixApplication : Application() { Log.addSink(AndroidLogSink()) setupCrashReporting() + setupGlean(this) loadExperiments() } + private fun setupGlean(context: Context) { + Glean.initialize(context) + Glean.setMetricsEnabled(BuildConfig.TELEMETRY) + } + private fun loadExperiments() { val experimentsFile = File(filesDir, EXPERIMENTS_JSON_FILENAME) val experimentSource = KintoExperimentSource( diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index e967687e6..e59591793 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -75,6 +75,7 @@ object Deps { const val mozilla_feature_toolbar = "org.mozilla.components:feature-toolbar:${Versions.mozilla_android_components}" const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}" + const val mozilla_service_glean = "org.mozilla.components:service-glean:${Versions.mozilla_android_components}" const val mozilla_lib_crash = "org.mozilla.components:lib-crash:${Versions.mozilla_android_components}" diff --git a/docs/telemetry.md b/docs/telemetry.md new file mode 100644 index 000000000..a9585b582 --- /dev/null +++ b/docs/telemetry.md @@ -0,0 +1,7 @@ +# Telemetry + +Nightly versions of Fenix (build on Taskcluster) send a "baseline" ping to Mozilla's telemetry service. + +## Baseline ping + +Fenix crates and tries to send a "baseline" ping when the app goes to the background. This baseline ping is defined by the [Glean](https://github.com/mozilla-mobile/android-components/tree/master/components/service/glean) component and [documented in the Android Components repository](https://github.com/mozilla-mobile/android-components/blob/master/components/service/glean/docs/baseline.md). \ No newline at end of file