Skip to content

Commit

Permalink
No issue: fix glean metrics tests for expired metrics (mozilla-mobile…
Browse files Browse the repository at this point in the history
…#20621)

* Remove references to preferences.open_links_in_private and preferences.private_search_suggestions in tests. These metrics have been expired and may be removed.

* Add ignores for performance metrics that have expired.

* Remove tabs_tray.cfr.dismiss and tabs_tray.cfr.go_to_settings telemetry probes.

* Remove metrics controller from signature and remove in tests
  • Loading branch information
Elise Richards committed Aug 2, 2021
1 parent ff4f3b4 commit ba164d6
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 70 deletions.
32 changes: 0 additions & 32 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2650,38 +2650,6 @@ reader_mode:
- android-probes@mozilla.com
expires: "2022-02-01"

tabs_tray.cfr:
dismiss:
type: event
description: |
A user dismisses the tabs tray CFR.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/16485
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/17442
- https://github.com/mozilla-mobile/fenix/issues/16485#issuecomment-759641324
- https://github.com/mozilla-mobile/fenix/pull/19924#issuecomment-861423789
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2021-08-01"
go_to_settings:
type: event
description: |
A user selects the CFR option to navigate to settings.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/16485
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/17442
- https://github.com/mozilla-mobile/fenix/issues/16485#issuecomment-759641324
- https://github.com/mozilla-mobile/fenix/pull/19924#issuecomment-861423789
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2021-08-01"

tabs_tray:
opened:
type: event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ sealed class Event {
object TabsTraySaveToCollectionPressed : Event()
object TabsTrayShareAllTabsPressed : Event()
object TabsTrayCloseAllTabsPressed : Event()
object TabsTrayCfrDismissed : Event()
object TabsTrayCfrTapped : Event()

object ProgressiveWebAppOpenFromHomescreenTap : Event()
object ProgressiveWebAppInstallAsShortcut : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import org.mozilla.fenix.GleanMetrics.SyncedTabs
import org.mozilla.fenix.GleanMetrics.Tab
import org.mozilla.fenix.GleanMetrics.Tabs
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.GleanMetrics.TabsTrayCfr
import org.mozilla.fenix.GleanMetrics.Tip
import org.mozilla.fenix.GleanMetrics.ToolbarSettings
import org.mozilla.fenix.GleanMetrics.TopSites
Expand Down Expand Up @@ -700,12 +699,6 @@ private val Event.wrapper: EventWrapper<*>?
is Event.TabsTrayCloseAllTabsPressed -> EventWrapper<NoExtraKeys>(
{ TabsTray.closeAllTabs.record(it) }
)
is Event.TabsTrayCfrDismissed -> EventWrapper<NoExtraKeys>(
{ TabsTrayCfr.dismiss.record(it) }
)
is Event.TabsTrayCfrTapped -> EventWrapper<NoExtraKeys>(
{ TabsTrayCfr.goToSettings.record(it) }
)
is Event.AutoPlaySettingVisited -> EventWrapper<NoExtraKeys>(
{ Autoplay.visitedSetting.record(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
store = requireComponents.core.store,
infoBannerView = view.info_banner,
settings = requireComponents.settings,
navigationInteractor = navigationInteractor,
metrics = requireComponents.analytics.metrics
navigationInteractor = navigationInteractor
),
owner = this,
view = view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import mozilla.components.lib.state.helpers.AbstractBinding
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.infobanner.InfoBanner
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.utils.Settings

@OptIn(ExperimentalCoroutinesApi::class)
Expand All @@ -31,8 +29,7 @@ class TabsTrayInfoBannerBinding(
store: BrowserStore,
private val infoBannerView: ViewGroup,
private val settings: Settings,
private val navigationInteractor: NavigationInteractor,
private val metrics: MetricController?
private val navigationInteractor: NavigationInteractor
) : AbstractBinding<BrowserState>(store) {

@VisibleForTesting
Expand Down Expand Up @@ -70,12 +67,10 @@ class TabsTrayInfoBannerBinding(
container = infoBannerView,
dismissByHiding = true,
dismissAction = {
metrics?.track(Event.TabsTrayCfrDismissed)
settings.shouldShowAutoCloseTabsBanner = false
}
) {
navigationInteractor.onTabSettingsClicked()
metrics?.track(Event.TabsTrayCfrTapped)
settings.shouldShowAutoCloseTabsBanner = false
}
} else {
Expand Down
2 changes: 0 additions & 2 deletions app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ class FenixApplicationTest {
assertEquals(true, Preferences.bookmarksSuggestion.testGetValue())
assertEquals(true, Preferences.clipboardSuggestionsEnabled.testGetValue())
assertEquals(true, Preferences.searchShortcutsEnabled.testGetValue())
assertEquals(true, Preferences.openLinksInPrivate.testGetValue())
assertEquals(true, Preferences.privateSearchSuggestions.testGetValue())
assertEquals(true, Preferences.voiceSearchEnabled.testGetValue())
assertEquals(true, Preferences.openLinksInAppEnabled.testGetValue())
assertEquals(true, Preferences.signedInSync.testGetValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.History
import org.mozilla.fenix.GleanMetrics.SyncedTabs
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.GleanMetrics.TabsTrayCfr
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner

@RunWith(FenixRobolectricTestRunner::class)
Expand Down Expand Up @@ -250,14 +249,6 @@ class GleanMetricsServiceTest {
assertFalse(TabsTray.closeAllTabs.testHasValue())
gleanService.track(Event.TabsTrayCloseAllTabsPressed)
assertTrue(TabsTray.closeAllTabs.testHasValue())

assertFalse(TabsTrayCfr.dismiss.testHasValue())
gleanService.track(Event.TabsTrayCfrDismissed)
assertTrue(TabsTrayCfr.dismiss.testHasValue())

assertFalse(TabsTrayCfr.goToSettings.testHasValue())
gleanService.track(Event.TabsTrayCfrTapped)
assertTrue(TabsTrayCfr.goToSettings.testHasValue())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -41,6 +42,7 @@ class StorageStatsMetricsTest {
}

@Test
@Ignore("These metrics have expired.")
fun `WHEN reporting THEN the values from the storageStats are accumulated`() {
every { storageStats.appBytes } returns 100
every { storageStats.cacheBytes } returns 200
Expand All @@ -54,6 +56,7 @@ class StorageStatsMetricsTest {
}

@Test
@Ignore("These metrics have expired.")
fun `WHEN reporting THEN the query duration is measured`() {
StorageStatsMetrics.reportSync(mockContext)
assertTrue(Metrics.queryStatsDuration.testHasValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.tabstray.TabsTrayInfoBannerBinding.Companion.TAB_COUNT_SHOW_CFR
import org.mozilla.fenix.utils.Settings
Expand All @@ -35,7 +33,6 @@ class TabsTrayInfoBannerBindingTest {
private lateinit var store: BrowserStore
private lateinit var view: ViewGroup
private lateinit var interactor: NavigationInteractor
private lateinit var metrics: MetricController
private lateinit var settings: Settings

@get:Rule
Expand All @@ -46,7 +43,6 @@ class TabsTrayInfoBannerBindingTest {
store = BrowserStore()
view = CoordinatorLayout(testContext)
interactor = mockk(relaxed = true)
metrics = mockk(relaxed = true)
settings = Settings(testContext)
}

Expand All @@ -60,8 +56,7 @@ class TabsTrayInfoBannerBindingTest {
store = store,
infoBannerView = view,
settings = settings,
navigationInteractor = interactor,
metrics = metrics
navigationInteractor = interactor
)

binding.start()
Expand All @@ -88,8 +83,7 @@ class TabsTrayInfoBannerBindingTest {
store = store,
infoBannerView = view,
settings = settings,
navigationInteractor = interactor,
metrics = metrics
navigationInteractor = interactor
)

binding.start()
Expand All @@ -103,7 +97,5 @@ class TabsTrayInfoBannerBindingTest {

verify(exactly = 0) { interactor.onTabSettingsClicked() }
assert(!settings.shouldShowAutoCloseTabsBanner)
verify(exactly = 0) { metrics.track(Event.TabsTrayCfrTapped) }
verify(exactly = 1) { metrics.track(Event.TabsTrayCfrDismissed) }
}
}

0 comments on commit ba164d6

Please sign in to comment.