File tree 5 files changed +38
-6
lines changed
main/java/com/amplifyframework/pinpoint/core
test/java/com/amplifyframework/pinpoint/core
5 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ dependencies {
39
39
testImplementation(libs.test.robolectric)
40
40
testImplementation(libs.test.androidx.core)
41
41
testImplementation(libs.test.kotlin.coroutines)
42
+ testImplementation(libs.test.kotest.assertions)
42
43
43
44
androidTestImplementation(libs.test.androidx.core)
44
45
androidTestImplementation(libs.test.androidx.runner)
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class AnalyticsClient(
96
96
eventTimestamp : Long = System .currentTimeMillis(),
97
97
eventId : String = UUID .randomUUID().toString()
98
98
): PinpointEvent {
99
- val session = sessionClient?.session ? : Session (context, uniqueId)
99
+ val session = sessionClient?.session ? : Session (uniqueId)
100
100
return createEvent(
101
101
eventType,
102
102
session.sessionId,
Original file line number Diff line number Diff line change 14
14
*/
15
15
package com.amplifyframework.pinpoint.core
16
16
17
- import android.content.Context
18
17
import com.amplifyframework.annotations.InternalAmplifyApi
19
18
import java.text.SimpleDateFormat
20
19
import java.util.Locale
@@ -53,11 +52,10 @@ class Session {
53
52
}
54
53
55
54
constructor (
56
- context: Context ,
57
55
uniqueId: String
58
56
) {
59
- this @Session.sessionId = generateSessionId(uniqueId)
60
57
this @Session.startTime = System .currentTimeMillis()
58
+ this @Session.sessionId = generateSessionId(uniqueId)
61
59
this @Session.stopTime = null
62
60
}
63
61
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class SessionClient(
23
23
private val context : Context ,
24
24
val targetingClient : TargetingClient ,
25
25
private val uniqueId : String ,
26
- var analyticsClient : AnalyticsClient ? = null ,
26
+ var analyticsClient : AnalyticsClient ? = null
27
27
) {
28
28
29
29
var session: Session ? = null
@@ -66,7 +66,7 @@ class SessionClient(
66
66
67
67
private fun executeStart () {
68
68
targetingClient.updateEndpointProfile()
69
- val newSession = Session (context, uniqueId)
69
+ val newSession = Session (uniqueId)
70
70
session = newSession
71
71
analyticsClient?.let {
72
72
val pinpointEvent = it.createEvent(
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License").
5
+ * You may not use this file except in compliance with the License.
6
+ * A copy of the License is located at
7
+ *
8
+ * http://aws.amazon.com/apache2.0
9
+ *
10
+ * or in the "license" file accompanying this file. This file is distributed
11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
+ * express or implied. See the License for the specific language governing
13
+ * permissions and limitations under the License.
14
+ */
15
+
16
+ package com.amplifyframework.pinpoint.core
17
+
18
+ import io.kotest.matchers.equals.shouldNotBeEqual
19
+ import kotlinx.coroutines.delay
20
+ import kotlinx.coroutines.test.runTest
21
+ import org.junit.Test
22
+
23
+ class SessionTest {
24
+ @Test
25
+ fun `sessions created at different times have different session IDs` () = runTest {
26
+ val uniqueId = " id"
27
+ val session = Session (uniqueId)
28
+ delay(10 )
29
+ val session2 = Session (uniqueId)
30
+
31
+ session.sessionId shouldNotBeEqual session2.sessionId
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments