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.

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.

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.

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.

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.)

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.

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