PostHog / posthog-android

PostHog Android SDK
https://posthog.com/docs/libraries/android
MIT License
43 stars 23 forks source link

Last event before Posthog.reset() isn't flushed and displayed on analytics front end. #169

Closed AlexMisiulia closed 2 months ago

AlexMisiulia commented 2 months ago

Version

3.6.0

Steps to Reproduce

  1. User has logged in into the application (PostHog.identify() called).
  2. User has logged out of the application (PostHog.capture("Logged out") called).
  3. User session has been reset (PostHog.reset() called).

Expected Result

Identify and Logged out events are captured and displayed on analytics front end.

Actual Result

Only identify event is captured and displayed on analytics front end.

I tried to use this code but got the same result:

PostHog.flush()
PostHog.reset()

This work around works for me:

       private val handler = Handler(Looper.getMainLooper())

       PostHog.flush()

        // work around for last event before resetPosthog isn't sent because Posthog.reset() clears
        // the internal queue of events even when flush is called
        handler.postDelayed(
            { PostHog.reset() },
            1000L
        )
marandaneto commented 2 months ago

Hello @AlexMisiulia indeed, reset should not clear the queue, indeed, let me fix it

AlexMisiulia commented 2 months ago

@marandaneto Hello. Thank you for the fast fix. Maybe you have ETA for a release with this fix?

marandaneto commented 2 months ago

its released already https://github.com/PostHog/posthog-android/releases/tag/3.6.1