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

Doubling events in multi-process app #287

Open
dmersiyanov opened this issue Jul 5, 2021 · 4 comments
Open

Doubling events in multi-process app #287

dmersiyanov opened this issue Jul 5, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@dmersiyanov
Copy link

I've faced an issue with amplitude auto session tracking in the multi-process app. According to the logs, start_session and end_session events are sent twice or more times.

Also, you can check this user to see how is that look like in analytics - https://analytics.amplitude.com/dpdrussia/project/294323/search/amplitude_id%3D274642275421?sessionHandle=Xp1yKdg_Xp1x4AJ_D%2Fx9Ixd_BH2z_88f8c6d7-fd46-4b50-a392-b3cbf66f1bb5R&eventId=d6ab76df-dd6a-11eb-bf47-02ef0a11101f

Expected Behavior

Session auto-tracking events sent only once per whole application (not per process)

Current Behavior

Start_session and end_session events are sent twice or more times.

Possible Solution

Add internal checking if another process started by the application, check this lib for inspiration - https://github.com/int02h/primaree

Steps to Reproduce

  1. Create a service that runs in another process and declare it in manifest

     <service
         android:name="com.example.JobService"
         android:enabled="true"
         android:exported="false"
         android:permission="android.permission.BIND_JOB_SERVICE"
         android:process=":NewProcess" >
     </service>
    
  2. Init amplitude in android Application class in onCreate method (enable logging)

      Amplitude.getInstance().initialize(app, ApiKeys.AMPLITUDE)
         .enableForegroundTracking(app)
         .enableLocationListening()
         .trackSessionEvents(true)
         .enableLogging(true)
         .setLogLevel(Log.DEBUG)
    
  3. Open \ close app to generate required events

Environment

  • SDK Version: v2.30.2
  • Android API Level: 30
  • Device: Xiaomi Mi 8
@dmersiyanov dmersiyanov added the bug Something isn't working label Jul 5, 2021
@dantetam
Copy link
Contributor

Hello @dmersiyanov ,

That's an interesting test case, and obviously not a desired result. Apps running on multiple processes should not be treated in the SDK as multiple apps/users. We'll look into this

Dante

@dantetam
Copy link
Contributor

Hello again @dmersiyanov ,

Could you help us by providing more information about your multiprocess setup?

I could not reproduce the bug with just a plain new service inside a separate process. I did analyze your charts and realize there are far too many start session events. However, the timing is often 10 minutes to 3 hours ahead. Do you believe the extra process is triggering a start session event when the user has not opened the app?

  1. Which classes are calling the Amplitude SDK, just your main application? Is that all the instrumentation?
  2. Are you doing any special multiprocess service binding? Could you provide as much manifest/gradle/file structure info as possible?

Dante

@qingzhuozhen
Copy link
Contributor

Hi @dmersiyanov , we can't reproduce so far. Can you provide more information to help us reproduce or debug?

@aabolfazl
Copy link

I am currently encountering a specific issue with the Amplitude SDK in a multiprocess application but I am unsure. The problem manifests as a significant discrepancy in the data reported by Amplitude compared to another analytics service I am using. Specifically, there's a notable difference, approximately double, in the reported analytics.

Could you provide recommendations or best practices for creating such a clear test environment? This would help in isolating the issue and facilitating a more precise diagnosis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants