aws-amplify / aws-amplify/amplify-android
About using new session in AnalyticsClient
- Dominant language
- Java
- Stars
- 287
- Forks
- 132
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 45
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-android/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-android/discussions).
### Language and Async Model
Kotlin
### Amplify Categories
Analytics
### Gradle script dependencies
```groovy
dependencies {
...
api ("com.amplifyframework:aws-analytics-pinpoint:2.14.13") {
exclude( group = "androidx.lifecycle", module = "lifecycle-viewmodel-ktx")
}
api ("com.amplifyframework:aws-auth-cognito:2.14.13") {
exclude( group = "androidx.lifecycle", module = "lifecycle-viewmodel-ktx")
}
...
}
```
### Environment information
```
------------------------------------------------------------
Gradle 8.1.1
------------------------------------------------------------
Build time: 2023-04-21 12:31:26 UTC
Revision: 1cf537a851c635c364a4214885f8b9798051175b
Kotlin: 1.8.10
Groovy: 3.0.15
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 19.0.1 (Oracle Corporation 19.0.1+10-21)
OS: Mac OS X 12.0.1 aarch64
```
### Please include any relevant guides or documentation you're referencing
_No response_
### Describe the feature request
When I did not initialize Amplify at the Application level,
AutoSessionTracker was behaving strangely.
This prevented sessions from being created and deleted properly.
After that, a new session was created every time we sent an event.
While trying to figure out what was causing this issue, I came across a suggestion in AnalyticsClient > createEvent.
In createEvent, if the session of sessionClient doesn't exist, we create a new Session and pass it over.
In this case, the newly created session is not stored in the sessionClient and seems to be created anew each time.
If this is not the intention, my suggestion would be to save the session to the sessionClient when it is newly created.
This would make the behavior a bit more understandable.
Thanks!
[link](https://github.com/aws-amplify/amplify-android/blob/4bea6d49a4d340d6a9c2b70909247a0045a01117/aws-pinpoint-core/src/main/java/com/amplifyframework/pinpoint/core/AnalyticsClient.kt#L99)
### Initialization steps (if applicable)
_No response_
### Code Snippet
```java
// Put your code below this line.
```
### amplifyconfiguration.json
_No response_
### GraphQL Schema
```graphql
// Put your schema below this line
```
### Additional information and screenshots
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.