Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old implementation of Crashes #921

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.embrace.android.embracesdk.arch.schema.SchemaType
import io.embrace.android.embracesdk.arch.schema.TelemetryAttributes
import io.embrace.android.embracesdk.config.ConfigService
import io.embrace.android.embracesdk.internal.ApkToolsConfig
import io.embrace.android.embracesdk.internal.crash.CrashFileMarker
import io.embrace.android.embracesdk.internal.logs.LogOrchestrator
import io.embrace.android.embracesdk.internal.serialization.EmbraceSerializer
Expand Down Expand Up @@ -45,7 +46,7 @@
private val logWriter: LogWriter,
private val configService: ConfigService,
private val serializer: EmbraceSerializer,
logger: EmbLogger,
private val logger: EmbLogger,
) : CrashDataSource,
LogDataSourceImpl(
destination = logWriter,
Expand All @@ -56,6 +57,14 @@
private var mainCrashHandled = false
private var jsException: JsException? = null

init {
if (configService.autoDataCaptureBehavior.isUncaughtExceptionHandlerEnabled() &&
!ApkToolsConfig.IS_EXCEPTION_CAPTURE_DISABLED

Check warning on line 62 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/capture/crash/CrashDataSourceImpl.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/capture/crash/CrashDataSourceImpl.kt#L62

Added line #L62 was not covered by tests
) {
registerExceptionHandler()
}
}

/**
* Handles a crash caught by the [EmbraceUncaughtExceptionHandler] by constructing a
* JSON message containing a description of the crash, device, and context, and then sending
Expand Down Expand Up @@ -171,4 +180,14 @@
private fun encodeToUTF8String(source: String): String {
return source.toByteArray().toUTF8String()
}

/**
* Registers the Embrace [java.lang.Thread.UncaughtExceptionHandler] to intercept uncaught
* exceptions and forward them to the Embrace API as crashes.
*/
private fun registerExceptionHandler() {
val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
val embraceHandler = EmbraceUncaughtExceptionHandler(defaultHandler, this, logger)
Thread.setDefaultUncaughtExceptionHandler(embraceHandler)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.embrace.android.embracesdk.injection

import io.embrace.android.embracesdk.capture.crash.CompositeCrashService
import io.embrace.android.embracesdk.capture.crash.CrashDataSource
import io.embrace.android.embracesdk.capture.crash.CrashDataSourceImpl
import io.embrace.android.embracesdk.capture.crash.CrashService
import io.embrace.android.embracesdk.capture.crash.EmbraceCrashService
import io.embrace.android.embracesdk.internal.crash.CrashFileMarker
import io.embrace.android.embracesdk.internal.crash.CrashFileMarkerImpl
import io.embrace.android.embracesdk.internal.crash.LastRunCrashVerifier
Expand All @@ -28,11 +25,9 @@ internal class CrashModuleImpl(
initModule: InitModule,
storageModule: StorageModule,
essentialServiceModule: EssentialServiceModule,
deliveryModule: DeliveryModule,
nativeModule: NativeModule,
sessionModule: SessionModule,
anrModule: AnrModule,
dataContainerModule: DataContainerModule,
androidServicesModule: AndroidServicesModule,
logModule: CustomerLogModule
) : CrashModule {
Expand All @@ -44,27 +39,7 @@ internal class CrashModuleImpl(
CrashFileMarkerImpl(markerFile, initModule.logger)
}

private val legacyCrashService: CrashService by singleton {
EmbraceCrashService(
logModule.logOrchestrator,
sessionModule.sessionOrchestrator,
sessionModule.sessionPropertiesService,
essentialServiceModule.metadataService,
essentialServiceModule.sessionIdTracker,
deliveryModule.deliveryService,
essentialServiceModule.userService,
dataContainerModule.eventService,
anrModule.anrService,
nativeModule.ndkService,
essentialServiceModule.gatingService,
androidServicesModule.preferencesService,
crashMarker,
initModule.clock,
initModule.logger
)
}

private val crashDataSource: CrashDataSource by singleton {
override val crashService: CrashService by singleton {
CrashDataSourceImpl(
logModule.logOrchestrator,
sessionModule.sessionOrchestrator,
Expand All @@ -80,15 +55,6 @@ internal class CrashModuleImpl(
)
}

override val crashService: CrashService by singleton {
CompositeCrashService(
{ legacyCrashService },
{ crashDataSource },
essentialServiceModule.configService,
initModule.logger
)
}

override val lastRunCrashVerifier: LastRunCrashVerifier by singleton {
LastRunCrashVerifier(crashMarker, initModule.logger)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,9 @@ internal class ModuleInitBootstrapper(
initModule,
storageModule,
essentialServiceModule,
deliveryModule,
nativeModule,
sessionModule,
anrModule,
dataContainerModule,
androidServicesModule,
customerLogModule,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,9 @@ internal typealias CrashModuleSupplier = (
initModule: InitModule,
storageModule: StorageModule,
essentialServiceModule: EssentialServiceModule,
deliveryModule: DeliveryModule,
nativeModule: NativeModule,
sessionModule: SessionModule,
anrModule: AnrModule,
dataContainerModule: DataContainerModule,
androidServicesModule: AndroidServicesModule,
logModule: CustomerLogModule,
) -> CrashModule
Expand Down
Loading