enrichEvent static method

EnrichedSessionEvent enrichEvent(
  1. SessionState state,
  2. int now, {
  3. bool updateActivity = true,
})

Implementation

static EnrichedSessionEvent enrichEvent(
  SessionState state,
  int now, {
  bool updateActivity = true,
}) {
  final sessionStart = state.eventIndex == 0;
  final contextSession = ContextSession(
    sessionId: state.sessionId,
    sessionIndex: state.sessionIndex,
    sessionStart: sessionStart ? true : null,
    eventIndex: state.eventIndex,
    previousSessionId: state.previousSessionId,
    firstEventId: state.firstEventId,
    firstEventTimestamp: state.firstEventTimestamp,
  );

  final sessionState = state.copyWith(
    eventIndex: state.eventIndex + 1,
    lastActivityAt: updateActivity ? now : state.lastActivityAt,
    clearBackgroundedAt: updateActivity,
  );

  return EnrichedSessionEvent(
    contextSession: contextSession,
    sessionState: sessionState,
  );
}