Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ constructor(
CoroutineScope(backgroundDispatcher).launch {
try {
sessionDataStore.updateData {
// TODO(mrober): Double check time makes sense?
sessionData.copy(backgroundTime = timeProvider.currentTime())
}
} catch (ex: Exception) {
Expand All @@ -125,6 +124,9 @@ constructor(
val isSessionExpired = isSessionExpired(currentSessionData)
val isColdStart = isColdStart(currentSessionData)
val isMyProcessStale = isMyProcessStale(currentSessionData)
println(
"isSessionExpired: $isSessionExpired isColdStart: $isColdStart isMyProcessStale: $isMyProcessStale"
)

val newProcessDataMap =
if (isColdStart) {
Expand All @@ -138,10 +140,17 @@ constructor(
currentSessionData.processDataMap
}

val currentSession =
if (isColdStart) {
// For a cold start, do not keep the current session
null
} else {
currentSessionData.sessionDetails
}

// This is an expression, and returns the updated session data
if (isSessionExpired || isColdStart) {
val newSessionDetails =
sessionGenerator.generateNewSession(currentSessionData.sessionDetails)
val newSessionDetails = sessionGenerator.generateNewSession(currentSession)
sessionFirelogPublisher.mayLogSession(sessionDetails = newSessionDetails)
processDataManager.onSessionGenerated()
currentSessionData.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ class SharedSessionRepositoryTest {
fakeDataStore.close()

assertThat(sharedSessionRepository.localSessionData.sessionDetails)
.isEqualTo(
SessionDetails(SESSION_ID_1, SESSION_ID_INIT, 1, fakeTimeProvider.currentTime().us)
)
.isEqualTo(SessionDetails(SESSION_ID_1, SESSION_ID_1, 0, fakeTimeProvider.currentTime().us))
}

@Test
Expand Down
Loading