Skip to content

Commit

Permalink
Remove old implementation of Crashes (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
priettt committed Jun 11, 2024
1 parent 0cb0869 commit 9d45b65
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 568 deletions.

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.EmbType.System.ReactNativeCrash
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 @@ internal class CrashDataSourceImpl(
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 @@ internal class CrashDataSourceImpl(
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 @@ internal class CrashDataSourceImpl(
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

0 comments on commit 9d45b65

Please sign in to comment.