For #959 - Adds search related telemetry
parent
786592e8d0
commit
32f8e06e98
|
@ -31,6 +31,32 @@ events:
|
|||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: never
|
||||
entered_url:
|
||||
type: event
|
||||
description: >
|
||||
A user entered a url
|
||||
extra_keys:
|
||||
autocomplete: "The url was filled by the autocomplete"
|
||||
bugs:
|
||||
- 123456789
|
||||
data_reviews:
|
||||
- N/A
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: never
|
||||
performed_search:
|
||||
type: event
|
||||
description: >
|
||||
A user performed a search
|
||||
extra_keys:
|
||||
search_suggestion: "The search was initiated from a search suggestion"
|
||||
bugs:
|
||||
- 123456789
|
||||
data_reviews:
|
||||
- N/A
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
expires: never
|
||||
|
||||
metrics:
|
||||
default_browser:
|
||||
|
|
|
@ -16,6 +16,8 @@ private val Event.metricType: EventMetricType?
|
|||
get() = when(this) {
|
||||
is Event.OpenedApp -> Events.appOpened
|
||||
is Event.SearchBarTapped -> Events.searchBarTapped
|
||||
is Event.EnteredUrl -> Events.enteredUrl
|
||||
is Event.PerformedSearch -> Events.performedSearch
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ private val Event.name: String?
|
|||
|
||||
// Do not track these events in Leanplum
|
||||
is Event.SearchBarTapped -> ""
|
||||
}
|
||||
is Event.EnteredUrl -> ""
|
||||
is Event.PerformedSearch -> ""
|
||||
}
|
||||
|
||||
class LeanplumMetricsService(private val application: Application) : MetricsService {
|
||||
data class Token(val id: String, val token: String) {
|
||||
|
|
|
@ -52,6 +52,16 @@ sealed class Event {
|
|||
get() = mapOf("source" to source.name)
|
||||
}
|
||||
|
||||
data class EnteredUrl(val autoCompleted: Boolean) : Event() {
|
||||
override val extras: Map<String, String>?
|
||||
get() = mapOf("autocomplete" to autoCompleted.toString())
|
||||
}
|
||||
|
||||
data class PerformedSearch(val fromSearchSuggestion: Boolean) : Event() {
|
||||
override val extras: Map<String, String>?
|
||||
get() = mapOf("search_suggestion" to fromSearchSuggestion.toString())
|
||||
}
|
||||
|
||||
open val extras: Map<String, String>?
|
||||
get() = null
|
||||
}
|
||||
|
|
|
@ -14,10 +14,12 @@ import androidx.fragment.app.Fragment
|
|||
import kotlinx.android.synthetic.main.fragment_search.view.*
|
||||
import mozilla.components.feature.search.SearchUseCases
|
||||
import mozilla.components.feature.session.SessionUseCases
|
||||
import mozilla.components.support.ktx.kotlin.isUrl
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.toolbar.SearchAction
|
||||
import org.mozilla.fenix.components.toolbar.SearchState
|
||||
import org.mozilla.fenix.components.toolbar.ToolbarComponent
|
||||
|
@ -92,6 +94,14 @@ class SearchFragment : Fragment() {
|
|||
if (it.url.isNotBlank()) {
|
||||
(activity as HomeActivity).openToBrowserAndLoad(it.url, it.session,
|
||||
BrowserDirection.FromSearch)
|
||||
|
||||
val event = if (it.url.isUrl()) {
|
||||
Event.EnteredUrl(false)
|
||||
} else {
|
||||
Event.PerformedSearch(false)
|
||||
}
|
||||
|
||||
requireComponents.analytics.metrics.track(event)
|
||||
}
|
||||
}
|
||||
is SearchAction.TextChanged -> {
|
||||
|
@ -109,11 +119,13 @@ class SearchFragment : Fragment() {
|
|||
is AwesomeBarAction.URLTapped -> {
|
||||
getSessionUseCase(requireContext(), sessionId == null).invoke(it.url)
|
||||
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
|
||||
requireComponents.analytics.metrics.track(Event.EnteredUrl(false))
|
||||
}
|
||||
is AwesomeBarAction.SearchTermsTapped -> {
|
||||
getSearchUseCase(requireContext(), sessionId == null)
|
||||
.invoke(it.searchTerms, it.engine)
|
||||
(activity as HomeActivity).openToBrowser(sessionId, BrowserDirection.FromSearch)
|
||||
requireComponents.analytics.metrics.track(Event.PerformedSearch(true))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue