Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #800 - Adds metrics for the default search engine
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Apr 15, 2019
1 parent cf5ecc2 commit a2666c4
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
50 changes: 50 additions & 0 deletions app/metrics.yaml
Expand Up @@ -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"
Expand Up @@ -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),
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a2666c4

Please sign in to comment.