For #957 - Adds telemetry for context menu items
parent
5764450e34
commit
e19e13c768
|
@ -101,6 +101,27 @@ events:
|
|||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
|
||||
context_menu:
|
||||
item_tapped:
|
||||
type: event
|
||||
description: >
|
||||
A user tapped an item in the browsers context menu
|
||||
extra_keys:
|
||||
named:
|
||||
description: >
|
||||
The name of the item that was tapped. Available items are
|
||||
```
|
||||
open_in_new_tab, open_in_private_tab, open_image_in_new_tab,
|
||||
save_image, share_link, copy_link, copy_image_location
|
||||
```
|
||||
bugs:
|
||||
- 957
|
||||
data_reviews:
|
||||
- TBD
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
|
||||
find_in_page:
|
||||
opened:
|
||||
type: event
|
||||
|
|
|
@ -8,6 +8,7 @@ import mozilla.components.service.glean.Glean
|
|||
import mozilla.components.service.glean.metrics.NoExtraKeys
|
||||
import mozilla.components.support.utils.Browsers
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.GleanMetrics.ContextMenu
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||
import org.mozilla.fenix.GleanMetrics.Events
|
||||
|
@ -61,12 +62,16 @@ private val Event.wrapper
|
|||
is Event.FindInPageNext -> EventWrapper<NoExtraKeys>(
|
||||
{ FindInPage.nextResult.record(it) }
|
||||
)
|
||||
is Event.FindInPagePrevious-> EventWrapper<NoExtraKeys>(
|
||||
is Event.FindInPagePrevious -> EventWrapper<NoExtraKeys>(
|
||||
{ FindInPage.previousResult.record(it) }
|
||||
)
|
||||
is Event.FindInPageSearchCommitted -> EventWrapper<NoExtraKeys>(
|
||||
{ FindInPage.searchedPage.record(it) }
|
||||
)
|
||||
is Event.ContextMenuItemTapped -> EventWrapper(
|
||||
{ ContextMenu.itemTapped.record(it) },
|
||||
{ ContextMenu.itemTappedKeys.valueOf(it) }
|
||||
)
|
||||
// Don't track other events with Glean
|
||||
else -> null
|
||||
}
|
||||
|
|
|
@ -74,26 +74,47 @@ sealed class Event {
|
|||
get() = mapOf("engine" to engine)
|
||||
}
|
||||
|
||||
object FindInPageOpened: Event()
|
||||
object FindInPageClosed: Event()
|
||||
object FindInPageNext: Event()
|
||||
object FindInPagePrevious: Event()
|
||||
object FindInPageSearchCommitted: Event()
|
||||
object FindInPageOpened : Event()
|
||||
object FindInPageClosed : Event()
|
||||
object FindInPageNext : Event()
|
||||
object FindInPagePrevious : Event()
|
||||
object FindInPageSearchCommitted : Event()
|
||||
|
||||
class ContextMenuItemTapped private constructor(val item: String) : Event() {
|
||||
override val extras: Map<String, String>?
|
||||
get() = mapOf("named" to item)
|
||||
|
||||
companion object {
|
||||
fun create(context_item: String) = allowList[context_item]?.let { ContextMenuItemTapped(it) }
|
||||
|
||||
private val allowList = mapOf(
|
||||
"mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab",
|
||||
"mozac.feature.contextmenu.open_in_private_tab" to "open_in_private_tab",
|
||||
"mozac.feature.contextmenu.open_image_in_new_tab" to "open_image_in_new_tab",
|
||||
"mozac.feature.contextmenu.save_image" to "save_image",
|
||||
"mozac.feature.contextmenu.share_link" to "share_link",
|
||||
"mozac.feature.contextmenu.copy_link" to "copy_link",
|
||||
"mozac.feature.contextmenu.copy_image_location" to "copy_image_location"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open val extras: Map<String, String>?
|
||||
get() = null
|
||||
}
|
||||
|
||||
private fun Fact.toEvent(): Event? = when(Pair(component, item)){
|
||||
private fun Fact.toEvent(): Event? = when (Pair(component, item)) {
|
||||
Pair(Component.FEATURE_FINDINPAGE, "previous") -> Event.FindInPagePrevious
|
||||
Pair(Component.FEATURE_FINDINPAGE, "next") -> Event.FindInPageNext
|
||||
Pair(Component.FEATURE_FINDINPAGE, "close") -> Event.FindInPageClosed
|
||||
Pair(Component.FEATURE_FINDINPAGE, "input") -> Event.FindInPageSearchCommitted
|
||||
Pair(Component.FEATURE_CONTEXTMENU, "item") -> {
|
||||
metadata?.get("item")?.let { Event.ContextMenuItemTapped.create(it.toString()) }
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
interface MetricsService {
|
||||
fun start()
|
||||
fun track(event: Event)
|
||||
|
|
Loading…
Reference in New Issue