This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for app-services error reporting.
- Added new component that hooks into the new app-services error reporter and listens for events. When it sees an event it submits it to the crash reporter. - Added support for customizing crash reports for these errors.
- Loading branch information
1 parent
1d07779
commit ac1a2df
Showing
12 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...nents/concept/base/src/main/java/mozilla/components/concept/base/crash/RustCrashReport.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.concept.base.crash | ||
|
||
/** | ||
* Crash report for rust errors | ||
* | ||
* We implement this on exception classes that correspond to Rust errors to | ||
* customize how the crash reports look. | ||
* | ||
* CrashReporting implementors should test if exceptions implement this | ||
* interface. If so, they should try to customize their crash reports to match. | ||
*/ | ||
interface RustCrashReport { | ||
val typeName: String | ||
val message: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Handles errors that come from Rust functions. | ||
|
||
This component defines and installs an application-services `ApplicationErrorReporter` class that: | ||
- Forwords error reports and breadcrumbs to `SentryServices` | ||
- Reports error counts to Glean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion config.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdkVersion config.minSdkVersion | ||
targetSdkVersion config.targetSdkVersion | ||
} | ||
|
||
lintOptions { | ||
warningsAsErrors true | ||
abortOnError true | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
consumerProguardFiles 'proguard-rules-consumer.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation Dependencies.mozilla_errorsupport | ||
implementation Dependencies.kotlin_stdlib | ||
implementation Dependencies.kotlin_coroutines | ||
implementation project(':support-base') | ||
} | ||
|
||
apply from: '../../../publish.gradle' | ||
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ProGuard rules for consumers of this library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/sebastian/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- This Source Code Form is subject to the terms of the Mozilla Public | ||
- License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
- You can obtain one at http://mozilla.org/MPL/2.0/. --> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="mozilla.components.support.rusterrors" /> |
39 changes: 39 additions & 0 deletions
39
...ents/support/rusterrors/src/main/java/mozilla/components/support/rusterrors/RustErrors.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.support.rusterrors | ||
|
||
import mozilla.appservices.errorsupport.ApplicationErrorReporter | ||
import mozilla.appservices.errorsupport.setApplicationErrorReporter | ||
import mozilla.components.concept.base.crash.Breadcrumb | ||
import mozilla.components.concept.base.crash.CrashReporting | ||
import mozilla.components.concept.base.crash.RustCrashReport | ||
|
||
/** | ||
* Initialize application services error reporting | ||
* | ||
* Errors reports and breadcrumbs from Application Services will be forwarded | ||
* to the CrashReporting instance. Error counting, which is used for expected | ||
* errors like network errors, will be counted with Glean. | ||
*/ | ||
public fun initializeRustErrors(crashReporter: CrashReporting) { | ||
setApplicationErrorReporter(AndroidComponentsErrorReportor(crashReporter)) | ||
} | ||
|
||
internal class AppServicesErrorReport( | ||
override val typeName: String, | ||
override val message: String, | ||
) : Exception(typeName), RustCrashReport | ||
|
||
private class AndroidComponentsErrorReportor( | ||
val crashReporter: CrashReporting | ||
) : ApplicationErrorReporter { | ||
override fun reportError(typeName: String, message: String) { | ||
crashReporter.submitCaughtException(AppServicesErrorReport(typeName, message)) | ||
} | ||
|
||
override fun reportBreadcrumb(message: String, module: String, line: UInt, column: UInt) { | ||
crashReporter.recordCrashBreadcrumb(Breadcrumb("$module[$line]: $message")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters