For #22138 - Install source metrics probe

upstream-sync
Mugurell 3 years ago committed by mergify[bot]
parent 9cce30b824
commit 018fe15072

@ -1301,6 +1301,20 @@ metrics:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2022-02-01"
install_source:
type: string
lifetime: application
description: |
Used to identify the source the app was installed from.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/22138
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22224#issuecomment-956749994
data_sensitivity:
- technical
notification_emails:
- android-probes@mozilla.com
expires: "2022-02-01"
customize_home:
most_visited_sites:

@ -626,6 +626,14 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
tabViewSetting.set(settings.getTabViewPingString())
closeTabSetting.set(settings.getTabTimeoutPingString())
val installSourcePackage = if (SDK_INT >= Build.VERSION_CODES.R) {
packageManager.getInstallSourceInfo(packageName).installingPackageName
} else {
@Suppress("DEPRECATION")
packageManager.getInstallerPackageName(packageName)
}
installSource.set(installSourcePackage.orEmpty())
}
with(AndroidAutofill) {

@ -4,6 +4,8 @@
package org.mozilla.fenix
import android.content.pm.PackageManager
import android.os.Build
import androidx.test.core.app.ApplicationProvider
import io.mockk.Runs
import io.mockk.every
@ -32,6 +34,7 @@ import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.BrowsersCache
import org.mozilla.fenix.utils.Settings
import org.robolectric.annotation.Config
@RunWith(FenixRobolectricTestRunner::class)
class FenixApplicationTest {
@ -80,11 +83,17 @@ class FenixApplicationTest {
}
@Test
@Config(sdk = [Build.VERSION_CODES.O])
fun `WHEN setStartupMetrics is called THEN sets some base metrics`() {
val expectedAppName = "org.mozilla.fenix"
val expectedAppInstallSource = "org.mozilla.install.source"
val settings: Settings = mockk()
val application = spyk(application)
val packageManager: PackageManager = mockk()
every { application.packageManager } returns packageManager
@Suppress("DEPRECATION")
every { packageManager.getInstallerPackageName(any()) } returns expectedAppInstallSource
every { browsersCache.all(any()).isDefaultBrowser } returns true
every { mozillaProductDetector.getMozillaBrowserDefault(any()) } returns expectedAppName
every { mozillaProductDetector.getInstalledMozillaProducts(any()) } returns listOf(expectedAppName)
@ -168,6 +177,7 @@ class FenixApplicationTest {
assertEquals("standard", Preferences.enhancedTrackingProtection.testGetValue())
assertEquals(listOf("switch", "touch exploration"), Preferences.accessibilityServices.testGetValue())
assertEquals(true, Preferences.inactiveTabsEnabled.testGetValue())
assertEquals(expectedAppInstallSource, Metrics.installSource.testGetValue())
// Verify that search engine defaults are NOT set. This test does
// not mock most of the objects telemetry is collected from.

Loading…
Cancel
Save