Fixes #1191 - Crash reporter metrics
parent
7e151f8c02
commit
0944180407
|
@ -101,6 +101,33 @@ events:
|
||||||
- telemetry-client-dev@mozilla.com
|
- telemetry-client-dev@mozilla.com
|
||||||
expires: "2020-03-01"
|
expires: "2020-03-01"
|
||||||
|
|
||||||
|
crash_reporter:
|
||||||
|
opened:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
The crash reporter was displayed
|
||||||
|
bugs:
|
||||||
|
- 1040
|
||||||
|
data_reviews:
|
||||||
|
- TBD
|
||||||
|
notification_emails:
|
||||||
|
- telemetry-client-dev@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
closed:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
The crash reporter was closed
|
||||||
|
extra_keys:
|
||||||
|
crash_submitted:
|
||||||
|
description: "A boolean that tells us whether or not the user submitted a crash report"
|
||||||
|
bugs:
|
||||||
|
- 1040
|
||||||
|
data_reviews:
|
||||||
|
- TBD
|
||||||
|
notification_emails:
|
||||||
|
- telemetry-client-dev@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
|
||||||
context_menu:
|
context_menu:
|
||||||
item_tapped:
|
item_tapped:
|
||||||
type: event
|
type: event
|
||||||
|
|
|
@ -8,11 +8,9 @@ import mozilla.components.service.glean.Glean
|
||||||
import mozilla.components.service.glean.metrics.NoExtraKeys
|
import mozilla.components.service.glean.metrics.NoExtraKeys
|
||||||
import mozilla.components.support.utils.Browsers
|
import mozilla.components.support.utils.Browsers
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.GleanMetrics.ContextMenu
|
import org.mozilla.fenix.GleanMetrics.*
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||||
import org.mozilla.fenix.GleanMetrics.Events
|
import org.mozilla.fenix.utils.Settings
|
||||||
import org.mozilla.fenix.GleanMetrics.FindInPage
|
|
||||||
|
|
||||||
private class EventWrapper<T : Enum<T>>(
|
private class EventWrapper<T : Enum<T>>(
|
||||||
private val recorder: ((Map<T, String>?) -> Unit),
|
private val recorder: ((Map<T, String>?) -> Unit),
|
||||||
|
@ -37,6 +35,7 @@ private class EventWrapper<T : Enum<T>>(
|
||||||
|
|
||||||
private val Event.wrapper
|
private val Event.wrapper
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
|
|
||||||
is Event.OpenedApp -> EventWrapper(
|
is Event.OpenedApp -> EventWrapper(
|
||||||
{ Events.appOpened.record(it) },
|
{ Events.appOpened.record(it) },
|
||||||
{ Events.appOpenedKeys.valueOf(it) }
|
{ Events.appOpenedKeys.valueOf(it) }
|
||||||
|
@ -72,6 +71,14 @@ private val Event.wrapper
|
||||||
{ ContextMenu.itemTapped.record(it) },
|
{ ContextMenu.itemTapped.record(it) },
|
||||||
{ ContextMenu.itemTappedKeys.valueOf(it) }
|
{ ContextMenu.itemTappedKeys.valueOf(it) }
|
||||||
)
|
)
|
||||||
|
is Event.CrashReporterOpened -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ CrashReporter.opened }
|
||||||
|
)
|
||||||
|
is Event.CrashReporterClosed -> EventWrapper(
|
||||||
|
{ CrashReporter.closed },
|
||||||
|
{ CrashReporter.closedKeys.valueOf(it) }
|
||||||
|
)
|
||||||
|
|
||||||
// Don't track other events with Glean
|
// Don't track other events with Glean
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,12 @@ sealed class Event {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object CrashReporterOpened : Event()
|
||||||
|
data class CrashReporterClosed(val crashSubmitted: Boolean) : Event() {
|
||||||
|
override val extras: Map<String, String>?
|
||||||
|
get() = mapOf("crash_submitted" to crashSubmitted.toString())
|
||||||
|
}
|
||||||
|
|
||||||
open val extras: Map<String, String>?
|
open val extras: Map<String, String>?
|
||||||
get() = null
|
get() = null
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,10 @@ import androidx.navigation.Navigation
|
||||||
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
|
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
|
||||||
import mozilla.components.lib.crash.Crash
|
import mozilla.components.lib.crash.Crash
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
class CrashReporterFragment : Fragment() {
|
class CrashReporterFragment : Fragment() {
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
@ -26,24 +29,25 @@ class CrashReporterFragment : Fragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val crashIntent = CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent
|
|
||||||
val crash = Crash.fromIntent(CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent)
|
val crash = Crash.fromIntent(CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent)
|
||||||
|
|
||||||
view.findViewById<TextView>(R.id.title).text =
|
view.findViewById<TextView>(R.id.title).text =
|
||||||
getString(R.string.tab_crash_title, context!!.getString(R.string.app_name))
|
getString(R.string.tab_crash_title, context!!.getString(R.string.app_name))
|
||||||
|
|
||||||
// TODO TelemetryWrapper.crashReporterOpened()
|
requireContext().components.analytics.metrics.track(Event.CrashReporterOpened)
|
||||||
|
|
||||||
close_tab_button.setOnClickListener {
|
close_tab_button.setOnClickListener {
|
||||||
val selectedSession = requireComponents.core.sessionManager.selectedSession
|
val selectedSession = requireComponents.core.sessionManager.selectedSession
|
||||||
|
|
||||||
selectedSession?.let { session -> requireComponents.useCases.tabsUseCases.removeTab.invoke(session) }
|
selectedSession?.let { session -> requireComponents.useCases.tabsUseCases.removeTab.invoke(session) }
|
||||||
// TODO TelemetryWrapper.crashReporterClosed(wantsSubmitCrashReport)
|
|
||||||
|
|
||||||
if (send_crash_checkbox.isChecked) {
|
var wantsSubmitCrashReport = false
|
||||||
|
if (Settings.getInstance(context!!).isCrashReportingEnabled) {
|
||||||
requireComponents.analytics.crashReporter.submitReport(crash)
|
requireComponents.analytics.crashReporter.submitReport(crash)
|
||||||
|
wantsSubmitCrashReport = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(wantsSubmitCrashReport))
|
||||||
navigateHome(view)
|
navigateHome(view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +63,6 @@ class CrashReporterFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onBackPressed() {
|
fun onBackPressed() {
|
||||||
// TODO TelemetryWrapper.crashReporterClosed(false)
|
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue