Skip to content

Commit

Permalink
For mozilla-mobile#21009 - New Recently closed tabs telemetry
Browse files Browse the repository at this point in the history
This adds a new `recently_closed_tabs` category with then events for all user
interactions on the screen.

The already existent `events.recently_closed_tabs_opened` is still kept for a
bit more time to still have this data available while the new telemetry ride
the trains but can later be removed in favor of this newly added events.
  • Loading branch information
Mugurell authored and pkirakosyan committed Mar 10, 2022
1 parent fb52f9b commit 5e174c8
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 7 deletions.
160 changes: 160 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ events:
description: |
An event that indicates that the user
has accessed recently closed tabs list.
Deprecated in favor of "recently_closed_tabs.opened"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/15366
- https://github.com/mozilla-mobile/fenix/issues/19923
Expand Down Expand Up @@ -3124,6 +3125,165 @@ history:
- android-probes@mozilla.com
expires: "2022-11-01"

recently_closed_tabs:
opened:
type: event
description: |
User opened the "Recently closed tabs" screen.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
closed:
type: event
description: |
User closed the "Recently closed tabs" screen.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
show_full_history:
type: event
description: |
User tapped "Show full history" to see all history.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
open_tab:
type: event
description: |
User tapped on a tab item to be opened.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
delete_tab:
type: event
description: |
User tapped the delete button of a tab item.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
menu_close:
type: event
description: |
User tapped the close button - "X" to return to the previous screen.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
menu_share:
type: event
description: |
User tapped the share menu option for multi selected tabs.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
menu_delete:
type: event
description: |
User tapped the delete menu option for multi selected tabs.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
menu_open_in_normal_tab:
type: event
description: |
User tapped the "Open in new tab" menu option for multi selected tabs.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
menu_open_in_private_tab:
type: event
description: |
User tapped the "Open in private tab" menu option for multi selected tabs.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
enter_multiselect:
type: event
description: |
User tapped on a tab item to enter multi select mode.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"
exit_multiselect:
type: event
description: |
User pressed back or tapped the last selected tab item to exit
multiselect.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21009
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22588#issuecomment-1024352995
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2023-01-31"

reader_mode:
available:
type: event
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ sealed class Event {
object HistorySearchTermGroupOpenTab : Event()
object HistorySearchTermGroupRemoveTab : Event()
object HistorySearchTermGroupRemoveAll : Event()
object RecentlyClosedTabsOpened : Event()
object RecentlyClosedTabsClosed : Event()
object RecentlyClosedTabsShowFullHistory : Event()
object RecentlyClosedTabsOpenTab : Event()
object RecentlyClosedTabsDeleteTab : Event()
object RecentlyClosedTabsMenuClose : Event()
object RecentlyClosedTabsMenuShare : Event()
object RecentlyClosedTabsMenuDelete : Event()
object RecentlyClosedTabsMenuOpenInNormalTab : Event()
object RecentlyClosedTabsMenuOpenInPrivateTab : Event()
object RecentlyClosedTabsEnterMultiselect : Event()
object RecentlyClosedTabsExitMultiselect : Event()
object ReaderModeAvailable : Event()
object ReaderModeOpened : Event()
object ReaderModeClosed : Event()
Expand Down Expand Up @@ -235,7 +247,7 @@ sealed class Event {

object SyncedTabOpened : Event()

object RecentlyClosedTabsOpened : Event()
object RecentlyClosedTabsOpenedOld : Event()
object HaveOpenTabs : Event()
object HaveNoOpenTabs : Event()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.mozilla.fenix.GleanMetrics.ReaderMode
import org.mozilla.fenix.GleanMetrics.RecentBookmarks
import org.mozilla.fenix.GleanMetrics.RecentSearches
import org.mozilla.fenix.GleanMetrics.RecentTabs
import org.mozilla.fenix.GleanMetrics.RecentlyClosedTabs
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
import org.mozilla.fenix.GleanMetrics.SearchTerms
import org.mozilla.fenix.GleanMetrics.SearchWidget
Expand Down Expand Up @@ -325,6 +326,42 @@ private val Event.wrapper: EventWrapper<*>?
is Event.HistorySearchTermGroupRemoveAll -> EventWrapper<NoExtraKeys>(
{ History.searchTermGroupRemoveAll.record(it) }
)
is Event.RecentlyClosedTabsOpened -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.opened.record(it) }
)
is Event.RecentlyClosedTabsClosed -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.closed.record(it) }
)
is Event.RecentlyClosedTabsShowFullHistory -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.showFullHistory.record(it) }
)
is Event.RecentlyClosedTabsOpenTab -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.openTab.record(it) }
)
is Event.RecentlyClosedTabsDeleteTab -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.deleteTab.record(it) }
)
is Event.RecentlyClosedTabsMenuClose -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.menuClose.record(it) }
)
is Event.RecentlyClosedTabsMenuShare -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.menuShare.record(it) }
)
is Event.RecentlyClosedTabsMenuDelete -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.menuDelete.record(it) }
)
is Event.RecentlyClosedTabsMenuOpenInNormalTab -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.menuOpenInNormalTab.record(it) }
)
is Event.RecentlyClosedTabsMenuOpenInPrivateTab -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.menuOpenInPrivateTab.record(it) }
)
is Event.RecentlyClosedTabsEnterMultiselect -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.enterMultiselect.record(it) }
)
is Event.RecentlyClosedTabsExitMultiselect -> EventWrapper<NoExtraKeys>(
{ RecentlyClosedTabs.exitMultiselect.record(it) }
)
is Event.CollectionRenamed -> EventWrapper<NoExtraKeys>(
{ Collections.renamed.record(it) }
)
Expand Down Expand Up @@ -691,7 +728,7 @@ private val Event.wrapper: EventWrapper<*>?
{ Events.syncedTabOpened.record(it) }
)

is Event.RecentlyClosedTabsOpened -> EventWrapper<NoExtraKeys>(
is Event.RecentlyClosedTabsOpenedOld -> EventWrapper<NoExtraKeys>(
{ Events.recentlyClosedTabsOpened.record(it) }
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ class DefaultHistoryController(
HistoryFragmentDirections.actionGlobalRecentlyClosed(),
NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build()
)
metrics.track(Event.RecentlyClosedTabsOpened)
metrics.track(Event.RecentlyClosedTabsOpenedOld)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController

@Suppress("TooManyFunctions")
interface RecentlyClosedController {
Expand All @@ -37,42 +39,60 @@ class DefaultRecentlyClosedController(
private val recentlyClosedStore: RecentlyClosedFragmentStore,
private val tabsUseCases: TabsUseCases,
private val activity: HomeActivity,
private val metrics: MetricController,
private val openToBrowser: (item: RecoverableTab, mode: BrowsingMode?) -> Unit
) : RecentlyClosedController {
override fun handleOpen(tab: RecoverableTab, mode: BrowsingMode?) {
openToBrowser(tab, mode)
}

override fun handleOpen(tabs: Set<RecoverableTab>, mode: BrowsingMode?) {
if (mode == BrowsingMode.Normal) {
metrics.track(Event.RecentlyClosedTabsMenuOpenInNormalTab)
} else if (mode == BrowsingMode.Private) {
metrics.track(Event.RecentlyClosedTabsMenuOpenInPrivateTab)
}
recentlyClosedStore.dispatch(RecentlyClosedFragmentAction.DeselectAll)
tabs.forEach { tab -> handleOpen(tab, mode) }
}

override fun handleSelect(tab: RecoverableTab) {
if (recentlyClosedStore.state.selectedTabs.isEmpty()) {
metrics.track(Event.RecentlyClosedTabsEnterMultiselect)
}
recentlyClosedStore.dispatch(RecentlyClosedFragmentAction.Select(tab))
}

override fun handleDeselect(tab: RecoverableTab) {
if (recentlyClosedStore.state.selectedTabs.size == 1) {
metrics.track(Event.RecentlyClosedTabsExitMultiselect)
}
recentlyClosedStore.dispatch(RecentlyClosedFragmentAction.Deselect(tab))
}

override fun handleDelete(tab: RecoverableTab) {
metrics.track(Event.RecentlyClosedTabsDeleteTab)
browserStore.dispatch(RecentlyClosedAction.RemoveClosedTabAction(tab))
}

override fun handleDelete(tabs: Set<RecoverableTab>) {
metrics.track(Event.RecentlyClosedTabsMenuDelete)
recentlyClosedStore.dispatch(RecentlyClosedFragmentAction.DeselectAll)
tabs.forEach { tab -> handleDelete(tab) }
tabs.forEach { tab ->
browserStore.dispatch(RecentlyClosedAction.RemoveClosedTabAction(tab))
}
}

override fun handleNavigateToHistory() {
metrics.track(Event.RecentlyClosedTabsShowFullHistory)
navController.navigate(
RecentlyClosedFragmentDirections.actionGlobalHistoryFragment(),
NavOptions.Builder().setPopUpTo(R.id.historyFragment, true).build()
)
}

override fun handleShare(tabs: Set<RecoverableTab>) {
metrics.track(Event.RecentlyClosedTabsMenuShare)
val shareData = tabs.map { ShareData(url = it.url, title = it.title) }
navController.navigate(
RecentlyClosedFragmentDirections.actionGlobalShareFragment(
Expand All @@ -82,6 +102,8 @@ class DefaultRecentlyClosedController(
}

override fun handleRestore(item: RecoverableTab) {
metrics.track(Event.RecentlyClosedTabsOpenTab)

tabsUseCases.restore(item)

browserStore.dispatch(
Expand All @@ -95,9 +117,11 @@ class DefaultRecentlyClosedController(

override fun handleBackPressed(): Boolean {
return if (recentlyClosedStore.state.selectedTabs.isNotEmpty()) {
metrics.track(Event.RecentlyClosedTabsExitMultiselect)
recentlyClosedStore.dispatch(RecentlyClosedFragmentAction.DeselectAll)
true
} else {
metrics.track(Event.RecentlyClosedTabsClosed)
false
}
}
Expand Down
Loading

0 comments on commit 5e174c8

Please sign in to comment.