-
- All Implemented Interfaces:
-
com.bugsnag.android.FeatureFlagAware,com.bugsnag.android.JsonStream.Streamable,com.bugsnag.android.MetadataAware,com.bugsnag.android.UserAware
public class Event implements JsonStream.Streamable, MetadataAware, UserAware, FeatureFlagAware
An Event object represents a Throwable captured by Bugsnag and is available as a parameter on an OnErrorCallback, where individual properties can be mutated before an error report is sent to Bugsnag's API.
-
-
Method Summary
Modifier and Type Method Description ThrowablegetOriginalError()The Throwable object that caused the event in your application. List<Error>getErrors()Information extracted from the Throwable that caused the event can be found in thisfield. ErroraddError(@NonNull() Throwable error)Add a new error to this event and return its Error data. ErroraddError(@NonNull() String errorClass, @Nullable() String errorMessage)Add a new empty android error to this event and return its Errordata. ErroraddError(@NonNull() String errorClass, @Nullable() String errorMessage, @NonNull() ErrorType errorType)Add a new empty error to this event and return its Error data. List<Thread>getThreads()If thread state is being captured along with the event, this field will contain alist of Thread objects. ThreadaddThread(@NonNull() String id, @NonNull() String name)Create, add and return a new empty Thread object to this event with a given idand name. ThreadaddThread(long id, @NonNull() String name)Create, add and return a new empty Thread object to this event with a given idand name. voidsetErrorReportingThread(@NonNull() Thread thread)Sets the thread that caused the event. voidsetErrorReportingThread(long threadId)Sets the thread that caused the event by its id. List<Breadcrumb>getBreadcrumbs()A list of breadcrumbs leading up to the event. BreadcrumbleaveBreadcrumb(@NonNull() String message, @NonNull() BreadcrumbType type, @Nullable() Map<String, Object> metadata)Add a new breadcrumb to this event and return its Breadcrumb object. BreadcrumbleaveBreadcrumb(@NonNull() String message)Add a new breadcrumb to this event and return its Breadcrumb object. List<FeatureFlag>getFeatureFlags()A list of feature flags active at the time of the event. AppWithStategetApp()Information set by the notifier about your app can be found in this field. DeviceWithStategetDevice()Information set by the notifier about your device can be found in this field. voidsetApiKey(@NonNull() String apiKey)The API key used for events sent to Bugsnag. StringgetApiKey()The API key used for events sent to Bugsnag. voidsetSeverity(@NonNull() Severity severity)The severity of the event. SeveritygetSeverity()The severity of the event. voidsetGroupingHash(@Nullable() String groupingHash)Set the grouping hash of the event to override the default grouping on the dashboard.All events with the same grouping hash will be grouped together into one error. StringgetGroupingHash()Set the grouping hash of the event to override the default grouping on the dashboard.All events with the same grouping hash will be grouped together into one error. voidsetContext(@Nullable() String context)Sets the context of the error. StringgetContext()Returns the context of the error. StringsetGroupingDiscriminator(@Nullable() String groupingDiscriminator)Set the Grouping Discriminator for this {@code Event}and return its previous value (if any was set).StringgetGroupingDiscriminator()voidsetUser(@Nullable() String id, @Nullable() String email, @Nullable() String name)Sets the user associated with the event. UsergetUser()Returns the currently set User information. voidaddMetadata(@NonNull() String section, @NonNull() Map<String, out Object> value)Adds a map of multiple metadata key-value pairs to the specified section. voidaddMetadata(@NonNull() String section, @NonNull() String key, @Nullable() Object value)Adds the specified key and value in the specified section. voidclearMetadata(@NonNull() String section)Removes all the data from the specified section. voidclearMetadata(@NonNull() String section, @NonNull() String key)Removes data with the specified key from the specified section. Map<String, Object>getMetadata(@NonNull() String section)Returns a map of data in the specified section. ObjectgetMetadata(@NonNull() String section, @NonNull() String key)Returns the value of the specified key in the specified section. voidaddFeatureFlag(@NonNull() String name)voidaddFeatureFlag(@NonNull() String name, @Nullable() String variant)voidaddFeatureFlags(@NonNull() Iterable<FeatureFlag> featureFlags)voidclearFeatureFlag(@NonNull() String name)voidclearFeatureFlags()voidtoStream(@NonNull() JsonStream stream)booleanisUnhandled()Whether the event was a crash (i.e. voidsetUnhandled(boolean unhandled)Whether the event was a crash (i.e. voidsetTraceCorrelation(@NonNull() UUID traceId, long spanId)Associate this event with a specific trace. DeliveryStrategygetDeliveryStrategy()Returns the delivery strategy for this event, which determines how the eventshould be delivered to the Bugsnag API. voidsetDeliveryStrategy(@NonNull() DeliveryStrategy deliveryStrategy)Sets the delivery strategy for this event, which determines how the eventshould be delivered to the Bugsnag API. RequestgetRequest()Returns the HTTP request associated with this event, if any. voidsetRequest(@Nullable() Request request)Associates an HTTP request with this event. ResponsegetResponse()Returns the HTTP response associated with this event, if any. voidsetResponse(@Nullable() Response response)Associates an HTTP response with this event. -
Methods inherited from class com.bugsnag.android.JsonStream.Streamable
toStream -
Methods inherited from class com.bugsnag.android.MetadataAware
addMetadata, clearMetadata, getMetadata -
Methods inherited from class com.bugsnag.android.UserAware
getUser, setUser -
Methods inherited from class com.bugsnag.android.FeatureFlagAware
addFeatureFlag, addFeatureFlags, clearFeatureFlag, clearFeatureFlags -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getOriginalError
@Nullable() Throwable getOriginalError()
-
getErrors
@NonNull() List<Error> getErrors()
Information extracted from the Throwable that caused the event can be found in thisfield. The list contains at least one Error that represents the thrown objectwith subsequent elements in the list populated from getCause.
A reference to the actual Throwable object that caused the event is availablethrough getOriginalError ()}.
-
addError
@NonNull() Error addError(@NonNull() Throwable error)
Add a new error to this event and return its Error data. The new Error will appear at theend of the errors list.
-
addError
@NonNull() Error addError(@NonNull() String errorClass, @Nullable() String errorMessage)
Add a new empty android error to this event and return its Errordata. The new Error will appear at the end of the errors list.
-
addError
@NonNull() Error addError(@NonNull() String errorClass, @Nullable() String errorMessage, @NonNull() ErrorType errorType)
Add a new empty error to this event and return its Error data. The new Error will appearat the end of the errors list.
-
getThreads
@NonNull() List<Thread> getThreads()
If thread state is being captured along with the event, this field will contain alist of Thread objects.
-
addThread
@NonNull() Thread addThread(@NonNull() String id, @NonNull() String name)
Create, add and return a new empty Thread object to this event with a given idand name. This can be used to augment the event with thread data that would not be pickedup as part of a normal event being generated (for example: native threads managedby cross-platform toolkits).
-
addThread
@NonNull() Thread addThread(long id, @NonNull() String name)
Create, add and return a new empty Thread object to this event with a given idand name. This can be used to augment the event with thread data that would not be pickedup as part of a normal event being generated (for example: native threads managedby cross-platform toolkits).
-
setErrorReportingThread
void setErrorReportingThread(@NonNull() Thread thread)
Sets the thread that caused the event. This should be one of the threads in getThreads. If the thread is not already in the list this method has no effect.
- Parameters:
thread- the thread that caused the event
-
setErrorReportingThread
void setErrorReportingThread(long threadId)
Sets the thread that caused the event by its id. This should be one of the threads in getThreads. If the id does not match any threads in the list this method hasno effect.
- Parameters:
threadId- the id of the thread that caused the event
-
getBreadcrumbs
@NonNull() List<Breadcrumb> getBreadcrumbs()
A list of breadcrumbs leading up to the event. These values can be accessed and amendedif necessary. See Breadcrumb for details of the data available.
-
leaveBreadcrumb
@NonNull() Breadcrumb leaveBreadcrumb(@NonNull() String message, @NonNull() BreadcrumbType type, @Nullable() Map<String, Object> metadata)
Add a new breadcrumb to this event and return its Breadcrumb object. The new breadcrumbwill be added to the end of the breadcrumbs list by this method.
-
leaveBreadcrumb
@NonNull() Breadcrumb leaveBreadcrumb(@NonNull() String message)
Add a new breadcrumb to this event and return its Breadcrumb object. The new breadcrumbwill be added to the end of the breadcrumbs list by this# method.
-
getFeatureFlags
@NonNull() List<FeatureFlag> getFeatureFlags()
A list of feature flags active at the time of the event.See FeatureFlag for details of the data available.
-
getApp
@NonNull() AppWithState getApp()
Information set by the notifier about your app can be found in this field. These valuescan be accessed and amended if necessary.
-
getDevice
@NonNull() DeviceWithState getDevice()
Information set by the notifier about your device can be found in this field. These valuescan be accessed and amended if necessary.
-
setApiKey
void setApiKey(@NonNull() String apiKey)
The API key used for events sent to Bugsnag. Even though the API key is set when Bugsnagis initialized, you may choose to send certain events to a different Bugsnag project.
-
getApiKey
@NonNull() String getApiKey()
The API key used for events sent to Bugsnag. Even though the API key is set when Bugsnagis initialized, you may choose to send certain events to a different Bugsnag project.
-
setSeverity
void setSeverity(@NonNull() Severity severity)
The severity of the event. By default, unhandled exceptions will be ERROR and handled exceptions sent with notifyWARNING.
-
getSeverity
@NonNull() Severity getSeverity()
The severity of the event. By default, unhandled exceptions will be ERROR and handled exceptions sent with notifyWARNING.
-
setGroupingHash
void setGroupingHash(@Nullable() String groupingHash)
Set the grouping hash of the event to override the default grouping on the dashboard.All events with the same grouping hash will be grouped together into one error. This is anadvanced usage of the library and mis-using it will cause your events not to group properlyin your dashboard.
As the name implies, this option accepts a hash of sorts.
-
getGroupingHash
@Nullable() String getGroupingHash()
Set the grouping hash of the event to override the default grouping on the dashboard.All events with the same grouping hash will be grouped together into one error. This is anadvanced usage of the library and mis-using it will cause your events not to group properlyin your dashboard.
As the name implies, this option accepts a hash of sorts.
-
setContext
void setContext(@Nullable() String context)
Sets the context of the error. The context is a summary what what was occurring in theapplication at the time of the crash, if available, such as the visible activity.
-
getContext
@Nullable() String getContext()
Returns the context of the error. The context is a summary what what was occurring in theapplication at the time of the crash, if available, such as the visible activity.
-
setGroupingDiscriminator
@Nullable() String setGroupingDiscriminator(@Nullable() String groupingDiscriminator)
Set the Grouping Discriminator for this
{@code Event}and return its previous value (if any was set).- Parameters:
groupingDiscriminator- the new grouping discriminator or null to clear it
-
getGroupingDiscriminator
@Nullable() String getGroupingDiscriminator()
-
setUser
void setUser(@Nullable() String id, @Nullable() String email, @Nullable() String name)
Sets the user associated with the event.
-
addMetadata
void addMetadata(@NonNull() String section, @NonNull() Map<String, out Object> value)
Adds a map of multiple metadata key-value pairs to the specified section.
-
addMetadata
void addMetadata(@NonNull() String section, @NonNull() String key, @Nullable() Object value)
Adds the specified key and value in the specified section. The value can be ofany primitive type or a collection such as a map, set or array.
-
clearMetadata
void clearMetadata(@NonNull() String section)
Removes all the data from the specified section.
-
clearMetadata
void clearMetadata(@NonNull() String section, @NonNull() String key)
Removes data with the specified key from the specified section.
-
getMetadata
@Nullable() Map<String, Object> getMetadata(@NonNull() String section)
Returns a map of data in the specified section.
-
getMetadata
@Nullable() Object getMetadata(@NonNull() String section, @NonNull() String key)
Returns the value of the specified key in the specified section.
-
addFeatureFlag
void addFeatureFlag(@NonNull() String name)
-
addFeatureFlag
void addFeatureFlag(@NonNull() String name, @Nullable() String variant)
-
addFeatureFlags
void addFeatureFlags(@NonNull() Iterable<FeatureFlag> featureFlags)
-
clearFeatureFlag
void clearFeatureFlag(@NonNull() String name)
-
clearFeatureFlags
void clearFeatureFlags()
-
toStream
void toStream(@NonNull() JsonStream stream)
-
isUnhandled
boolean isUnhandled()
Whether the event was a crash (i.e. unhandled) or handled error in which the systemcontinued running.Unhandled errors count towards your stability score. If you don't want certain errorsto count towards your stability score, you can alter this property through an OnErrorCallback.
-
setUnhandled
void setUnhandled(boolean unhandled)
Whether the event was a crash (i.e. unhandled) or handled error in which the systemcontinued running.Unhandled errors count towards your stability score. If you don't want certain errorsto count towards your stability score, you can alter this property through an OnErrorCallback.
-
setTraceCorrelation
void setTraceCorrelation(@NonNull() UUID traceId, long spanId)
Associate this event with a specific trace. This is usually done automatically whenusing bugsnag-android-performance, but can also be set manually if required.
- Parameters:
traceId- the ID of the trace the event occurred withinspanId- the ID of the span that the event occurred within
-
getDeliveryStrategy
@NonNull() DeliveryStrategy getDeliveryStrategy()
Returns the delivery strategy for this event, which determines how the eventshould be delivered to the Bugsnag API.
-
setDeliveryStrategy
void setDeliveryStrategy(@NonNull() DeliveryStrategy deliveryStrategy)
Sets the delivery strategy for this event, which determines how the eventshould be delivered to the Bugsnag API. This allows customization of deliverybehavior on a per-event basis.
- Parameters:
deliveryStrategy- the delivery strategy to use for this event
-
getRequest
@Nullable() Request getRequest()
Returns the HTTP request associated with this event, if any. This representsthe HTTP request that was being processed when the event occurred.The request object contains information such as the HTTP method, URL, headers,and query parameters. This can be useful for understanding the context of errorsthat occur during HTTP request handling.
-
setRequest
void setRequest(@Nullable() Request request)
Associates an HTTP request with this event. This should represent the HTTP requestthat was being processed when the event occurred.Setting request information can help with debugging by providing context aboutthe HTTP request that led to the error. Set this to null to clear any previouslyassociated request.
- Parameters:
request- the HTTP request to associate with this event, or null to clear it
-
getResponse
@Nullable() Response getResponse()
Returns the HTTP response associated with this event, if any. This representsthe HTTP response that was being generated when the event occurred.The response object contains information such as the HTTP status code, headers,and body length. This can be useful for understanding the context of errorsthat occur during HTTP response generation.
-
setResponse
void setResponse(@Nullable() Response response)
Associates an HTTP response with this event. This should represent the HTTP responsethat was being generated when the event occurred.Setting response information can help with debugging by providing context aboutthe HTTP response generation that led to the error. Set this to null to clear anypreviously associated response.
- Parameters:
response- the HTTP response to associate with this event, or null to clear it
-
-
-
-