1
0
Fork 0

For #800 - Adds metrics for the default search engine

master
Jeff Boek 2019-04-12 13:25:16 -07:00
parent cf5ecc23e9
commit a2666c4f74
2 changed files with 64 additions and 0 deletions

View File

@ -308,3 +308,53 @@ metrics:
- fenix-core@mozilla.com
expires: "2020-03-01"
search.default_engine:
code:
type: string
description: >
If the search engine is pre-loaded with Fenix this value
will be the search engine identifier. If it's a custom search engine
(defined: https://github.com/mozilla-mobile/fenix/issues/1607) the
value will be "custom"
send_in_pings:
- metrics
bugs:
- 800
data_reviews:
- https://github.com/mozilla-mobile/fenix/issues/1607
notification_emails:
- fenix-core@mozilla.com
expires: "2019-09-01"
name:
type: string
description: >
If the search engine is pre-loaded with Fenix this value
will be the search engine name. If it's a custom search engine
(defined: https://github.com/mozilla-mobile/fenix/issues/1607) the
value will be "custom"
send_in_pings:
- metrics
bugs:
- 800
data_reviews:
- https://github.com/mozilla-mobile/fenix/issues/1607
notification_emails:
- fenix-core@mozilla.com
expires: "2019-09-01"
submission_url:
type: string
description: >
If the search engine is pre-loaded with Fenix this value
will be he base URL we use to build the search query for the search engine.
For example: https://mysearchengine.com/?query=%s. If it's a custom search engine
(defined: https://github.com/mozilla-mobile/fenix/issues/1607) the
value will be "custom"
send_in_pings:
- metrics
bugs:
- 800
data_reviews:
- https://github.com/mozilla-mobile/fenix/issues/1607
notification_emails:
- fenix-core@mozilla.com
expires: "2019-09-01"

View File

@ -13,6 +13,8 @@ import org.mozilla.fenix.GleanMetrics.FindInPage
import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.QuickActionSheet
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.ext.components
private class EventWrapper<T : Enum<T>>(
private val recorder: ((Map<T, String>?) -> Unit),
@ -119,6 +121,18 @@ class GleanMetricsService(private val context: Context) : MetricsService {
defaultBrowser.set(Browsers.all(context).isDefaultBrowser)
}
SearchDefaultEngine.apply {
val defaultEngine = context
.components
.search
.searchEngineManager
.defaultSearchEngine ?: return@apply
code.set(defaultEngine.identifier)
name.set(defaultEngine.name)
submissionUrl.set(defaultEngine.buildSearchUrl(""))
}
initialized = true
}