Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ internal data class TracingErrorFields(
val breadcrumbs: String,
)

@Serializable
internal data class TracingBreadcrumbFields(
val module: String,
val line: UInt,
val column: UInt,
)

private class ErrorEventSink : EventSink {
val json = Json { ignoreUnknownKeys = true }

Expand All @@ -74,54 +67,6 @@ private class ErrorEventSink : EventSink {
RustComponentErrors.details.set(event.message)
RustComponentErrors.breadcrumbs.set(fields.breadcrumbs.split("\n"))
Pings.rustComponentErrors.submit()

ApplicationErrorReporterRegistry.errorReporter?.reportError(fields.typeName, event.message)
} else if (event.target == "app-services-error-reporter::breadcrumb") {
val fields = json.decodeFromString<TracingBreadcrumbFields>(event.fields)

ApplicationErrorReporterRegistry.errorReporter?.reportBreadcrumb(
event.message,
fields.module,
fields.line,
fields.column,
)
}
}
}

/**
* Report Rust errors to Sentry (supplied by the application
*
* This represents the legacy error reporting interface. We're keeping this around for now so that
* Android can send errors to Sentry. At some point we should migrate Android to only use
* Glean-based error reporting.
*/
public interface ApplicationErrorReporter {
/**
* Report an error
*/
fun reportError(typeName: String, message: String)

/**
* Report a breadbcrumb
*/
fun reportBreadcrumb(message: String, module: String, line: UInt, column: UInt)
}

/**
* Set the global ApplicationErrorReporter
*/
public fun setApplicationErrorReporter(errorReporter: ApplicationErrorReporter) {
ApplicationErrorReporterRegistry.errorReporter = errorReporter
}

/**
* Unset the global ApplicationErrorReporter
*/
public fun unsetApplicationErrorReporter() {
ApplicationErrorReporterRegistry.errorReporter = null
}

internal object ApplicationErrorReporterRegistry {
var errorReporter: ApplicationErrorReporter? = null
}