Skip to content

AppAmbit Crashes Flutter

AppAmbit Crashes automatically records a crash log whenever your application crashes. Initially, the log is saved to the device’s local storage. Once the app is reopened, the crash report is sent to AppAmbit, offering valuable insights to help diagnose and fix issues.

Generate a Test Crash

To simplify SDK testing, AppAmbit Crashes provides an API for generating a test crash.

Dart

AppambitSdk.generateTestCrash()

Handled Errors

AppAmbit also supports tracking non-fatal errors by logging handled exceptions:

Dart

try {
    throw Exception('Test');
} catch (e, st) {
    await AppambitSdk.logError(
    exception: e,
    stackTrace: st,
    );
}

Besides, an application can attach properties to a controlled error report to provide more context. Pass the properties as a map of key-value pairs (strings only) as shown in the following example.

Dart

try {
    throw Exception('Test with Properties');
} catch (e, st) {
    await AppambitSdk.logError(
    exception: e,
    stackTrace: st,
    properties: <String, String>{'user_id': '1'}
    );
}

Additionally, you can log custom error messages for better visibility during unexpected situations:

Dart

try {
    ...
} catch (e, st) {
    final msg = "Error Exception";
    await AppambitSdk.logError(message: msg);
}

Even log with message and properties and use it to get details about errors

Dart

try {
    ...
} catch (e, st) {
    final msg = "Error Exception";
    await AppambitSdk.logError(
        message: msg,
        properties: <String, String>{'user_id': '1'}
    );
}

Details about the last crash

If the app has previously crashed, the function will return a boolean

Dart

await AppambitSdk.didCrashInLastSession();