Fixes #1024 - Adds metrics for browser menu items
parent
0944180407
commit
4b4d172e2e
|
@ -64,6 +64,23 @@ events:
|
||||||
notification_emails:
|
notification_emails:
|
||||||
- telemetry-client-dev@mozilla.com
|
- telemetry-client-dev@mozilla.com
|
||||||
expires: "2020-03-01"
|
expires: "2020-03-01"
|
||||||
|
browser_menu_action:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A browser menu item was tapped
|
||||||
|
extra_keys:
|
||||||
|
item:
|
||||||
|
description: >
|
||||||
|
A string containing the name of the item the user tapped. These items include:
|
||||||
|
Settings, Your library, Help, Desktop Site toggle on/off, Find in Page, New Tab,
|
||||||
|
Private Tab, Share, Report Site Issue, Back/Forward button, Reload Button
|
||||||
|
bugs:
|
||||||
|
- 1024
|
||||||
|
data_reviews:
|
||||||
|
- TBD
|
||||||
|
notification_emails:
|
||||||
|
- telemetry-client-dev@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
ss_menu_opened:
|
ss_menu_opened:
|
||||||
type: event
|
type: event
|
||||||
description: >
|
description: >
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.mozilla.fenix.IntentReceiverActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.FindInPageIntegration
|
import org.mozilla.fenix.components.FindInPageIntegration
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
|
import org.mozilla.fenix.components.metrics.Event.BrowserMenuItemTapped.Item
|
||||||
import org.mozilla.fenix.components.toolbar.SearchAction
|
import org.mozilla.fenix.components.toolbar.SearchAction
|
||||||
import org.mozilla.fenix.components.toolbar.SearchState
|
import org.mozilla.fenix.components.toolbar.SearchState
|
||||||
import org.mozilla.fenix.components.toolbar.ToolbarComponent
|
import org.mozilla.fenix.components.toolbar.ToolbarComponent
|
||||||
|
@ -279,7 +280,10 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||||
Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)
|
Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is SearchAction.ToolbarMenuItemTapped -> handleToolbarItemInteraction(it)
|
is SearchAction.ToolbarMenuItemTapped -> {
|
||||||
|
trackToolbarItemInteraction(it)
|
||||||
|
handleToolbarItemInteraction(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,6 +356,29 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||||
promptsFeature.withFeature { it.onActivityResult(requestCode, resultCode, data) }
|
promptsFeature.withFeature { it.onActivityResult(requestCode, resultCode, data) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method triggers the complexity warning. However it's actually not that hard to understand.
|
||||||
|
@SuppressWarnings("ComplexMethod")
|
||||||
|
private fun trackToolbarItemInteraction(action: SearchAction.ToolbarMenuItemTapped) {
|
||||||
|
val item = when (action.item) {
|
||||||
|
ToolbarMenu.Item.Back -> Item.BACK
|
||||||
|
ToolbarMenu.Item.Forward -> Item.FORWARD
|
||||||
|
ToolbarMenu.Item.Reload -> Item.RELOAD
|
||||||
|
ToolbarMenu.Item.Stop -> Item.STOP
|
||||||
|
ToolbarMenu.Item.Settings -> Item.SETTINGS
|
||||||
|
ToolbarMenu.Item.Library -> Item.LIBRARY
|
||||||
|
is ToolbarMenu.Item.RequestDesktop ->
|
||||||
|
if (action.item.isChecked) Item.DESKTOP_VIEW_ON else Item.DESKTOP_VIEW_OFF
|
||||||
|
ToolbarMenu.Item.NewPrivateTab -> Item.NEW_PRIVATE_TAB
|
||||||
|
ToolbarMenu.Item.FindInPage -> Item.FIND_IN_PAGE
|
||||||
|
ToolbarMenu.Item.ReportIssue -> Item.REPORT_SITE_ISSUE
|
||||||
|
ToolbarMenu.Item.Help -> Item.HELP
|
||||||
|
ToolbarMenu.Item.NewTab -> Item.NEW_TAB
|
||||||
|
ToolbarMenu.Item.OpenInFenix -> Item.OPEN_IN_FENIX
|
||||||
|
ToolbarMenu.Item.Share -> Item.SHARE
|
||||||
|
}
|
||||||
|
|
||||||
|
requireComponents.analytics.metrics.track(Event.BrowserMenuItemTapped(item))
|
||||||
|
}
|
||||||
// This method triggers the complexity warning. However it's actually not that hard to understand.
|
// This method triggers the complexity warning. However it's actually not that hard to understand.
|
||||||
@SuppressWarnings("ComplexMethod")
|
@SuppressWarnings("ComplexMethod")
|
||||||
private fun handleToolbarItemInteraction(action: SearchAction.ToolbarMenuItemTapped) {
|
private fun handleToolbarItemInteraction(action: SearchAction.ToolbarMenuItemTapped) {
|
||||||
|
|
|
@ -8,7 +8,10 @@ import mozilla.components.service.glean.Glean
|
||||||
import mozilla.components.service.glean.metrics.NoExtraKeys
|
import mozilla.components.service.glean.metrics.NoExtraKeys
|
||||||
import mozilla.components.support.utils.Browsers
|
import mozilla.components.support.utils.Browsers
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.GleanMetrics.*
|
import org.mozilla.fenix.GleanMetrics.CrashReporter
|
||||||
|
import org.mozilla.fenix.GleanMetrics.Events
|
||||||
|
import org.mozilla.fenix.GleanMetrics.FindInPage
|
||||||
|
import org.mozilla.fenix.GleanMetrics.ContextMenu
|
||||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
|
@ -35,7 +38,6 @@ private class EventWrapper<T : Enum<T>>(
|
||||||
|
|
||||||
private val Event.wrapper
|
private val Event.wrapper
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
|
|
||||||
is Event.OpenedApp -> EventWrapper(
|
is Event.OpenedApp -> EventWrapper(
|
||||||
{ Events.appOpened.record(it) },
|
{ Events.appOpened.record(it) },
|
||||||
{ Events.appOpenedKeys.valueOf(it) }
|
{ Events.appOpenedKeys.valueOf(it) }
|
||||||
|
@ -78,6 +80,10 @@ private val Event.wrapper
|
||||||
{ CrashReporter.closed },
|
{ CrashReporter.closed },
|
||||||
{ CrashReporter.closedKeys.valueOf(it) }
|
{ CrashReporter.closedKeys.valueOf(it) }
|
||||||
)
|
)
|
||||||
|
is Event.BrowserMenuItemTapped -> EventWrapper(
|
||||||
|
{ Events.browserMenuAction },
|
||||||
|
{ Events.browserMenuActionKeys.valueOf(it) }
|
||||||
|
)
|
||||||
|
|
||||||
// Don't track other events with Glean
|
// Don't track other events with Glean
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
@ -105,6 +105,16 @@ sealed class Event {
|
||||||
get() = mapOf("crash_submitted" to crashSubmitted.toString())
|
get() = mapOf("crash_submitted" to crashSubmitted.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class BrowserMenuItemTapped(val item: Item) : Event() {
|
||||||
|
enum class Item {
|
||||||
|
SETTINGS, LIBRARY, HELP, DESKTOP_VIEW_ON, DESKTOP_VIEW_OFF, FIND_IN_PAGE, NEW_TAB,
|
||||||
|
NEW_PRIVATE_TAB, SHARE, REPORT_SITE_ISSUE, BACK, FORWARD, RELOAD, STOP, OPEN_IN_FENIX
|
||||||
|
}
|
||||||
|
|
||||||
|
override val extras: Map<String, String>?
|
||||||
|
get() = mapOf("item" to item.toString().toLowerCase())
|
||||||
|
}
|
||||||
|
|
||||||
open val extras: Map<String, String>?
|
open val extras: Map<String, String>?
|
||||||
get() = null
|
get() = null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue