Diagnostics
When a scan goes wrong on a user's phone, you usually can't reproduce it on yours. Diagnostics let Roomio support see what happened on that phone, without you having to collect logs from your users.
Send diagnostics to Roomio support
exportDiagnostics packages the SDK's recent diagnostics into an encrypted file that only Roomio can read. It covers recent scans, including ones that crashed or were never exported, or just one scan if you pass its scanId.
A common pattern is a "Report a problem" button in your app's help or settings screen that exports the file and opens the share sheet, so a user who hit a problem can send it to you or straight to support.
let url = try await Roomio.exportDiagnostics(scanId: session.scanId)
val file = Roomio.exportDiagnostics(context, scanId = session.scanId)
const path = await Roomio.exportDiagnostics(bundle.scanId ?? undefined); // or no scanId for recent scans
Send the file to support@roomio.io with the scanId, the SDK version (Roomio.version) and what the user saw. On Android, the file is in your app's private storage, so to share it through another app, copy it into a folder your FileProvider covers, such as one in cacheDir.
Forward diagnostics to your own logging
If you already collect logs or crash reports, you can have the SDK's messages land there too, next to your app's own. Choose a minimum level so you only get what you care about; warnings and errors are a good start.
final class RoomioLogger: RoomioDiagnosticsDelegate {
func roomio(didRecord diagnostic: RoomioDiagnostic) {
print("\(diagnostic.code): \(diagnostic.message)")
}
}
// The SDK holds the delegate weakly, so keep a reference to it
Roomio.setDiagnosticsDelegate(logger, minimumLevel: .warning)
Roomio.setDiagnosticsListener(
listener = { diagnostic -> Log.w("Roomio", "${diagnostic.code}: ${diagnostic.message}") },
minimumLevel = RoomioDiagnosticLevel.WARNING,
)
Messages arrive on the main thread. Pass nil or null to stop. New diagnostic codes may be added in future releases. Errors also appear in the device log, even without a listener.
Send waiting reports now
The SDK sends Roomio reports of how scans went when it starts and after each scan, so you rarely need to think about it. If your app is about to be closed for a long time, for example after a test session in the field, Roomio.flush() sends any waiting reports straight away, in the background. It does nothing while a scan is recording.