Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #15347 - Adds telemetry for autoclose setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ekager committed Oct 6, 2020
1 parent ad2b99f commit 29f133f
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
34 changes: 33 additions & 1 deletion app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -906,6 +906,23 @@ metrics:
notification_emails:
- [email protected]
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:
- [email protected]
expires: "2021-03-01"
search_widget_installed:
type: boolean
lifetime: application
Expand Down Expand Up @@ -4034,3 +4051,18 @@ master_password:
notification_emails:
- [email protected]
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:
- [email protected]
expires: "2021-03-01"
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -705,6 +706,9 @@ private val Event.wrapper: EventWrapper<*>?
Event.MasterPasswordMigrationSuccess -> EventWrapper<NoExtraKeys>(
{ MasterPassword.migration.record(it) }
)
Event.TabSettingsOpened -> EventWrapper<NoExtraKeys>(
{ Tabs.settingOpened.record(it)}
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down

0 comments on commit 29f133f

Please sign in to comment.