android-components / mozilla.components.lib.crash / CrashReporter

CrashReporter

class CrashReporter (source)

A generic crash reporter that can report crashes to multiple services.

In the onCreate() method of your Application class create a CrashReporter instance and call install():

CrashReporter(
  services = listOf(
    // List the crash reporting services you want to use
  )
).install(this)

With this minimal setup the crash reporting library will capture “uncaught exception” crashes and “native code” crashes and forward them to the configured crash reporting services.

Types

Name Summary
Prompt enum class Prompt
PromptConfiguration data class PromptConfiguration
Configuration for the crash reporter prompt.

Constructors

Name Summary
<init> CrashReporter(services: List<CrashReporterService> = emptyList(), telemetryServices: List<CrashReporterService> = emptyList(), shouldPrompt: Prompt = Prompt.NEVER, enabled: Boolean = true, promptConfiguration: PromptConfiguration = PromptConfiguration(), nonFatalCrashIntent: <ERROR CLASS>? = null, scope: CoroutineScope = CoroutineScope(Dispatchers.IO))
A generic crash reporter that can report crashes to multiple services.

Properties

Name Summary
enabled var enabled: Boolean
Enable/Disable crash reporting.

Functions

Name Summary
install fun install(applicationContext: <ERROR CLASS>): CrashReporter
Install this CrashReporter instance. At this point the component will be setup to collect crash reports.
recordCrashBreadcrumb fun recordCrashBreadcrumb(breadcrumb: Breadcrumb): Unit
Add a crash breadcrumb to all registered services with breadcrumb support.
submitCaughtException fun submitCaughtException(throwable: Throwable): Job
Submit a caught exception report to all registered services.
submitCrashTelemetry fun submitCrashTelemetry(crash: Crash, then: () -> Unit = {}): Job
Submit a crash report to all registered telemetry services.
submitReport fun submitReport(crash: Crash, then: () -> Unit = {}): Job
Submit a crash report to all registered services.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.