Skip to content

Commit 94908c2

Browse files
committed
Rename SessionState to SessionDetails
1 parent 17e59c0 commit 94908c2

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SessionEvent.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.google.firebase.sessions
1818

1919
/**
20-
* Contains the relevant information around an App Quality Session.
20+
* Contains the relevant information around a session event.
2121
*
2222
* See go/app-quality-unified-session-definition for more details. Keep in sync with
2323
* https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseSessions/ProtoSupport/Protos/sessions.proto
@@ -31,14 +31,14 @@ internal data class SessionEvent(
3131
val sessionData: SessionInfo,
3232
) {
3333
companion object {
34-
fun sessionStart(sessionState: SessionState) =
34+
fun sessionStart(sessionDetails: SessionDetails) =
3535
SessionEvent(
3636
eventType = EventType.SESSION_START,
3737
sessionData =
3838
SessionInfo(
39-
sessionState.sessionId,
40-
sessionState.firstSessionId,
41-
sessionState.sessionIndex,
39+
sessionDetails.sessionId,
40+
sessionDetails.firstSessionId,
41+
sessionDetails.sessionIndex,
4242
),
4343
)
4444
}

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SessionGenerator.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package com.google.firebase.sessions
1919
import java.util.UUID
2020

2121
/**
22-
* [SessionState] is a data class responsible for storing information about the current Session.
22+
* [SessionDetails] is a data class responsible for storing information about the current Session.
2323
*
2424
* @hide
2525
*/
26-
internal data class SessionState(
26+
internal data class SessionDetails(
2727
val sessionId: String,
2828
val firstSessionId: String,
2929
val collectEvents: Boolean,
@@ -32,16 +32,16 @@ internal data class SessionState(
3232

3333
/**
3434
* The [SessionGenerator] is responsible for generating the Session ID, and keeping the
35-
* [SessionState] up to date with the latest values.
35+
* [SessionDetails] up to date with the latest values.
3636
*
3737
* @hide
3838
*/
3939
internal class SessionGenerator(private var collectEvents: Boolean) {
4040
private var firstSessionId = ""
4141
private var sessionIndex: Int = -1
4242

43-
private var thisSession: SessionState =
44-
SessionState(
43+
private var thisSession: SessionDetails =
44+
SessionDetails(
4545
sessionId = "",
4646
firstSessionId = "",
4747
collectEvents,
@@ -50,7 +50,7 @@ internal class SessionGenerator(private var collectEvents: Boolean) {
5050

5151
// Generates a new Session ID. If there was already a generated Session ID
5252
// from the last session during the app's lifecycle, it will also set the last Session ID
53-
fun generateNewSession(): SessionState {
53+
fun generateNewSession(): SessionDetails {
5454
val newSessionId = UUID.randomUUID().toString().replace("-", "").lowercase()
5555

5656
// If firstSessionId is set, use it. Otherwise set it to the
@@ -60,11 +60,11 @@ internal class SessionGenerator(private var collectEvents: Boolean) {
6060
sessionIndex += 1
6161

6262
thisSession =
63-
SessionState(sessionId = newSessionId, firstSessionId, collectEvents, sessionIndex)
63+
SessionDetails(sessionId = newSessionId, firstSessionId, collectEvents, sessionIndex)
6464

6565
return thisSession
6666
}
6767

68-
val currentSession: SessionState
68+
val currentSession: SessionDetails
6969
get() = thisSession
7070
}

firebase-sessions/src/test/kotlin/com/google/firebase/sessions/SessionEventTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ import org.junit.Test
2121

2222
class SessionEventTest {
2323
@Test
24-
fun sessionStart_populatesSessionStateCorrectly() {
25-
val sessionState =
26-
SessionState(
24+
fun sessionStart_populatesSessionDetailsCorrectly() {
25+
val sessionDetails =
26+
SessionDetails(
2727
sessionId = "a1b2c3",
2828
firstSessionId = "a1a1a1",
2929
collectEvents = true,
3030
sessionIndex = 3,
3131
)
3232

33-
val sessionEvent = SessionEvent.sessionStart(sessionState)
33+
val sessionEvent = SessionEvent.sessionStart(sessionDetails)
3434

3535
assertThat(sessionEvent)
3636
.isEqualTo(

firebase-sessions/src/test/kotlin/com/google/firebase/sessions/SessionGeneratorTest.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SessionGeneratorTest {
4747
}
4848

4949
@Test
50-
fun generateNewSessionID_generatesValidSessionState() {
50+
fun generateNewSessionID_generatesValidSessionDetails() {
5151
val sessionGenerator = SessionGenerator(collectEvents = true)
5252

5353
sessionGenerator.generateNewSession()
@@ -68,32 +68,32 @@ class SessionGeneratorTest {
6868

6969
sessionGenerator.generateNewSession()
7070

71-
val firstSessionState = sessionGenerator.currentSession
71+
val firstSessionDetails = sessionGenerator.currentSession
7272

73-
assertThat(isValidSessionId(firstSessionState.sessionId)).isTrue()
74-
assertThat(isValidSessionId(firstSessionState.firstSessionId)).isTrue()
75-
assertThat(firstSessionState.firstSessionId).isEqualTo(firstSessionState.sessionId)
76-
assertThat(firstSessionState.sessionIndex).isEqualTo(0)
73+
assertThat(isValidSessionId(firstSessionDetails.sessionId)).isTrue()
74+
assertThat(isValidSessionId(firstSessionDetails.firstSessionId)).isTrue()
75+
assertThat(firstSessionDetails.firstSessionId).isEqualTo(firstSessionDetails.sessionId)
76+
assertThat(firstSessionDetails.sessionIndex).isEqualTo(0)
7777

7878
sessionGenerator.generateNewSession()
79-
val secondSessionState = sessionGenerator.currentSession
79+
val secondSessionDetails = sessionGenerator.currentSession
8080

81-
assertThat(isValidSessionId(secondSessionState.sessionId)).isTrue()
82-
assertThat(isValidSessionId(secondSessionState.firstSessionId)).isTrue()
81+
assertThat(isValidSessionId(secondSessionDetails.sessionId)).isTrue()
82+
assertThat(isValidSessionId(secondSessionDetails.firstSessionId)).isTrue()
8383
// Ensure the new firstSessionId is equal to the first Session ID from earlier
84-
assertThat(secondSessionState.firstSessionId).isEqualTo(firstSessionState.sessionId)
84+
assertThat(secondSessionDetails.firstSessionId).isEqualTo(firstSessionDetails.sessionId)
8585
// Session Index should increase
86-
assertThat(secondSessionState.sessionIndex).isEqualTo(1)
86+
assertThat(secondSessionDetails.sessionIndex).isEqualTo(1)
8787

8888
// Do a third round just in case
8989
sessionGenerator.generateNewSession()
90-
val thirdSessionState = sessionGenerator.currentSession
90+
val thirdSessionDetails = sessionGenerator.currentSession
9191

92-
assertThat(isValidSessionId(thirdSessionState.sessionId)).isTrue()
93-
assertThat(isValidSessionId(thirdSessionState.firstSessionId)).isTrue()
92+
assertThat(isValidSessionId(thirdSessionDetails.sessionId)).isTrue()
93+
assertThat(isValidSessionId(thirdSessionDetails.firstSessionId)).isTrue()
9494
// Ensure the new firstSessionId is equal to the first Session ID from earlier
95-
assertThat(thirdSessionState.firstSessionId).isEqualTo(firstSessionState.sessionId)
95+
assertThat(thirdSessionDetails.firstSessionId).isEqualTo(firstSessionDetails.sessionId)
9696
// Session Index should increase
97-
assertThat(thirdSessionState.sessionIndex).isEqualTo(2)
97+
assertThat(thirdSessionDetails.sessionIndex).isEqualTo(2)
9898
}
9999
}

0 commit comments

Comments
 (0)