Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New session ID is not created #149

Open
kataRebuy opened this issue Oct 18, 2022 · 2 comments
Open

New session ID is not created #149

kataRebuy opened this issue Oct 18, 2022 · 2 comments

Comments

@kataRebuy
Copy link

SDK version: 1.4.4

A new session ID is not provided even after the minTimeBetweenSessionsMillis is exceeded. The issue only happens when there is an ampli.identify() call at app start. In this case startNewSessionIfNeeded is called twice causing probably some threading issue. When I only put a breakpoint inside isWithinMinTimeBetweenSessions I get timestamp - lastEventTime == 0. If I start debugging I can also get a negative number for timestamp - lastEventTime
Screenshot 2022-10-18 at 08 48 33

I can see that once the function is called from onEnterForeground and the other time it is called because of applyContextData inside AndroidContextPlugin because of the identify call. Probably this is causing a threading issue.

With this I can reproduce the issue:

ampli.load(
    context,
    LoadOptions(
        environment = Ampli.Environment.DEVELOPMENT,
        client = LoadClientOptions(instance = Amplitude(Configuration(apiKey = apiKey, context = context, minTimeBetweenSessionsMillis = 5000)))
    )
)
ampli.identify(null, Identify(property ="value"))

Once the identify is removed then it works fine.

@kevinpagtakhan
Copy link
Contributor

H @kataRebuy, thank you for choosing Amplitude. We'll investigate this with the team and get back to you soon. This may be related to another issue that we are working on a fix for.

@kataRebuy
Copy link
Author

@kevinpagtakhan it seems like your recent release(com.amplitude:analytics-android:1.4.5) solved the issue but introduced a new one, now I always get a start session event when restarting the app.
Following config for testing:

ampli.load(
    context,
    LoadOptions(
        environment = Ampli.Environment.DEVELOPMENT,
        client = LoadClientOptions(instance = Amplitude(Configuration(apiKey = apiKey, context = context, minTimeBetweenSessionsMillis = 3000000)))
    )
)
ampli.identify(null, Identify(property ="value"))

With this config, every time I get a new Start session event even though the minTimeBetweenSessionsMillis haven't passed. Once I remove the ampli.identify it works as expected. It seems that it triggers the startNewSession function because inSession() is false
Screenshot 2022-10-24 at 11 48 24

Screenshot 2022-10-24 at 11 48 52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants