tryReplayFirstOpenNow static method
Try replaying first_open if needed, with cooldown.
Implementation
static Future<void> tryReplayFirstOpenNow(
int initTimestamp, {
Future<void> Function(Event event)? persistEvent,
}) async {
final isSent = Prefs.getBool(_isSentKey) ?? false;
if (isSent) return;
final isPending = Prefs.getBool(_pendingDurableKey) ?? false;
if (!isPending) return;
final now = DateTime.now().millisecondsSinceEpoch;
if (now - _lastReplayAttemptTs < _replayCooldownMs) return;
_lastReplayAttemptTs = now;
final firstOpenTime = Prefs.getInt('first_open_time') ?? -1;
if (firstOpenTime == -1) return;
final diff = Prefs.getInt(_pendingInstallDiffKey) ??
(initTimestamp - firstOpenTime);
await _recordFirstOpenEvent(
firstOpenTime,
diff,
recordEvent: persistEvent ?? onRecordEvent,
);
await _confirmPendingFirstOpenStored(firstOpenTime);
}