From d87b8a8a5c3ecb8f6c8eb8e68162eea80af0e79f Mon Sep 17 00:00:00 2001 From: Yeon Taek Jeong Date: Wed, 28 Aug 2019 14:41:37 -0700 Subject: [PATCH] For #4658: Add some private browsing mode telemetry (#4968) --- app/metrics.yaml | 59 +++++++++++++++++++ .../java/org/mozilla/fenix/HomeActivity.kt | 3 +- .../components/metrics/GleanMetricsService.kt | 16 +++++ .../fenix/components/metrics/Metrics.kt | 5 ++ .../org/mozilla/fenix/home/HomeFragment.kt | 3 + .../intent/NotificationsIntentProcessor.kt | 5 ++ .../viewholders/TabHeaderViewHolder.kt | 1 + .../session/SessionNotificationService.kt | 4 ++ docs/metrics.md | 50 +++++++++++++++- 9 files changed, 144 insertions(+), 2 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index fe1ddad9d538..1b50bb804873 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1142,6 +1142,65 @@ search_widget: - fenix-core@mozilla.com expires: "2020-03-01" +private_browsing_mode: + garbage_icon: + type: event + description: > + A user pressed the garbage can icon on the private browsing home page, + deleting all private tabs. + bugs: + - 4658 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/4968 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + snackbar_undo: + type: event + description: > + A user pressed the "undo" button in the snackbar that is shown when the garbage icon is + tapped. + bugs: + - 4658 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/4968 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + notification_tapped: + type: event + description: > + A user pressed the private browsing mode notification itself. + bugs: + - 4658 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/4968 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + notification_open: + type: event + description: > + A user pressed the private browsing mode notification's "Open" button. + bugs: + - 4658 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/4968 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + notification_delete: + type: event + description: > + A user pressed the private browsing mode notification's "Delete and Open" button. + bugs: + - 4658 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/4968 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + experiments.metrics: active_experiment: type: string diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 92e57e1879e0..5efbdc96f20b 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -339,6 +339,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback const val OPEN_TO_BROWSER = "open_to_browser" const val OPEN_TO_BROWSER_AND_LOAD = "open_to_browser_and_load" const val OPEN_TO_SEARCH = "open_to_search" - const val EXTRA_DELETE_PRIVATE_TABS = "notification" + const val EXTRA_DELETE_PRIVATE_TABS = "notification_delete_and_open" + const val EXTRA_OPENED_FROM_NOTIFICATION = "notification_open" } } 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 04bc622d2517..82a57b116d7a 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 @@ -27,6 +27,7 @@ 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.PrivateBrowsingMode import org.mozilla.fenix.GleanMetrics.QrScanner import org.mozilla.fenix.GleanMetrics.QuickActionSheet import org.mozilla.fenix.GleanMetrics.ReaderMode @@ -314,6 +315,21 @@ private val Event.wrapper: EventWrapper<*>? is Event.SearchWidgetVoiceSearchPressed -> EventWrapper( { SearchWidget.voiceButton.record(it) } ) + is Event.PrivateBrowsingGarbageIconTapped -> EventWrapper( + { PrivateBrowsingMode.garbageIcon.record(it) } + ) + is Event.PrivateBrowsingSnackbarUndoTapped -> EventWrapper( + { PrivateBrowsingMode.snackbarUndo.record(it) } + ) + is Event.PrivateBrowsingNotificationTapped -> EventWrapper( + { PrivateBrowsingMode.notificationTapped.record(it) } + ) + is Event.PrivateBrowsingNotificationOpenTapped -> EventWrapper( + { PrivateBrowsingMode.notificationOpen.record(it) } + ) + is Event.PrivateBrowsingNotificationDeleteAndOpenTapped -> EventWrapper( + { PrivateBrowsingMode.notificationDelete.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> 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 7e274fa16cf5..c5d673d7f6d7 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 @@ -96,6 +96,11 @@ sealed class Event { object FindInPageNext : Event() object FindInPagePrevious : Event() object FindInPageSearchCommitted : Event() + object PrivateBrowsingGarbageIconTapped : Event() + object PrivateBrowsingSnackbarUndoTapped : Event() + object PrivateBrowsingNotificationTapped : Event() + object PrivateBrowsingNotificationOpenTapped : Event() + object PrivateBrowsingNotificationDeleteAndOpenTapped : Event() // Interaction events with extras diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 174d589e2f4d..6b695f6fcbe6 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -616,6 +616,9 @@ class HomeFragment : Fragment(), AccountObserver { view!!, snackbarMessage, getString(R.string.snackbar_deleted_undo), { + if (private) { + requireComponents.analytics.metrics.track(Event.PrivateBrowsingSnackbarUndoTapped) + } deleteAllSessionsJob = null emitSessionChanges() }, diff --git a/app/src/main/java/org/mozilla/fenix/home/intent/NotificationsIntentProcessor.kt b/app/src/main/java/org/mozilla/fenix/home/intent/NotificationsIntentProcessor.kt index e9eb5df692da..06aefa23fd2e 100644 --- a/app/src/main/java/org/mozilla/fenix/home/intent/NotificationsIntentProcessor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/intent/NotificationsIntentProcessor.kt @@ -7,6 +7,7 @@ package org.mozilla.fenix.home.intent import android.content.Intent import androidx.navigation.NavController import org.mozilla.fenix.HomeActivity +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.sessionsOfType @@ -21,10 +22,14 @@ class NotificationsIntentProcessor( override fun process(intent: Intent, navController: NavController, out: Intent): Boolean { return if (intent.extras?.getBoolean(HomeActivity.EXTRA_DELETE_PRIVATE_TABS) == true) { out.putExtra(HomeActivity.EXTRA_DELETE_PRIVATE_TABS, false) + activity.components.analytics.metrics.track(Event.PrivateBrowsingNotificationDeleteAndOpenTapped) activity.components.core.sessionManager.run { sessionsOfType(private = true).forEach { remove(it) } } true + } else if (intent.extras?.getBoolean(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION) == true) { + activity.components.analytics.metrics.track(Event.PrivateBrowsingNotificationOpenTapped) + true } else { false } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabHeaderViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabHeaderViewHolder.kt index d68daa14b208..131603125794 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabHeaderViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabHeaderViewHolder.kt @@ -55,6 +55,7 @@ class TabHeaderViewHolder( close_tabs_button.run { setOnClickListener { + view.context.components.analytics.metrics.track(Event.PrivateBrowsingGarbageIconTapped) actionEmitter.onNext(TabAction.CloseAll(true)) } } diff --git a/app/src/main/java/org/mozilla/fenix/session/SessionNotificationService.kt b/app/src/main/java/org/mozilla/fenix/session/SessionNotificationService.kt index c59e22e0708a..38de2ae2acf5 100644 --- a/app/src/main/java/org/mozilla/fenix/session/SessionNotificationService.kt +++ b/app/src/main/java/org/mozilla/fenix/session/SessionNotificationService.kt @@ -21,7 +21,9 @@ import mozilla.components.support.utils.ThreadUtils import org.mozilla.fenix.R import org.mozilla.fenix.HomeActivity +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components +import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.sessionsOfType /** @@ -39,6 +41,7 @@ class SessionNotificationService : Service() { } ACTION_ERASE -> { + metrics.track(Event.PrivateBrowsingNotificationTapped) components.core.sessionManager.removeAndCloseAllPrivateSessions() if (!VisibilityLifecycleCallback.finishAndRemoveTaskIfInBackground(this)) { @@ -100,6 +103,7 @@ class SessionNotificationService : Service() { private fun createOpenActionIntent(): PendingIntent { val intent = Intent(this, HomeActivity::class.java) + intent.putExtra(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION, true) return PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT) } diff --git a/docs/metrics.md b/docs/metrics.md index efda738485ef..e9d08d73b3dc 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -1096,4 +1096,52 @@ Data that is sent in the activation ping 2020-03-01 - \ No newline at end of file + + +## private_browsing_mode + +
+
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+    
+        
+        
+        
+        
+        
+        
+    
+
garbage_iconeventA user pressed the garbage can icon on the private browsing home page, deleting all private tabs.link2020-03-01
snackbar_undoeventA user pressed the "undo" button in the snackbar that is shown when the garbage icon is tapped.link2020-03-01
notification_tappedeventA user pressed the private browsing mode notification itself.link2020-03-01
notification_openeventA user pressed the private browsing mode notification's "Open" button.link2020-03-01
notification_deleteeventA user pressed the private browsing mode notification's "Delete and Open" button.link2020-03-01
+
+