Class BacktraceBase

java.lang.Object
backtraceio.library.base.BacktraceBase
All Implemented Interfaces:
Client
Direct Known Subclasses:
BacktraceClient

public class BacktraceBase extends Object implements Client
Base Backtrace Android client
  • Field Details

    • database

      public final Database database
      Backtrace database instance
    • version

      public static String version
      Backtrace client version
    • attributes

      public final Map<String,Object> attributes
      Get custom client attributes. Every argument stored in dictionary will be send to Backtrace API
    • attachments

      public final List<String> attachments
      File attachments to attach to crashes and reports.
    • metrics

      public Metrics metrics
      Backtrace metrics instance
    • context

      protected android.content.Context context
      Application context
  • Constructor Details

    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      attachments - File attachment paths to consider for reports
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Map<String,Object> attributes)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      attributes - additional information about current application
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Map<String,Object> attributes, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      attributes - additional information about current application
      attachments - File attachment paths to consider for reports
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, BacktraceDatabaseSettings databaseSettings)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      databaseSettings - Backtrace database settings
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, BacktraceDatabaseSettings databaseSettings, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      databaseSettings - Backtrace database settings
      attachments - File attachment paths to consider for reports
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, BacktraceDatabaseSettings databaseSettings, Map<String,Object> attributes)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      databaseSettings - Backtrace database settings
      attributes - additional information about current application
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, BacktraceDatabaseSettings databaseSettings, Map<String,Object> attributes, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      databaseSettings - Backtrace database settings
      attributes - additional information about current application
      attachments - File attachment paths to consider for reports
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Database database)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      database - Backtrace database
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Database database, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      database - Backtrace database
      attachments - File attachment paths to consider for reports
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Database database, Map<String,Object> attributes)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      database - Backtrace database
      attributes - additional information about current application
    • BacktraceBase

      public BacktraceBase(android.content.Context context, BacktraceCredentials credentials, Database database, Map<String,Object> attributes, List<String> attachments)
      Initialize new client instance with BacktraceCredentials
      Parameters:
      context - context of current state of the application
      credentials - Backtrace credentials to access Backtrace API
      database - Backtrace database
      attributes - additional information about current application
      attachments - File attachment paths to consider for reports
  • Method Details

    • crash

      public void crash()
    • enableNativeIntegration

      public void enableNativeIntegration()
      Capture unhandled native exceptions (Backtrace database integration is required to enable this feature).
      Specified by:
      enableNativeIntegration in interface Client
    • enableNativeIntegration

      public void enableNativeIntegration(boolean enableClientSideUnwinding)
      Capture unhandled native exceptions (Backtrace database integration is required to enable this feature).
      Parameters:
      enableClientSideUnwinding - Enable client side unwinding
    • enableNativeIntegration

      public void enableNativeIntegration(boolean enableClientSideUnwinding, UnwindingMode unwindingMode)
      Capture unhandled native exceptions (Backtrace database integration is required to enable this feature).
      Parameters:
      enableClientSideUnwinding - Enable client side unwinding
      unwindingMode - Unwinding mode to use for client side unwinding
    • disableNativeIntegration

      public void disableNativeIntegration()
    • enableProguard

      public void enableProguard()
      Inform Backtrace API that we are using Proguard symbolication
    • getAttributes

      public Map<String,Object> getAttributes()
      Get custom attributes
      Returns:
      map with custom attributes
    • addAttribute

      public void addAttribute(String key, Object value)
      Adds a new attribute to Backtrace Client. If the native integration is enabled, adds the attribute to the native report attributes if: - the value exists (is not a null) - is not an object (the attribute value is primitive type like String, or Int)
      Specified by:
      addAttribute in interface Client
      Parameters:
      key - attribute name
      value - attribute value.
    • addAttribute

      public void addAttribute(Map<String,Object> attributes)
      Adds new attributes to Backtrace Client. If the native integration is enabled, adds attributes to the native report attributes if: - the value exists (is not a null) - is not an object (the attribute value is primitive type like String, or Int)
      Specified by:
      addAttribute in interface Client
      Parameters:
      attributes - Map of attributes
    • setOnBeforeSendEventListener

      public void setOnBeforeSendEventListener(OnBeforeSendEventListener eventListener)
      Set event executed before sending data to Backtrace API
      Parameters:
      eventListener - object with method which will be executed
    • setOnServerErrorEventListener

      public void setOnServerErrorEventListener(OnServerErrorEventListener eventListener)
      Set an event executed when received bad request, unauthorize request or other information from server
      Parameters:
      eventListener - object with method which will be executed
    • setOnRequestHandler

      public void setOnRequestHandler(RequestHandler requestHandler)
      Custom request handler for sending Backtrace reports to server
      Parameters:
      requestHandler - object with method which will be executed
    • enableBreadcrumbs

      public boolean enableBreadcrumbs(android.content.Context context)
      Enable logging of breadcrumbs and submission with crash reports
      Parameters:
      context - context of current state of the application
      Returns:
      true if we successfully enabled breadcrumbs
    • enableBreadcrumbs

      public boolean enableBreadcrumbs(android.content.Context context, int maxBreadcrumbLogSizeBytes)
      Enable logging of breadcrumbs and submission with crash reports
      Parameters:
      context - context of current state of the application
      maxBreadcrumbLogSizeBytes - breadcrumb log size limit in bytes, should be a power of 2
      Returns:
      true if we successfully enabled breadcrumbs
    • enableBreadcrumbs

      public boolean enableBreadcrumbs(android.content.Context context, EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable)
      Enable logging of breadcrumbs and submission with crash reports
      Parameters:
      context - context of current state of the application
      breadcrumbTypesToEnable - a set containing which breadcrumb types to enable
      Returns:
      true if we successfully enabled breadcrumbs
    • enableBreadcrumbs

      public boolean enableBreadcrumbs(android.content.Context context, EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable, int maxBreadcrumbLogSizeBytes)
      Enable logging of breadcrumbs and submission with crash reports
      Parameters:
      context - context of current state of the application
      breadcrumbTypesToEnable - a set containing which breadcrumb types to enable
      maxBreadcrumbLogSizeBytes - breadcrumb log size limit in bytes, should be a power of 2
      Returns:
      true if we successfully enabled breadcrumbs
    • clearBreadcrumbs

      public boolean clearBreadcrumbs()
      Clear breadcrumb logs
    • addBreadcrumb

      public boolean addBreadcrumb(String message)
      Add a breadcrumb of type "Manual" and level "Info" with the provided message string
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, BacktraceBreadcrumbLevel level)
      Add a breadcrumb of type "Manual" and the desired level with the provided message string
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      level - the severity level of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, Map<String,Object> attributes)
      Add a breadcrumb of type "Manual" and level "Info" with the provided message string and attributes
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      attributes - key-value pairs to provide additional information about this breadcrumb (1KB max, including some overhead per key-value pair)
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, Map<String,Object> attributes, BacktraceBreadcrumbLevel level)
      Add a breadcrumb of type "Manual" and the desired level with the provided message string and attributes
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      attributes - key-value pairs to provide additional information about this breadcrumb (1KB max, including some overhead per key-value pair)
      level - the severity level of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, BacktraceBreadcrumbType type)
      Add a breadcrumb of the desired type and level "Info" with the provided message string
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      type - broadly describes the category of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)
      Add a breadcrumb of the desired level and type with the provided message string
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      type - broadly describes the category of this breadcrumb
      level - the severity level of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, Map<String,Object> attributes, BacktraceBreadcrumbType type)
      Add a breadcrumb of the desired type and level "Info" with the provided message string and attributes
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      attributes - key-value pairs to provide additional information about this breadcrumb (1KB max, including some overhead per key-value pair)
      type - broadly describes the category of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • addBreadcrumb

      public boolean addBreadcrumb(String message, Map<String,Object> attributes, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)
      Add a breadcrumb of the desired level and type with the provided message string and attributes
      Parameters:
      message - a message which describes this breadcrumb (1KB max)
      attributes - key-value pairs to provide additional information about this breadcrumb (1KB max, including some overhead per key-value pair)
      type - broadly describes the category of this breadcrumb
      level - the severity level of this breadcrumb
      Returns:
      true if the breadcrumb was successfully added
    • nativeCrash

      public void nativeCrash()
    • dumpWithoutCrash

      public void dumpWithoutCrash(String message)
      Force a native crash report and minidump submission
      Parameters:
      message -
    • dumpWithoutCrash

      public void dumpWithoutCrash(String message, boolean setMainThreadAsFaultingThread)
    • send

      public void send(BacktraceReport report)
      Sending an exception to Backtrace API
      Specified by:
      send in interface Client
      Parameters:
      report - current BacktraceReport
    • send

      public void send(BacktraceReport report, OnServerResponseEventListener callback)
      Sending an exception to Backtrace API
      Parameters:
      report - current BacktraceReport