trackError static method

Future<void> trackError(
  1. dynamic exception,
  2. StackTrace? stack, {
  3. Map<String, String> properties = const {},
  4. bool fatal = false,
})

Track a handled error with name and optional properties. The property names and values are limited to 64 characters each. The number of properties per crash is limited to 5. The property names or values cannot be null.

Implementation

static Future<void> trackError(
  dynamic exception,
  StackTrace? stack, {
  Map<String, String> properties = const {},
  bool fatal = false,
}) async {
  _validateArgs(properties);

  stack ??= StackTrace.current;
  var convertedException = ExceptionLog(
    type: exception.runtimeType.toString(),
    message: exception.toString(),
    stackTrace: stack.toString(),
  );

  return await AppCenter.instance.logService.addLog(ManagedErrorLog(
    appLaunchTimestamp: AppCenter.instance.appLaunchTimestamp,
    sid: AppCenter.instance.sessionId,
    device: AppCenter.instance.deviceService.device,
    properties: properties,
    processId: pid,
    processName: pid.toString(),
    fatal: fatal,
    exception: convertedException,
  ));
}