diff --git a/app/metrics.yaml b/app/metrics.yaml index 79036eb55fc6..42e4508380b3 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -613,7 +613,7 @@ activation: type: string lifetime: ping description: > - An hashed and salted version of the Google Advertising ID from the device. + A hashed and salted version of the Google Advertising ID from the device. This will never be sent in a ping that also contains the client_id. send_in_pings: - activation @@ -844,3 +844,60 @@ sync_account: notification_emails: - fenix-core@mozilla.com expires: "2020-03-01" + +history: + opened: + type: event + description: > + A user opened the history screen + bugs: + - 2362 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/3940 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + removed: + type: event + description: > + A user removed a history item + bugs: + - 2362 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/3940 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + removed_all: + type: event + description: > + A user removed all history items + bugs: + - 2362 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/3940 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + shared: + type: event + description: > + A user shared a history item + bugs: + - 2362 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/3940 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + opened_item: + type: event + description: > + A user opened a history item + bugs: + - 2362 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/3940 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" \ No newline at end of file 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 b85c8fcb47cf..b1d777f59bf2 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 @@ -22,15 +22,16 @@ import org.mozilla.fenix.GleanMetrics.CustomTab import org.mozilla.fenix.GleanMetrics.ErrorPage import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.FindInPage +import org.mozilla.fenix.GleanMetrics.History import org.mozilla.fenix.GleanMetrics.Library import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Pings import org.mozilla.fenix.GleanMetrics.QrScanner import org.mozilla.fenix.GleanMetrics.QuickActionSheet import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine +import org.mozilla.fenix.ext.components import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAuth -import org.mozilla.fenix.ext.components private class EventWrapper>( private val recorder: ((Map?) -> Unit), @@ -227,6 +228,21 @@ private val Event.wrapper { Events.preferenceToggled.record(it) }, { Events.preferenceToggledKeys.valueOf(it) } ) + is Event.HistoryOpened -> EventWrapper( + { History.opened.record(it) } + ) + is Event.HistoryItemShared -> EventWrapper( + { History.shared.record(it) } + ) + is Event.HistoryItemOpened -> EventWrapper( + { History.openedItem.record(it) } + ) + is Event.HistoryItemRemoved -> EventWrapper( + { History.removed.record(it) } + ) + is Event.HistoryAllItemsRemoved -> EventWrapper( + { History.removedAll.record(it) } + ) // Don't track other events with Glean else -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index a64411af7ad1..e6ab15c47bd2 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -93,6 +93,11 @@ sealed class Event { object SyncAccountClosed : Event() object SyncAccountSyncNow : Event() object SyncAccountSignOut : Event() + object HistoryOpened : Event() + object HistoryItemShared : Event() + object HistoryItemOpened : Event() + object HistoryItemRemoved : Event() + object HistoryAllItemsRemoved : Event() data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() { private val switchPreferenceTelemetryAllowList = listOf( diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt index 5dda9ef44451..46f8f1ff6a3f 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -33,6 +33,7 @@ import org.mozilla.fenix.FenixViewModelProvider import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R import org.mozilla.fenix.components.Components +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getHostFromUrl import org.mozilla.fenix.ext.nav @@ -69,6 +70,7 @@ class HistoryFragment : Fragment(), BackHandler { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + requireComponents.analytics.metrics.track(Event.HistoryOpened) setHasOptionsMenu(true) } @@ -209,6 +211,7 @@ class HistoryFragment : Fragment(), BackHandler { } private fun openItem(item: HistoryItem) { + requireComponents.analytics.metrics.track(Event.HistoryItemOpened) (activity as HomeActivity).openToBrowserAndLoad( searchTermOrURL = item.url, newTab = true, @@ -226,6 +229,7 @@ class HistoryFragment : Fragment(), BackHandler { setPositiveButton(R.string.history_clear_dialog) { dialog: DialogInterface, _ -> emitChange { HistoryChange.EnterDeletionMode } lifecycleScope.launch { + requireComponents.analytics.metrics.track(Event.HistoryAllItemsRemoved) requireComponents.core.historyStorage.deleteEverything() reloadData() launch(Dispatchers.Main) { @@ -279,6 +283,7 @@ class HistoryFragment : Fragment(), BackHandler { selected: List, components: Components = requireComponents ) { + requireComponents.analytics.metrics.track(Event.HistoryItemRemoved) val storage = components.core.historyStorage for (item in selected) { storage.deleteVisit(item.url, item.visitedAt) @@ -286,6 +291,7 @@ class HistoryFragment : Fragment(), BackHandler { } private fun share(url: String? = null, tabs: List? = null) { + requireComponents.analytics.metrics.track(Event.HistoryItemShared) val directions = HistoryFragmentDirections.actionHistoryFragmentToShareFragment( url = url, diff --git a/docs/metrics.md b/docs/metrics.md index 953a8056da4c..3a429f0de1b9 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -706,6 +706,62 @@ tracking_protection +## history + +
+
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+
keytypedescriptiondata deviewextrasexpires
openedeventA user opened the history screenlink2020-03-01
removedeventA user removed a history itemlink2020-03-01
removed_alleventA user removed all history itemslink2020-03-01
sharedeventA user shared a history itemlink2020-03-01
opened_itemeventA user opened a history itemlink2020-03-01
+
+ + ## Metrics Items that are added to the metrics ping