processRecord method
Process a completed (or failed) HTTP request.
Implementation
void processRecord(RequestRecord record) {
if (!_isEnabled) return;
// Drop records from a previous page: their startedAt precedes the last
// clearRecords() call, meaning the request was initiated before the user
// navigated away. Without this guard, slow responses arriving after
// navigation pollute the new page's buffer.
if (_ignoreBeforeTimestamp != null &&
!record.startedAt.isAfter(_ignoreBeforeTimestamp!)) {
return;
}
// Add to ring buffer (FIFO eviction)
_records.add(record);
if (_records.length > _bufferCapacity) _records.removeFirst();
// Start frequency timer on first record
_frequencyTimer ??= Timer.periodic(
const Duration(milliseconds: _frequencyWindowMs),
(_) => _evaluate(),
);
// Full re-evaluation from buffer
_evaluate();
}