1
0
Fork 0

For #1242: Adds telemetry for error pages

master
Sawyer Blatz 2019-05-14 14:17:58 -07:00
parent 0080e7d701
commit aa9e5c46ae
4 changed files with 29 additions and 2 deletions

View File

@ -263,7 +263,6 @@ quick_action_sheet:
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
share_tapped:
@ -717,4 +716,20 @@ library:
- https://github.com/mozilla-mobile/fenix/pull/2538#issuecomment-492830242
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
error_page:
visited_error:
type: event
description: >
A user encountered an error page
extra_keys:
error_type:
description: "The error type of the error page encountered"
bugs:
- 1242
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/2491#issuecomment-492414486
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"

View File

@ -9,6 +9,7 @@ import mozilla.components.browser.errorpages.ErrorPages
import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.concept.engine.EngineSession
import mozilla.components.concept.engine.request.RequestInterceptor
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.exceptions.ExceptionDomains
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.utils.Settings
@ -45,11 +46,11 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
errorType: ErrorType,
uri: String?
): RequestInterceptor.ErrorResponse? {
val riskLevel = getRiskLevel(errorType)
val htmlResource = getPageForRiskLevel(riskLevel)
val cssResource = getStyleForRiskLevel(riskLevel)
context.components.analytics.metrics.track(Event.ErrorPageVisited(errorType))
return RequestInterceptor.ErrorResponse(
ErrorPages
.createErrorPage(context, errorType, uri = uri, htmlResource = htmlResource, cssResource = cssResource)

View File

@ -25,6 +25,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.mozilla.fenix.GleanMetrics.QrScanner
import org.mozilla.fenix.GleanMetrics.Library
import org.mozilla.fenix.GleanMetrics.ErrorPage
private class EventWrapper<T : Enum<T>>(
private val recorder: ((Map<T, String>?) -> Unit),
@ -183,6 +184,10 @@ private val Event.wrapper
{ Library.selectedItem },
{ Library.selectedItemKeys.valueOf(it) }
)
is Event.ErrorPageVisited -> EventWrapper(
{ ErrorPage.visitedError },
{ ErrorPage.visitedErrorKeys.valueOf(it) }
)
// Don't track other events with Glean
else -> null

View File

@ -4,6 +4,7 @@
package org.mozilla.fenix.components.metrics
import android.content.Context
import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.browser.search.SearchEngine
import mozilla.components.support.base.Component
import mozilla.components.support.base.facts.Fact
@ -110,6 +111,11 @@ sealed class Event {
get() = mapOf("source" to item)
}
data class ErrorPageVisited(val errorType: ErrorType) : Event() {
override val extras: Map<String, String>?
get() = mapOf("errorType" to errorType.name)
}
data class SearchBarTapped(val source: Source) : Event() {
enum class Source { HOME, BROWSER }
override val extras: Map<String, String>?