attachLogs method
Forms and attaches LogController.report log to attachments.
Implementation
Future<void> attachLogs() async {
final DateTime utc = DateTime.now().toUtc();
final String app = PlatformUtils.isWeb
? Config.origin.replaceFirst('https://', '').replaceFirst('http://', '')
: Config.userAgentProduct;
final String report = LogController.report(
sessions: _sessions,
sessionId: _sessionId,
userAgent: await PlatformUtils.userAgent,
myUser: _myUser?.value,
token: _token,
pushNotifications: _pushNotifications,
notificationSettings: await LogController.getNotificationSettings(),
);
final Utf8Encoder encoder = Utf8Encoder();
final Uint8List bytes = encoder.convert(report);
await _addAttachment(
NativeFile(
name:
'${app.toLowerCase()}_bug_report_${utc.year.toString().padLeft(4, '0')}.${utc.month.toString().padLeft(2, '0')}.${utc.day.toString().padLeft(2, '0')}_${utc.hour.toString().padLeft(2, '0')}.${utc.minute.toString().padLeft(2, '0')}.${utc.second.toString().padLeft(2, '0')}.log',
size: bytes.lengthInBytes,
bytes: bytes,
mime: MediaType('text', 'plain'),
),
);
}