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

Commit

Permalink
For #4658: Add some private browsing mode telemetry (#4968)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyeontaek authored Aug 28, 2019
1 parent 09ed721 commit d87b8a8
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 2 deletions.
59 changes: 59 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -314,6 +315,21 @@ private val Event.wrapper: EventWrapper<*>?
is Event.SearchWidgetVoiceSearchPressed -> EventWrapper<NoExtraKeys>(
{ SearchWidget.voiceButton.record(it) }
)
is Event.PrivateBrowsingGarbageIconTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.garbageIcon.record(it) }
)
is Event.PrivateBrowsingSnackbarUndoTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.snackbarUndo.record(it) }
)
is Event.PrivateBrowsingNotificationTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.notificationTapped.record(it) }
)
is Event.PrivateBrowsingNotificationOpenTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.notificationOpen.record(it) }
)
is Event.PrivateBrowsingNotificationDeleteAndOpenTapped -> EventWrapper<NoExtraKeys>(
{ PrivateBrowsingMode.notificationDelete.record(it) }
)

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

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TabHeaderViewHolder(

close_tabs_button.run {
setOnClickListener {
view.context.components.analytics.metrics.track(Event.PrivateBrowsingGarbageIconTapped)
actionEmitter.onNext(TabAction.CloseAll(true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -39,6 +41,7 @@ class SessionNotificationService : Service() {
}

ACTION_ERASE -> {
metrics.track(Event.PrivateBrowsingNotificationTapped)
components.core.sessionManager.removeAndCloseAllPrivateSessions()

if (!VisibilityLifecycleCallback.finishAndRemoveTaskIfInBackground(this)) {
Expand Down Expand Up @@ -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)
}
Expand Down
50 changes: 49 additions & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1096,4 +1096,52 @@ Data that is sent in the activation ping
<td>2020-03-01</td>
</tr>
</table>
</pre>
</pre>

## private_browsing_mode

<pre>
<table style="width: 100%">
<tr>
<td>garbage_icon</td>
<td>event</td>
<td>A user pressed the garbage can icon on the private browsing home page, deleting all private tabs.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4968">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>snackbar_undo</td>
<td>event</td>
<td>A user pressed the "undo" button in the snackbar that is shown when the garbage icon is tapped.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4968">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>notification_tapped</td>
<td>event</td>
<td>A user pressed the private browsing mode notification itself.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4968">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>notification_open</td>
<td>event</td>
<td>A user pressed the private browsing mode notification's "Open" button.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4968">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>notification_delete</td>
<td>event</td>
<td>A user pressed the private browsing mode notification's "Delete and Open" button.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4968">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
</table>
</pre>

0 comments on commit d87b8a8

Please sign in to comment.