put method
Keeps report, and returns false when a report with its id is already
kept: a client that died between sending and noting the send sends it
again, and that is one crash, not two.
Implementation
@override
Future<bool> put(DVCrashReport report, {required DateTime receivedAt}) async {
await ensureSchema();
final List<Map<String, Object?>> existing = await database.query(
'SELECT id FROM $table WHERE id = ?',
<Object?>[report.id],
);
if (existing.isNotEmpty) return false;
await database.execute(
'INSERT INTO $table (id, install_id, app_release, kind, fingerprint, '
'occurred_at, received_at, report) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
<Object?>[
report.id,
report.context.installId,
report.context.release,
report.kind.name,
report.fingerprint,
report.occurredAt.toUtc().toIso8601String(),
receivedAt.toUtc().toIso8601String(),
jsonEncode(report.toJson()),
],
);
return true;
}