Package 

Class Event

  • 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 Detail

      • getOriginalError

        @Nullable() Throwable getOriginalError()

        The Throwable object that caused the event in your application.

        Manipulating this field does not affect the error information reported to theBugsnag dashboard. Use getErrors to access and amend the representation ofthe error that will be sent.

      • 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 ()}.

      • 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
      • 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
      • 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 within
        spanId - the ID of the span that the event occurred within
      • 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