diff --git a/app/metrics.yaml b/app/metrics.yaml index bfe448679..fd6de67c9 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -279,7 +279,7 @@ events: whats_new_tapped: type: event description: | - A user opened the "what's new" page button + A user opened the "what's new" page button bugs: - https://github.com/mozilla-mobile/fenix/issues/5021 data_reviews: @@ -947,6 +947,40 @@ metrics: notification_emails: - fenix-core@mozilla.com expires: "2021-08-01" + close_tab_setting: + type: string + lifetime: application + description: | + A string that indicates the setting for tab closing: + MANUAL, ONE_DAY, ONE_WEEK, ONE_MONTH + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/15347#issue-707408975 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-08-01" + tab_view_setting: + type: string + lifetime: application + description: | + A string that indicates the setting for tab view: + GRID, LIST + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/15347#issue-707408975 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-08-01" search_widget_installed: type: boolean lifetime: application @@ -4207,3 +4241,18 @@ master_password: notification_emails: - fenix-core@mozilla.com expires: "2021-03-01" + +tabs: + setting_opened: + type: event + description: | + The tab settings were opened. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/15347#issue-707408975 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-08-01" diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index aec8008f1..bd79b6f9f 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -194,6 +194,8 @@ sealed class Event { object MasterPasswordMigrationSuccess : Event() object MasterPasswordMigrationDisplayed : Event() + object TabSettingsOpened : Event() + // Interaction events with extras data class TopSiteSwipeCarousel(val page: Int) : Event() { diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 25a289a55..aa82939e5 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -48,6 +48,7 @@ import org.mozilla.fenix.GleanMetrics.SearchWidgetCfr import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.Tab +import org.mozilla.fenix.GleanMetrics.Tabs import org.mozilla.fenix.GleanMetrics.TabsTray import org.mozilla.fenix.GleanMetrics.Tip import org.mozilla.fenix.GleanMetrics.ToolbarSettings @@ -705,6 +706,9 @@ private val Event.wrapper: EventWrapper<*>? Event.MasterPasswordMigrationSuccess -> EventWrapper( { MasterPassword.migration.record(it) } ) + Event.TabSettingsOpened -> EventWrapper( + { Tabs.settingOpened.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null @@ -786,6 +790,9 @@ class GleanMetricsService(private val context: Context) : MetricsService { ToolbarPosition.TOP -> Event.ToolbarPositionChanged.Position.TOP.name } ) + + tabViewSetting.set(context.settings().getTabViewPingString()) + closeTabSetting.set(context.settings().getTabTimeoutPingString()) } SearchDefaultEngine.apply { @@ -859,7 +866,9 @@ class GleanMetricsService(private val context: Context) : MetricsService { val accessibilitySelection = mutableListOf() - if (context.settings().switchServiceIsEnabled) { accessibilitySelection.add("switch") } + if (context.settings().switchServiceIsEnabled) { + accessibilitySelection.add("switch") + } if (context.settings().touchExplorationIsEnabled) { accessibilitySelection.add("touch exploration") diff --git a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt index b6aa9cf32..b5b996499 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TabsSettingsFragment.kt @@ -5,9 +5,12 @@ package org.mozilla.fenix.settings import android.os.Bundle +import android.view.View import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.utils.view.addToRadioGroup @@ -27,6 +30,11 @@ class TabsSettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.tabs_preferences, rootKey) } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + view.context.components.analytics.metrics.track(Event.TabSettingsOpened) + } + override fun onResume() { super.onResume() showToolbar(getString(R.string.preferences_tabs)) diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 6a32e55ef..6c411abed 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -390,6 +390,31 @@ class Settings(private val appContext: Context) : PreferencesHolder { else -> System.currentTimeMillis() } + enum class TabView { + GRID, LIST + } + + fun getTabViewPingString() = if (gridTabView) TabView.GRID.name else TabView.LIST.name + + enum class TabTimout { + ONE_DAY, ONE_WEEK, ONE_MONTH, MANUAL + } + + fun getTabTimeoutPingString(): String = when { + closeTabsAfterOneDay -> { + TabTimout.ONE_DAY.name + } + closeTabsAfterOneWeek -> { + TabTimout.ONE_WEEK.name + } + closeTabsAfterOneMonth -> { + TabTimout.ONE_MONTH.name + } + else -> { + TabTimout.MANUAL.name + } + } + fun getTabTimeoutString(): String = when { closeTabsAfterOneDay -> { appContext.getString(R.string.close_tabs_after_one_day) diff --git a/docs/metrics.md b/docs/metrics.md index 0614a699c..f75c30e25 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -197,6 +197,7 @@ The following metrics are added to the ping: | sync_auth.use_email_problem |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user chose to use their email to sign in after an account problem |[1](https://github.com/mozilla-mobile/fenix/pull/9835#pullrequestreview-398641844), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | +| tabs.setting_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tab settings were opened. |[1](https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952)||2021-08-01 |2 | | tabs_tray.close_all_tabs |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped the close all tabs button in the three dot menu within the tabs tray |[1](https://github.com/mozilla-mobile/fenix/pull/12036), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tabs_tray.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the tabs tray |[1](https://github.com/mozilla-mobile/fenix/pull/12036), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tabs_tray.closed_existing_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed an existing tab |[1](https://github.com/mozilla-mobile/fenix/pull/12036), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | @@ -279,6 +280,7 @@ The following metrics are added to the ping: | metrics.adjust_campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust campaign ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/5579), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |1 | | metrics.adjust_creative |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust creative ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/9253), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | metrics.adjust_network |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust network ID from which the user installed Fenix. This will not send on the first session the user runs. If the install is organic, this will be empty. |[1](https://github.com/mozilla-mobile/fenix/pull/9253), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | +| metrics.close_tab_setting |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the setting for tab closing: MANUAL, ONE_DAY, ONE_WEEK, ONE_MONTH |[1](https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952)||2021-08-01 |2 | | metrics.default_browser |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is Fenix the default browser? |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | metrics.default_moz_browser |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the default browser on device if and only if it's a Mozilla owned product |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216), [3](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |1, 2 | | metrics.has_open_tabs |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |A boolean that indicates if the user has any open NORMAL tabs. |[1](https://github.com/mozilla-mobile/fenix/pull/12024), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | @@ -288,6 +290,7 @@ The following metrics are added to the ping: | metrics.recently_used_pwa_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many PWAs a user has recently used. Threshold for "recency" set in HomeActivity#PWA_RECENTLY_USED_THRESHOLD. Currently we are not told by the OS when a PWA is removed by the user, so we use the "recently used" heuristic to judge how many PWAs are still active, as a proxy for "installed". This value will only be set if the user has at least *one* recently used PWA. If they have 0, this metric will not be sent, resulting in a null value during analysis on the server-side. To disambiguate between a failed `recently_used_pwa_count` metric and 0 recent PWAs, please see `has_recent_pwas`. |[1](https://github.com/mozilla-mobile/fenix/pull/11982#pullrequestreview-437963817), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `.`. If the search engine is bundled with Fenix `search-engine-name` will be the name of the search engine. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be `custom`. `source` will be: `action`, `suggestion`, `widget` or `shortcut` (depending on the source from which the search started). Also added the `other` option for the source but it should never enter on this case. |[1](https://github.com/mozilla-mobile/fenix/pull/1677), [2](https://github.com/mozilla-mobile/fenix/pull/5216), [3](https://github.com/mozilla-mobile/fenix/pull/7310), [4](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |1, 2 | | metrics.search_widget_installed |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Whether or not the search widget is installed |[1](https://github.com/mozilla-mobile/fenix/pull/10958), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | +| metrics.tab_view_setting |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the setting for tab view: GRID, LIST |[1](https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952)||2021-08-01 |2 | | metrics.tabs_open_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many NORMAL tabs a user has open. This value will only be set if the user has at least *one* open tab. If they have 0, this ping will not get sent, resulting in a null value. To disambiguate between a failed `tabs_open_count` ping and 0 open tabs, please see `has_open_tabs`. |[1](https://github.com/mozilla-mobile/fenix/pull/12024), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | metrics.toolbar_position |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the new position of the toolbar TOP or BOTTOM |[1](https://github.com/mozilla-mobile/fenix/pull/6608), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | metrics.top_sites_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many top sites a user has. This value will only be set if the user has at least *one* top site. If they have 0, this ping will not get sent, resulting in a null value. To disambiguate between a failed `top_sites_count` ping and 0 top sites, please see `has_top_sites`. |[1](https://github.com/mozilla-mobile/fenix/pull/9556), [2](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |