Skip to content

Commit ecc97e2

Browse files
committed
feat(event) implement ErrorOptions and CaptureOptions class
1 parent ee680d2 commit ecc97e2

File tree

12 files changed

+363
-63
lines changed

12 files changed

+363
-63
lines changed

bugsnag-android-core/api/bugsnag-android-core.api

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public final class com/bugsnag/android/Bugsnag {
8282
public static fun leaveBreadcrumb (Ljava/lang/String;Ljava/util/Map;Lcom/bugsnag/android/BreadcrumbType;)V
8383
public static fun markLaunchCompleted ()V
8484
public static fun notify (Ljava/lang/Throwable;)V
85+
public static fun notify (Ljava/lang/Throwable;Lcom/bugsnag/android/ErrorOptions;Lcom/bugsnag/android/OnErrorCallback;)V
8586
public static fun notify (Ljava/lang/Throwable;Lcom/bugsnag/android/OnErrorCallback;)V
8687
public static fun pauseSession ()V
8788
public static fun removeOnBreadcrumb (Lcom/bugsnag/android/OnBreadcrumbCallback;)V
@@ -111,6 +112,35 @@ public class com/bugsnag/android/BugsnagVmViolationListener : android/os/StrictM
111112
public fun onVmViolation (Landroid/os/strictmode/Violation;)V
112113
}
113114

115+
public final class com/bugsnag/android/CaptureOptions {
116+
public static final field CAPTURE_BREADCRUMBS I
117+
public static final field CAPTURE_FEATURE_FLAGS I
118+
public static final field CAPTURE_STACKTRACE I
119+
public static final field CAPTURE_THREADS I
120+
public static final field CAPTURE_USER I
121+
public static final field Companion Lcom/bugsnag/android/CaptureOptions$Companion;
122+
public fun <init> ()V
123+
public static final fun captureNothing ()Lcom/bugsnag/android/CaptureOptions;
124+
public static final fun captureOnly (I)Lcom/bugsnag/android/CaptureOptions;
125+
public final fun getBreadcrumbs ()Z
126+
public final fun getFeatureFlags ()Z
127+
public final fun getMetadata ()Ljava/util/Set;
128+
public final fun getStacktrace ()Z
129+
public final fun getThreads ()Z
130+
public final fun getUser ()Z
131+
public final fun setBreadcrumbs (Z)V
132+
public final fun setFeatureFlags (Z)V
133+
public final fun setMetadata (Ljava/util/Set;)V
134+
public final fun setStacktrace (Z)V
135+
public final fun setThreads (Z)V
136+
public final fun setUser (Z)V
137+
}
138+
139+
public final class com/bugsnag/android/CaptureOptions$Companion {
140+
public final fun captureNothing ()Lcom/bugsnag/android/CaptureOptions;
141+
public final fun captureOnly (I)Lcom/bugsnag/android/CaptureOptions;
142+
}
143+
114144
public class com/bugsnag/android/Client : com/bugsnag/android/CallbackAware, com/bugsnag/android/FeatureFlagAware, com/bugsnag/android/MetadataAware, com/bugsnag/android/UserAware {
115145
public fun <init> (Landroid/content/Context;)V
116146
public fun <init> (Landroid/content/Context;Lcom/bugsnag/android/Configuration;)V
@@ -139,6 +169,7 @@ public class com/bugsnag/android/Client : com/bugsnag/android/CallbackAware, com
139169
public fun leaveBreadcrumb (Ljava/lang/String;Ljava/util/Map;Lcom/bugsnag/android/BreadcrumbType;)V
140170
public fun markLaunchCompleted ()V
141171
public fun notify (Ljava/lang/Throwable;)V
172+
public fun notify (Ljava/lang/Throwable;Lcom/bugsnag/android/ErrorOptions;Lcom/bugsnag/android/OnErrorCallback;)V
142173
public fun notify (Ljava/lang/Throwable;Lcom/bugsnag/android/OnErrorCallback;)V
143174
public fun pauseSession ()V
144175
public fun removeOnBreadcrumb (Lcom/bugsnag/android/OnBreadcrumbCallback;)V
@@ -355,6 +386,14 @@ public class com/bugsnag/android/Error : com/bugsnag/android/JsonStream$Streamab
355386
public fun toStream (Lcom/bugsnag/android/JsonStream;)V
356387
}
357388

389+
public final class com/bugsnag/android/ErrorOptions {
390+
public fun <init> ()V
391+
public fun <init> (Lcom/bugsnag/android/CaptureOptions;)V
392+
public synthetic fun <init> (Lcom/bugsnag/android/CaptureOptions;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
393+
public final fun getCapture ()Lcom/bugsnag/android/CaptureOptions;
394+
public final fun setCapture (Lcom/bugsnag/android/CaptureOptions;)V
395+
}
396+
358397
public final class com/bugsnag/android/ErrorType : java/lang/Enum {
359398
public static final field ANDROID Lcom/bugsnag/android/ErrorType;
360399
public static final field C Lcom/bugsnag/android/ErrorType;

bugsnag-android-core/detekt-baseline.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<ID>LongParameterList:DeviceWithState.kt$DeviceWithState$( buildInfo: DeviceBuildInfo, jailbroken: Boolean?, id: String?, locale: String?, totalMemory: Long?, runtimeVersions: MutableMap&lt;String, Any>, /** * The number of free bytes of storage available on the device */ var freeDisk: Long?, /** * The number of free bytes of memory available on the device */ var freeMemory: Long?, /** * The orientation of the device when the event occurred: either portrait or landscape */ var orientation: String?, /** * The timestamp on the device when the event occurred */ var time: Date? )</ID>
2323
<ID>LongParameterList:EventFilenameInfo.kt$EventFilenameInfo.Companion$( obj: Any, uuid: String = UUID.randomUUID().toString(), apiKey: String?, timestamp: Long = System.currentTimeMillis(), config: ImmutableConfig, isLaunching: Boolean? = null )</ID>
2424
<ID>LongParameterList:EventInternal.kt$EventInternal$( apiKey: String, logger: Logger, breadcrumbs: MutableList&lt;Breadcrumb> = mutableListOf(), discardClasses: Set&lt;Pattern> = setOf(), errors: MutableList&lt;Error> = mutableListOf(), metadata: Metadata = Metadata(), featureFlags: FeatureFlags = FeatureFlags(), originalError: Throwable? = null, projectPackages: Collection&lt;String> = setOf(), severityReason: SeverityReason = SeverityReason.newInstance(SeverityReason.REASON_HANDLED_EXCEPTION), threads: MutableList&lt;Thread> = mutableListOf(), user: User = User(), redactionKeys: Set&lt;Pattern>? = null, isAttemptDeliveryOnCrash: Boolean = false )</ID>
25+
<ID>LongParameterList:EventInternal.kt$EventInternal$( originalError: Throwable? = null, config: ImmutableConfig, severityReason: SeverityReason, data: Metadata = Metadata(), featureFlags: FeatureFlags = FeatureFlags(), captureStacktrace: Boolean = true, captureThreads: Boolean = true, withOptions: Boolean? = null )</ID>
2526
<ID>LongParameterList:EventStorageModule.kt$EventStorageModule$( contextModule: ContextModule, configModule: ConfigModule, dataCollectionModule: DataCollectionModule, bgTaskService: BackgroundTaskService, trackerModule: TrackerModule, systemServiceModule: SystemServiceModule, notifier: Notifier, callbackState: CallbackState )</ID>
2627
<ID>LongParameterList:NativeStackframe.kt$NativeStackframe$( /** * The name of the method that was being executed */ var method: String?, /** * The location of the source file */ var file: String?, /** * The line number within the source file this stackframe refers to */ var lineNumber: Number?, /** * The address of the instruction where the event occurred. */ var frameAddress: Long?, /** * The address of the function where the event occurred. */ var symbolAddress: Long?, /** * The address of the library where the event occurred. */ var loadAddress: Long?, /** * Whether this frame identifies the program counter */ var isPC: Boolean?, /** * The type of the error */ var type: ErrorType? = null, /** * Identifies the exact build this frame originates from. */ var codeIdentifier: String? = null, )</ID>
2728
<ID>LongParameterList:StateEvent.kt$StateEvent.Install$( @JvmField val apiKey: String, @JvmField val autoDetectNdkCrashes: Boolean, @JvmField val appVersion: String?, @JvmField val buildUuid: String?, @JvmField val releaseStage: String?, @JvmField val lastRunInfoPath: String, @JvmField val consecutiveLaunchCrashes: Int, @JvmField val sendThreads: ThreadSendPolicy, @JvmField val maxBreadcrumbs: Int )</ID>
@@ -64,9 +65,9 @@
6465
<ID>MagicNumber:JsonHelper.kt$JsonHelper$8</ID>
6566
<ID>MagicNumber:JsonStream.kt$JsonStream$128</ID>
6667
<ID>MagicNumber:JsonStream.kt$JsonStream$32</ID>
67-
<ID>MagicNumber:JsonStream.kt$JsonStream.Companion$128</ID>
6868
<ID>MagicNumber:LastRunInfoStore.kt$LastRunInfoStore$3</ID>
6969
<ID>MagicNumber:SessionStore.kt$SessionStore$60</ID>
70+
<ID>MaxLineLength:ErrorTest.kt$ErrorTest$val err = Error.createError(IllegalStateException("Some err", RuntimeException("Whoops")), setOf(), NoopLogger, false)</ID>
7071
<ID>MaxLineLength:LastRunInfo.kt$LastRunInfo$return "LastRunInfo(consecutiveLaunchCrashes=$consecutiveLaunchCrashes, crashed=$crashed, crashedDuringLaunch=$crashedDuringLaunch)"</ID>
7172
<ID>MaxLineLength:ThreadState.kt$ThreadState$"[${allThreads.size - maxThreadCount} threads omitted as the maxReportedThreads limit ($maxThreadCount) was exceeded]"</ID>
7273
<ID>NestedBlockDepth:FileStore.kt$FileStore$fun deleteStoredFiles(storedFiles: Collection&lt;File>?)</ID>

bugsnag-android-core/src/main/java/com/bugsnag/android/Bugsnag.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ public static void notify(@NonNull final Throwable exception,
255255
getClient().notify(exception, onError);
256256
}
257257

258+
/**
259+
* Notify Bugsnag of a handled exception
260+
*
261+
* @param exception the exception to send to Bugsnag
262+
* @param onError callback invoked on the generated error report for
263+
* additional modification
264+
* @param options the error options
265+
*/
266+
public static void notify(@NonNull final Throwable exception,
267+
@Nullable final ErrorOptions options,
268+
@Nullable final OnErrorCallback onError) {
269+
getClient().notify(exception, options, onError);
270+
}
271+
258272
/**
259273
* Adds a map of multiple metadata key-value pairs to the specified section.
260274
*/

0 commit comments

Comments
 (0)