recordError static method
Submits a Crashlytics report of a caught error.
Implementation
static Future<void> recordError(
dynamic exception,
StackTrace? stack, {
String? reason,
bool fatal = false,
bool printDetails = true,
Map<String, dynamic>? moreInfo,
}) async {
if (printDetails) {
print('----------------CRASHLYTICS----------------');
if (reason != null) {
print('The following exception was thrown $reason:');
}
print(exception);
if (stack != null) print('\n$stack');
print('-------------------------------------------');
}
if (!collectionEnabled) return;
stack ??= StackTrace.current;
final stackTraceElements = _getStackTraceElements(stack);
final info = {
'reason': reason,
'fatal': fatal,
'version': SupabaseAddons.appVersion,
'os': operatingSystem,
'country_code': getUserCountry(),
if (moreInfo != null && !moreInfo.containsKey('user_id'))
'user_id': SupabaseAuthAddons.auth.currentUser?.id,
if (moreInfo != null) ...moreInfo,
};
final result = await SupabaseAddons.client.from(tableName).insert({
'exception': exception.toString(),
'stacktraceelements': stackTraceElements,
'info': info,
'timestamp': DateTime.now().millisecondsSinceEpoch,
}).execute();
if (result.error != null) {
print(result.error!.message);
throw result.error!;
}
}