processEvent static method

EnrichedSessionEvent processEvent({
  1. required SessionState? state,
  2. required int now,
  3. required String messageId,
  4. required String timestamp,
  5. int foregroundSessionTimeout = 0,
  6. int backgroundSessionTimeout = 0,
  7. bool isAppInBackground = false,
})

Implementation

static EnrichedSessionEvent processEvent({
  required SessionState? state,
  required int now,
  required String messageId,
  required String timestamp,
  int foregroundSessionTimeout = 0,
  int backgroundSessionTimeout = 0,
  bool isAppInBackground = false,
}) {
  final shouldRotate = state == null ||
      shouldRotateOnResume(
        state,
        now,
        backgroundSessionTimeout: backgroundSessionTimeout,
      ) ||
      (!isAppInBackground &&
          shouldRotateOnInactivity(
            state,
            now,
            foregroundSessionTimeout: foregroundSessionTimeout,
          ));

  final currentState = shouldRotate
      ? rotateSession(state, now, messageId, timestamp)
      : ensureFirstEvent(state, messageId, timestamp);

  return enrichEvent(
    currentState,
    now,
    updateActivity: !isAppInBackground,
  );
}