Closes #1194: Adds shortcut telemetry
parent
edc9d31729
commit
471b08d97a
|
@ -55,6 +55,8 @@ events:
|
|||
extra_keys:
|
||||
search_suggestion:
|
||||
description: "A boolean that tells us whether or not the search term was suggested by the Awesomebar"
|
||||
search_shortcut:
|
||||
description: "A boolean that tells us whether or not the search was conducted through a search shortcut"
|
||||
bugs:
|
||||
- 959
|
||||
data_reviews:
|
||||
|
@ -62,6 +64,42 @@ events:
|
|||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
ss_menu_opened:
|
||||
type: event
|
||||
description: >
|
||||
A user opened the search shortcut menu in the search view by pressing the shortcuts button
|
||||
bugs:
|
||||
- 793
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/1202#issuecomment-476870449
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
ss_menu_closed:
|
||||
type: event
|
||||
description: >
|
||||
A user closed the search shortcut menu in the search view by pressing the shortcuts button
|
||||
bugs:
|
||||
- 793
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/1202#issuecomment-476870449
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
ss_selected:
|
||||
type: event
|
||||
description: >
|
||||
A user selected a search shortcut engine to use
|
||||
extra_keys:
|
||||
engine:
|
||||
description: "The name of the built-in search engine the user selected as a string"
|
||||
bugs:
|
||||
- 793
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/1202#issuecomment-476870449
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: "2020-03-01"
|
||||
|
||||
metrics:
|
||||
default_browser:
|
||||
|
|
|
@ -49,6 +49,9 @@ private val Event.name: String?
|
|||
is Event.SearchBarTapped -> ""
|
||||
is Event.EnteredUrl -> ""
|
||||
is Event.PerformedSearch -> ""
|
||||
is Event.SearchShortcutMenuOpened -> ""
|
||||
is Event.SearchShortcutMenuClosed -> ""
|
||||
is Event.SearchShortcutSelected -> ""
|
||||
}
|
||||
|
||||
class LeanplumMetricsService(private val application: Application) : MetricsService {
|
||||
|
|
|
@ -43,6 +43,8 @@ sealed class Event {
|
|||
object UserDownloadedSend : Event()
|
||||
object OpenedPocketStory : Event()
|
||||
object DarkModeEnabled : Event()
|
||||
object SearchShortcutMenuOpened : Event()
|
||||
object SearchShortcutMenuClosed : Event()
|
||||
|
||||
// Interaction Events
|
||||
data class SearchBarTapped(val source: Source) : Event() {
|
||||
|
@ -56,9 +58,16 @@ sealed class Event {
|
|||
get() = mapOf("autocomplete" to autoCompleted.toString())
|
||||
}
|
||||
|
||||
data class PerformedSearch(val fromSearchSuggestion: Boolean) : Event() {
|
||||
data class PerformedSearch(val fromSearchSuggestion: Boolean, val fromSearchShortcut: Boolean) : Event() {
|
||||
override val extras: Map<String, String>?
|
||||
get() = mapOf("search_suggestion" to fromSearchSuggestion.toString())
|
||||
get() = mapOf("search_suggestion" to fromSearchSuggestion.toString(),
|
||||
"search_shortcut" to fromSearchShortcut.toString())
|
||||
}
|
||||
|
||||
// Track only built-in engine selection. Do not track user-added engines!
|
||||
data class SearchShortcutSelected(val engine: String) : Event() {
|
||||
override val extras: Map<String, String>?
|
||||
get() = mapOf("engine" to engine)
|
||||
}
|
||||
|
||||
open val extras: Map<String, String>?
|
||||
|
|
|
@ -84,9 +84,15 @@ class SearchFragment : Fragment() {
|
|||
view.toolbar_wrapper.clipToOutline = false
|
||||
|
||||
search_shortcuts_button.setOnClickListener {
|
||||
getManagedEmitter<AwesomeBarChange>().onNext(AwesomeBarChange
|
||||
.SearchShortcutEnginePicker(!(
|
||||
(awesomeBarComponent.uiView as AwesomeBarUIView).state?.showShortcutEnginePicker ?: true)))
|
||||
val isOpen = (awesomeBarComponent.uiView as AwesomeBarUIView).state?.showShortcutEnginePicker ?: false
|
||||
|
||||
getManagedEmitter<AwesomeBarChange>().onNext(AwesomeBarChange.SearchShortcutEnginePicker(!isOpen))
|
||||
|
||||
if (isOpen) {
|
||||
requireComponents.analytics.metrics.track(Event.SearchShortcutMenuClosed)
|
||||
} else {
|
||||
requireComponents.analytics.metrics.track(Event.SearchShortcutMenuOpened)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +119,9 @@ class SearchFragment : Fragment() {
|
|||
val event = if (it.url.isUrl()) {
|
||||
Event.EnteredUrl(false)
|
||||
} else {
|
||||
Event.PerformedSearch(false)
|
||||
val isSearchShortcut = it.engine !=
|
||||
requireComponents.search.searchEngineManager.defaultSearchEngine
|
||||
Event.PerformedSearch(false, isSearchShortcut)
|
||||
}
|
||||
|
||||
requireComponents.analytics.metrics.track(event)
|
||||
|
@ -142,13 +150,20 @@ class SearchFragment : Fragment() {
|
|||
getSearchUseCase(requireContext(), sessionId == null)
|
||||
.invoke(it.searchTerms, it.engine)
|
||||
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
|
||||
requireComponents.analytics.metrics.track(Event.PerformedSearch(true))
|
||||
|
||||
val isSearchShortcut = it.engine !=
|
||||
requireComponents.search.searchEngineManager.defaultSearchEngine
|
||||
|
||||
requireComponents.analytics.metrics
|
||||
.track(Event.PerformedSearch(true, isSearchShortcut))
|
||||
}
|
||||
is AwesomeBarAction.SearchShortcutEngineSelected -> {
|
||||
getManagedEmitter<AwesomeBarChange>()
|
||||
.onNext(AwesomeBarChange.SearchShortcutEngineSelected(it.engine))
|
||||
getManagedEmitter<SearchChange>()
|
||||
.onNext(SearchChange.SearchShortcutEngineSelected(it.engine))
|
||||
|
||||
requireComponents.analytics.metrics.track(Event.SearchShortcutSelected(it.engine.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue