File tree Expand file tree Collapse file tree 5 files changed +38
-6
lines changed
main/java/com/amplifyframework/pinpoint/core
test/java/com/amplifyframework/pinpoint/core Expand file tree Collapse file tree 5 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ dependencies {
3939 testImplementation(libs.test.robolectric)
4040 testImplementation(libs.test.androidx.core)
4141 testImplementation(libs.test.kotlin.coroutines)
42+ testImplementation(libs.test.kotest.assertions)
4243
4344 androidTestImplementation(libs.test.androidx.core)
4445 androidTestImplementation(libs.test.androidx.runner)
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class AnalyticsClient(
9696 eventTimestamp : Long = System .currentTimeMillis(),
9797 eventId : String = UUID .randomUUID().toString()
9898 ): PinpointEvent {
99- val session = sessionClient?.session ? : Session (context, uniqueId)
99+ val session = sessionClient?.session ? : Session (uniqueId)
100100 return createEvent(
101101 eventType,
102102 session.sessionId,
Original file line number Diff line number Diff line change 1414 */
1515package com.amplifyframework.pinpoint.core
1616
17- import android.content.Context
1817import com.amplifyframework.annotations.InternalAmplifyApi
1918import java.text.SimpleDateFormat
2019import java.util.Locale
@@ -53,11 +52,10 @@ class Session {
5352 }
5453
5554 constructor (
56- context: Context ,
5755 uniqueId: String
5856 ) {
59- this @Session.sessionId = generateSessionId(uniqueId)
6057 this @Session.startTime = System .currentTimeMillis()
58+ this @Session.sessionId = generateSessionId(uniqueId)
6159 this @Session.stopTime = null
6260 }
6361
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class SessionClient(
2323 private val context : Context ,
2424 val targetingClient : TargetingClient ,
2525 private val uniqueId : String ,
26- var analyticsClient : AnalyticsClient ? = null ,
26+ var analyticsClient : AnalyticsClient ? = null
2727) {
2828
2929 var session: Session ? = null
@@ -66,7 +66,7 @@ class SessionClient(
6666
6767 private fun executeStart () {
6868 targetingClient.updateEndpointProfile()
69- val newSession = Session (context, uniqueId)
69+ val newSession = Session (uniqueId)
7070 session = newSession
7171 analyticsClient?.let {
7272 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