Setting Crash SDK

IMQA Crash offers various options and enables the user to add custom settings for generating more detailed crash reports.

1. Custom crash occurrence

IMQA Crash Agent can collect the following user-defined errors. You can specify a specific tag and error rank together with the Exception object.

 try {
  ...
} catch (SomeException e) {
  IMQACrashAgent.SendException(e, "ERROR TAG", ErrorRank.Major);
}

There are no specific rules for error ranks. Error ranks can be changed according to the app configuration.

RankDescription

ErrorRank.Unhandle

The default error rank used for an unhandled exception.

ErrorRank.Critical

A crash that affects the app significantly.

ErrorRank.Major

A crash that affects the app.

ErrorRank.Minor

A crash that does not affect the app significantly.

2. Custom Web Crash

IMQA WebAgent lets you collect custom errors by specifying the desired error messages for detailed web error analytics.

To collect Webview Crash, you must add CrashWebviewBridge. Please refer to ‘Android > Setting MPM SDK > WebView HTTP Request > Android Agent Setup’.

Create Custom Errors

IMQA WCrash detects and collects user-defined errors.

Different errors but of the same error type are recognized as the same error, which can lead to error accumulation.

Custom Error Messages

You can change the default error messages to any error messages you want and collect them by WebAgent. We recommend specifying several error messages for detailed web error analytics.

If you specify error messages, even errors of the same type will be collected as different errors.

JS files to collect custom errors
...
// When using try-catch
try {
	...
}
catch(e){
	throw new Error("Custom error messages");
}

// When to generate default errors
new Error("Custom error messages");

You can view web crashes with detailed information in the IMQA WCrash service as shown below.

❶ Caught Error Instance Type Displays the name of the caught error instance of the error if it is generated on a web page.

❷ Custom Error Message Displays a user-specified message when a specific error-type error is generated.

throw new Error("Custom error messages");

❸ Error-type / Code line number You can check the type of webview error and the line number of the error.

Error-typeDescription

Error

This is the error type set by the user.

EvalError

This error occurs in eval().

RangeError

This error is generated when a variable is outside its valid range.

ReferenceError

This error occurs when an incorrect reference is made.

SyntaxError

It is an error if incorrect syntax exists.

TypeError

If it is not a valid data type, it is a type error.

URIError

This error is generated when inappropriate parameters are passed to the encodeURI() or decodeURI() functions.

AggregateError

This is a type of error that wraps multiple errors into one error.

3. Registering EventPath

EventPath is a function used to check the path of the app launch in the user’s device. The EventPath tracking code should be inserted into the class to use this function. Enter the following details as shown under “STEP” and “LABEL” into the tracking code.

STEPLABEL

Get the level of the call stack to collect, and the class name, function name, and call location of that level.

Alias of the collected EventPath. Shows each occurrence location of EventPath as an alias on the crash information window.

public void onClickSomething() {
      EventPathManager.CreateEventPath(STEP, LABEL);
  }

4. Registering a custom user ID

You can assign a custom ID to identify a user when a crash occurs. If user information is registered, the user information will also be displayed in crash occurrence information.

Class NameMethod NameDescription

IdentifierCollector

setUserId(STRING)

Register a user ID.

IdentifierCollector

setUserName(STRING)

Register a user name.

IdentifierCollector

setUserMail(STRING)

Register a user email.

IdentifierCollector.setUserId("10"); // Register a user ID.
IdentifierCollector.setUserName("My User Name"); // Register a user name.
IdentifierCollector.setUserMail("My User Email"); // Register a user email.

5. Registering a custom user log/key

The developer can manually leave additional logs before a crash occurs (up to 100 logs.)

Class NameMethod NameDescription

CustomLogCollector

log(STRING)

Leaves the log as a plain string.

CustomLogCollector

log(KEY, VALUE)

Leaves the log in the form of key:value.

CustomLogCollector.log("test log"); // Leaves the log as a plain string.
CustomKeyCollector.log("My Key", "My Log"); // Leaves the log in the form of key:value.

6. Adding initialization options

You can specify options when initializing IMQAController. You can change the IMQA Crash mode using parameters or options.

Class NameMethod NameDescription

IMQAOption

setDirectUploadFlag(BOOL)

Sets upload mode. If set to false, it will also work in debug mode.

IMQAOption

setPrintLog(BOOL)

Sets whether to output the log. If set to true, IMQA logs are output.

IMQAOption

setAnrOn(BOOL)

Sets whether to monitor ANR. If set to false, ANR will be excluded from crash collection.

IMQAOption

setAnrTimeoutIntercal(int)

Sets the time when ANR timeout occurs (in milliseconds.)

MyApplication.java
@Override
public void onCreate() {
    super.onCreate();
      
    io.imqa.core.IMQAOption imqaOption = new io.imqa.core.IMQAOption();

    /*  
     * Default value: true
     * Sets whether to collect ANR information. 
     * true: Monitors the ANR occurrence status.
     * false: Stops monitoring ANR occurrence.
    */
    imqaOption.setAnrOn(false);


    /*
     * Default value : 5000
     * anrTimeoutInveral : Sets the time when ANR timeout occurs (in milliseconds.)
     */
    imqaOption.setAnrTimeoutInterval(5000);


   /*
     * Default value : false
     * Sets whether to output the log. 
     * true: Outputs the IMQA Crash log.
    */
    imqaOption.setPrintCrashLog(true);

    /*
     * Default value : true
     * Uploads collected crash information as soon as the crash occurs.
     * true: Uploads as soon as the crash occurs.
     * false: Uploads when executing again after saving.
    */
    imqaOption.setCrashDirectUploadFlag(false);

    /*
     * Default value : false
     * Set the compression algorithm.
     * true : Using Zstandard (Zstd).
     * false : Using gzip algorithm
    */
    imqaOption.setCompressZstd(true);

    /*
     * Default value : 'https://collector.imqa.io'
     * Sets the crash server URL.
     * String: Server information
     */
    imqaOption.setCrashServerUrl('https://collector.imqa.io');

    io.imqa.crash.IMQACrashAgent.InitializeAndStartSession(
        this, // Application Context
        BuildConfig.FLAVOR, // Project Flavor Setting
        "PROJECT_KEY",  // Issued project key
        imqaOption // Add an object when the option is set.
    );
}

Last updated