Flutter bug report attachments
A bug report attachment adds one file of your Flutter app to the report shown in the Appelium Dashboard. Use it for diagnostic state that the screenshot, the activity log and the network logs do not already show, such as a compact export of your app's state, generated diagnostic JSON or a relevant cache file.
The delegate is called each time a bug report is created: when the form opens, or when a silent report is sent. Returning null omits the attachment for that report.
Configure the delegate
Implement BugReportingDelegate and pass it to the bug reporting configuration:
import 'dart:convert';
import 'dart:typed_data';
import 'package:appelium_feedback/appelium_feedback.dart';
class DiagnosticsAttachmentDelegate implements BugReportingDelegate {
@override
Future<ReportAttachment?> bugReportAttachment() async {
final state = await loadDiagnosticState();
if (state == null) {
return null;
}
return ReportAttachment(
fileName: 'diagnostics.json',
data: Uint8List.fromList(utf8.encode(jsonEncode(state))),
);
}
}
AppeliumFeedback.start(
apiKeys: apiKeys,
bugReporting: BugReportingConfiguration.enabled(
delegate: DiagnosticsAttachmentDelegate(),
),
);
bugReportAttachment() returns a Future, so you can await slower work, such as reading a file. The form opens without waiting for it, and the report is sent once the Future completes. If it throws, the report is sent without an attachment.
Attachment limits
Each ReportAttachment contains a file name and its bytes. If the data is larger than 100,000 bytes, the SDK keeps the last 100,000. Each bug report can carry one attachment, in addition to the screenshot, screen recording and activity log.
Prefer small, self-describing content:
- use a meaningful extension such as
.json,.txtor.sqlite; - leave out large logs or database contents that other parts of the report already show;
- shorten collections before you serialize them, rather than relying on the SDK to keep the last bytes;
- if the data cannot be produced safely, return
nullrather than attaching a stale file.
Load a file safely
Catch the errors of file access and return null, so that the report is still sent:
@override
Future<ReportAttachment?> bugReportAttachment() async {
try {
final file = File('${diagnosticsDirectory.path}/state.json');
return ReportAttachment(fileName: 'state.json', data: await file.readAsBytes());
} on FileSystemException catch (error) {
AppeliumFeedback.logWarning(
'Unable to prepare the bug report attachment: ${error.message}',
domain: 'Diagnostics',
);
return null;
}
}
The method can also build the content in memory from the current state instead of exposing an internal storage file.
Privacy
Attachments are uploaded with the bug report. Review their content as carefully as the report itself:
- do not attach passwords, access or refresh tokens, private keys, payment card data or full user profiles;
- use IDs and state transitions when raw names or email addresses are not needed;
- avoid complete SQLite databases unless their retention and their fields are explicitly approved;
- account for attachment data in your privacy policy and the workspace's retention setting.
See Network logs for request and response redaction.
Troubleshooting
- No attachment in the Dashboard: check that the delegate is passed to
BugReportingConfiguration.enabled(delegate:)and thatbugReportAttachment()completed with an attachment. - The file contains only its end: the data was larger than 100,000 bytes; shorten or summarize it before creating the
ReportAttachment. - Sensitive data appears in reports: stop attaching it, rotate any exposed credential, and review the workspace's data retention and privacy requirements.