1
0
Fork 0

For #969: Adds telemetry for collections (#3935)

master
Sawyer Blatz 2019-07-18 16:05:42 -07:00 committed by Jeff Boek
parent e544827e83
commit 13198f56df
7 changed files with 270 additions and 1 deletions

View File

@ -940,4 +940,115 @@ reader_mode:
- https://github.com/mozilla-mobile/fenix/pull/3941 - https://github.com/mozilla-mobile/fenix/pull/3941
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-03-01"
collections:
renamed:
type: event
description: >
A user renamed a collection
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
tab_restored:
type: event
description: >
A user restored a tab from collection tab list
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
all_tabs_restored:
type: event
description: >
A user tapped "open tabs" from collection menu
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
tab_removed:
type: event
description: >
A user tapped remove tab from collection tab list
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
shared:
type: event
description: >
A user tapped share collection
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
removed:
type: event
description: >
A user tapped delete collection from collection menu
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
saved:
type: event
description: >
A user saved a list of tabs to a new collection
extra_keys:
tabs_open:
description: "The number of tabs open in the current session"
tabs_selected:
description: "The number of tabs added to the collection"
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
tabs_added:
type: event
description: >
A user saved a list of tabs to an existing collection
extra_keys:
tabs_open:
description: "The number of tabs open in the current session"
tabs_selected:
description: "The number of tabs added to the collection"
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
tab_select_opened:
type: event
description: >
A user opened the select tabs screen (the first step of the collection creation flow)
bugs:
- 969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3935
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01" expires: "2020-03-01"

View File

@ -29,6 +29,8 @@ import kotlinx.coroutines.Job
import mozilla.components.support.ktx.android.view.hideKeyboard import mozilla.components.support.ktx.android.view.hideKeyboard
import mozilla.components.support.ktx.android.view.showKeyboard import mozilla.components.support.ktx.android.view.showKeyboard
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.increaseTapArea import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.ext.urlToTrimmedHost import org.mozilla.fenix.ext.urlToTrimmedHost
import org.mozilla.fenix.home.sessioncontrol.Tab import org.mozilla.fenix.home.sessioncontrol.Tab
@ -124,6 +126,8 @@ class CollectionCreationUIView(
when (it.saveCollectionStep) { when (it.saveCollectionStep) {
is SaveCollectionStep.SelectTabs -> { is SaveCollectionStep.SelectTabs -> {
view.context.components.analytics.metrics.track(Event.CollectionTabSelectOpened)
view.tab_list.isClickable = true view.tab_list.isClickable = true
back_button.setOnClickListener { back_button.setOnClickListener {

View File

@ -17,6 +17,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.mozilla.fenix.FenixViewModelProvider import org.mozilla.fenix.FenixViewModelProvider
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.home.sessioncontrol.Tab import org.mozilla.fenix.home.sessioncontrol.Tab
@ -122,6 +123,11 @@ class CreateCollectionFragment : DialogFragment() {
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
context.components.core.tabCollectionStorage.createCollection(it.name, sessionBundle) context.components.core.tabCollectionStorage.createCollection(it.name, sessionBundle)
} }
context.components.analytics.metrics.track(
Event.CollectionSaved(context.components.core.sessionManager.size, sessionBundle.size)
)
closeTabsIfNecessary(it.tabs) closeTabsIfNecessary(it.tabs)
} }
} }
@ -133,6 +139,11 @@ class CreateCollectionFragment : DialogFragment() {
context.components.core.tabCollectionStorage context.components.core.tabCollectionStorage
.addTabsToCollection(it.collection, sessionBundle) .addTabsToCollection(it.collection, sessionBundle)
} }
context.components.analytics.metrics.track(
Event.CollectionTabsAdded(context.components.core.sessionManager.size, sessionBundle.size)
)
closeTabsIfNecessary(it.tabs) closeTabsIfNecessary(it.tabs)
} }
} }
@ -140,6 +151,7 @@ class CreateCollectionFragment : DialogFragment() {
dismiss() dismiss()
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
requireComponents.core.tabCollectionStorage.renameCollection(it.collection, it.name) requireComponents.core.tabCollectionStorage.renameCollection(it.collection, it.name)
requireComponents.analytics.metrics.track(Event.CollectionRenamed)
} }
} }
} }

View File

@ -29,9 +29,10 @@ import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.GleanMetrics.QrScanner import org.mozilla.fenix.GleanMetrics.QrScanner
import org.mozilla.fenix.GleanMetrics.QuickActionSheet import org.mozilla.fenix.GleanMetrics.QuickActionSheet
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAccount
import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.SyncAuth
import org.mozilla.fenix.ext.components
private class EventWrapper<T : Enum<T>>( private class EventWrapper<T : Enum<T>>(
private val recorder: ((Map<T, String>?) -> Unit), private val recorder: ((Map<T, String>?) -> Unit),
@ -243,6 +244,27 @@ private val Event.wrapper
is Event.HistoryAllItemsRemoved -> EventWrapper<NoExtraKeys>( is Event.HistoryAllItemsRemoved -> EventWrapper<NoExtraKeys>(
{ History.removedAll.record(it) } { History.removedAll.record(it) }
) )
is Event.CollectionRenamed -> EventWrapper<NoExtraKeys>(
{ Collections.renamed.record(it) }
)
is Event.CollectionTabRestored -> EventWrapper<NoExtraKeys>(
{ Collections.tabRestored.record(it) }
)
is Event.CollectionAllTabsRestored -> EventWrapper<NoExtraKeys>(
{ Collections.allTabsRestored.record(it) }
)
is Event.CollectionTabRemoved -> EventWrapper<NoExtraKeys>(
{ Collections.tabRemoved.record(it) }
)
is Event.CollectionShared -> EventWrapper<NoExtraKeys>(
{ Collections.shared.record(it) }
)
is Event.CollectionRemoved -> EventWrapper<NoExtraKeys>(
{ Collections.removed.record(it) }
)
is Event.CollectionTabSelectOpened -> EventWrapper<NoExtraKeys>(
{ Collections.tabSelectOpened.record(it) }
)
// Don't track other events with Glean // Don't track other events with Glean
else -> null else -> null

View File

@ -101,6 +101,13 @@ sealed class Event {
object ReaderModeAvailable : Event() object ReaderModeAvailable : Event()
object ReaderModeOpened : Event() object ReaderModeOpened : Event()
object ReaderModeAppearanceOpened : Event() object ReaderModeAppearanceOpened : Event()
object CollectionRenamed : Event()
object CollectionTabRestored : Event()
object CollectionAllTabsRestored : Event()
object CollectionTabRemoved : Event()
object CollectionShared : Event()
object CollectionRemoved : Event()
object CollectionTabSelectOpened : Event()
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() { data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
private val switchPreferenceTelemetryAllowList = listOf( private val switchPreferenceTelemetryAllowList = listOf(
@ -124,6 +131,22 @@ sealed class Event {
} }
// Interaction Events // Interaction Events
data class CollectionSaved(val tabsOpenCount: Int, val tabsSelectedCount: Int) : Event() {
override val extras: Map<String, String>?
get() = mapOf(
"tabs_open" to tabsOpenCount.toString(),
"tabs_selected" to tabsSelectedCount.toString()
)
}
data class CollectionTabsAdded(val tabsOpenCount: Int, val tabsSelectedCount: Int) : Event() {
override val extras: Map<String, String>?
get() = mapOf(
"tabs_open" to tabsOpenCount.toString(),
"tabs_selected" to tabsSelectedCount.toString()
)
}
data class LibrarySelectedItem(val item: String) : Event() { data class LibrarySelectedItem(val item: String) : Event() {
override val extras: Map<String, String>? override val extras: Map<String, String>?
get() = mapOf("item" to item) get() = mapOf("item" to item)

View File

@ -460,6 +460,7 @@ class HomeFragment : Fragment(), AccountObserver {
setPositiveButton(R.string.tab_collection_dialog_positive) { dialog: DialogInterface, _ -> setPositiveButton(R.string.tab_collection_dialog_positive) { dialog: DialogInterface, _ ->
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
requireComponents.core.tabCollectionStorage.removeCollection(tabCollection) requireComponents.core.tabCollectionStorage.removeCollection(tabCollection)
requireComponents.analytics.metrics.track(Event.CollectionRemoved)
}.invokeOnCompletion { }.invokeOnCompletion {
dialog.dismiss() dialog.dismiss()
} }
@ -516,6 +517,7 @@ class HomeFragment : Fragment(), AccountObserver {
) )
(activity as HomeActivity).openToBrowser(BrowserDirection.FromHome) (activity as HomeActivity).openToBrowser(BrowserDirection.FromHome)
} }
requireComponents.analytics.metrics.track(Event.CollectionTabRestored)
} }
is CollectionAction.OpenTabs -> { is CollectionAction.OpenTabs -> {
invokePendingDeleteJobs() invokePendingDeleteJobs()
@ -540,15 +542,18 @@ class HomeFragment : Fragment(), AccountObserver {
delay(ANIM_SCROLL_DELAY) delay(ANIM_SCROLL_DELAY)
sessionControlComponent.view.smoothScrollToPosition(0) sessionControlComponent.view.smoothScrollToPosition(0)
} }
requireComponents.analytics.metrics.track(Event.CollectionAllTabsRestored)
} }
is CollectionAction.ShareTabs -> { is CollectionAction.ShareTabs -> {
val shareTabs = action.collection.tabs.map { ShareTab(it.url, it.title) } val shareTabs = action.collection.tabs.map { ShareTab(it.url, it.title) }
share(tabs = shareTabs) share(tabs = shareTabs)
requireComponents.analytics.metrics.track(Event.CollectionShared)
} }
is CollectionAction.RemoveTab -> { is CollectionAction.RemoveTab -> {
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
requireComponents.core.tabCollectionStorage.removeTabFromCollection(action.collection, action.tab) requireComponents.core.tabCollectionStorage.removeTabFromCollection(action.collection, action.tab)
} }
requireComponents.analytics.metrics.track(Event.CollectionTabRemoved)
} }
} }
} }

View File

@ -800,6 +800,98 @@ tracking_protection</td>
</table> </table>
</pre> </pre>
## collections
<pre>
<table style="width: 100%">
<tr>
<th>key</th>
<th>type</th>
<th>description</th>
<th>data deview</th>
<th>extras</th>
<th>expires</th>
</tr>
<tr>
<td>renamed</td>
<td>event</td>
<td>A user renamed a collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>tab_restored</td>
<td>event</td>
<td>A user restored a tab from collection tab list</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>all_tabs_restored</td>
<td>event</td>
<td>A user tapped "open tabs" from collection menu</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>tab_removed</td>
<td>event</td>
<td>A user tapped remove tab from collection tab list</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>shared</td>
<td>event</td>
<td>A user tapped share collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>removed</td>
<td>event</td>
<td>A user tapped delete collection from collection menu</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>saved</td>
<td>event</td>
<td>A user saved a list of tabs to a new collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td>tabs_open: The number of tabs open in the current session
tabs_selected: The number of tabs added to the collection
</td>
<td>2020-03-01</td>
</tr>
<tr>
<td>tabs_added</td>
<td>event</td>
<td>A user saved a list of tabs to an existing collection</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td>tabs_open: The number of tabs open in the current session
tabs_selected: The number of tabs added to the collection
</td>
<td>2020-03-01</td>
</tr>
<tr>
<td>tab_select_opened</td>
<td>event</td>
<td>A user opened the select tabs screen (the first step of the collection creation flow)</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3935">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
</table>
</pre>
## Metrics ## Metrics
Items that are added to the metrics ping Items that are added to the metrics ping