diff --git a/app/metrics.yaml b/app/metrics.yaml index 11bd45857d91..2150b328d141 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -265,7 +265,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: @@ -906,6 +906,23 @@ metrics: notification_emails: - fenix-core@mozilla.com expires: "2020-11-15" + 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: + - TBD + data_reviews: + - TBD + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-03-01" search_widget_installed: type: boolean lifetime: application @@ -4034,3 +4051,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: + - TBD + data_reviews: + - TBD + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-03-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 c01c4998b467..9505f8a2ef23 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 25a289a55fe8..8187beb4ea31 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,10 @@ class GleanMetricsService(private val context: Context) : MetricsService { ToolbarPosition.TOP -> Event.ToolbarPositionChanged.Position.TOP.name } ) + + closeTabSetting.set( + context.settings().getTabTimeoutPingString() + ) } SearchDefaultEngine.apply { diff --git a/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt index 9bb15f29525b..faf113dfdf3e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/CloseTabsSettingsFragment.kt @@ -5,8 +5,11 @@ package org.mozilla.fenix.settings import android.os.Bundle +import android.view.View 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.showToolbar import org.mozilla.fenix.utils.view.addToRadioGroup @@ -23,6 +26,11 @@ class CloseTabsSettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.close_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_close_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 16f07e438139..3d62973f4539 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -372,6 +372,25 @@ class Settings(private val appContext: Context) : PreferencesHolder { else -> System.currentTimeMillis() } + 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 845a399b9f3c..8fe649335259 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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |2 | +| tabs.setting_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tab settings were opened. |[1](TBD)||2021-03-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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |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](TBD)||2021-03-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)||2020-11-15 |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)||2020-11-15 |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)||2020-11-15 |2 |