startCall method
Records the start of a request. Returns null when not enabled.
body can be a String, bytes, or a JSON-encodable Map or List.
Implementation
TracklyHttpCall? startCall({
required String client,
required String method,
required Uri uri,
Map<String, String> headers = const {},
Object? body,
List<TracklyFormField>? formData,
}) {
if (!enabled) return null;
final redacted = _redact(headers);
final captured = captureBody(
body,
contentType: headerValue(redacted, 'content-type'),
maxLength: maxBodyLength,
);
final call = TracklyHttpCall._(
id: _nextId++,
client: client,
method: method.toUpperCase(),
uri: uri,
startTime: DateTime.now(),
requestHeaders: redacted,
requestBody: captured.text,
requestSize:
captured.size ??
formData?.fold<int>(0, (sum, field) => sum + (field.fileSize ?? 0)),
requestFormData: formData,
);
_calls.addLast(call);
while (_calls.length > maxCalls) {
_calls.removeFirst();
}
_scheduleNotify();
return call;
}