Fixes #1191 - Crash reporter metrics
parent
7e151f8c02
commit
0944180407
|
@ -101,6 +101,33 @@ events:
|
|||
- telemetry-client-dev@mozilla.com
|
||||
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:
|
||||
item_tapped:
|
||||
type: event
|
||||
|
|
|
@ -8,11 +8,9 @@ import mozilla.components.service.glean.Glean
|
|||
import mozilla.components.service.glean.metrics.NoExtraKeys
|
||||
import mozilla.components.support.utils.Browsers
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.GleanMetrics.ContextMenu
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.GleanMetrics.*
|
||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||
import org.mozilla.fenix.GleanMetrics.Events
|
||||
import org.mozilla.fenix.GleanMetrics.FindInPage
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
private class EventWrapper<T : Enum<T>>(
|
||||
private val recorder: ((Map<T, String>?) -> Unit),
|
||||
|
@ -37,6 +35,7 @@ private class EventWrapper<T : Enum<T>>(
|
|||
|
||||
private val Event.wrapper
|
||||
get() = when (this) {
|
||||
|
||||
is Event.OpenedApp -> EventWrapper(
|
||||
{ Events.appOpened.record(it) },
|
||||
{ Events.appOpenedKeys.valueOf(it) }
|
||||
|
@ -72,6 +71,14 @@ private val Event.wrapper
|
|||
{ ContextMenu.itemTapped.record(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
|
||||
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>?
|
||||
get() = null
|
||||
}
|
||||
|
|
|
@ -15,7 +15,10 @@ import androidx.navigation.Navigation
|
|||
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
|
||||
import mozilla.components.lib.crash.Crash
|
||||
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.utils.Settings
|
||||
|
||||
class CrashReporterFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
|
@ -26,24 +29,25 @@ class CrashReporterFragment : Fragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val crashIntent = CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent
|
||||
val crash = Crash.fromIntent(CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent)
|
||||
|
||||
view.findViewById<TextView>(R.id.title).text =
|
||||
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 {
|
||||
val selectedSession = requireComponents.core.sessionManager.selectedSession
|
||||
|
||||
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)
|
||||
wantsSubmitCrashReport = true
|
||||
}
|
||||
|
||||
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(wantsSubmitCrashReport))
|
||||
navigateHome(view)
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +63,6 @@ class CrashReporterFragment : Fragment() {
|
|||
}
|
||||
|
||||
fun onBackPressed() {
|
||||
// TODO TelemetryWrapper.crashReporterClosed(false)
|
||||
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(false))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue