allow method

bool allow()

Checks if another crash can be transmitted under the current rate limit window.

Implementation

bool allow() {
  final now = DateTime.now();

  while (_timestamps.isNotEmpty &&
      now.difference(_timestamps.first) >= _window) {
    _timestamps.removeAt(0);
  }

  if (_timestamps.length >= _maxCrashes) {
    return false;
  }

  _timestamps.add(now);

  return true;
}