sendException method

  1. @override
Future<void> sendException(
  1. String description, {
  2. bool? fatal,
})
inherited

In order to avoid sending any personally identifying information, the description field must not contain the exception message. In addition, only the first 100 chars of the description will be sent.

Implementation

@override
Future<void> sendException(String description, {bool? fatal}) {
  // We trim exceptions to a max length; google analytics will apply it's own
  // truncation, likely around 150 chars or so.
  const maxExceptionLength = 1000;

  // In order to ensure that the client of this API is not sending any PII
  // data, we strip out any stack trace that may reference a path on the
  // user's drive (file:/...).
  if (description.contains('file:/')) {
    description = description.substring(0, description.indexOf('file:/'));
  }

  description = description.replaceAll('\n', '; ');

  if (description.length > maxExceptionLength) {
    description = description.substring(0, maxExceptionLength);
  }

  var args = <String, String>{
    'exd': description,
    if (fatal != null && fatal) 'exf': '1',
  };
  return _enqueuePayload('exception', args);
}