ErrorFingerprint.compute constructor

ErrorFingerprint.compute(
  1. Object error,
  2. StackTrace stackTrace
)

Compute a fingerprint from an error and its stack trace.

The fingerprint is a SHA-256 hash of: errorType + top3StackFrames

This groups "same-root-cause" crashes together regardless of field values, timestamps, or unrelated stack frames.

Implementation

factory ErrorFingerprint.compute(Object error, StackTrace stackTrace) {
  final errorType = error.runtimeType.toString();
  final frames = _extractTopFrames(stackTrace, count: 3);
  final input = '$errorType|${frames.join('|')}';
  final digest = sha256.convert(utf8.encode(input));

  return ErrorFingerprint(
    hash: digest.toString(),
    errorType: errorType,
    topFrames: frames,
  );
}