AppSessionTracker constructor

AppSessionTracker({
  1. Duration sessionTimeout = const Duration(minutes: 30),
  2. RoyLifecycleCoordinator? lifecycle,
  3. String generateSessionId()?,
  4. Stopwatch createStopwatch()?,
})

Implementation

AppSessionTracker({
  this.sessionTimeout = const Duration(minutes: 30),
  RoyLifecycleCoordinator? lifecycle,
  String Function()? generateSessionId,
  Stopwatch Function()? createStopwatch,
}) : _generateSessionId = generateSessionId ?? _defaultSessionId,
     _createStopwatch = createStopwatch ?? Stopwatch.new {
  _foregroundStopwatch = _createStopwatch();
  _startNewSession();
  final coordinator = lifecycle ?? RoyLifecycleCoordinator.maybe;
  if (coordinator != null) {
    _lifecycle = coordinator;
    coordinator.registerHook(_hookName, (event) async {
      handleLifecycleEvent(event);
    });
  }
}