mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
434 stars 234 forks source link

Several events are silently dropped after calling createAlias #379

Closed zkhalapyan closed 4 years ago

zkhalapyan commented 4 years ago

Integration Method: CocoaPods Xcode Version: Version 11.5 (11E608c) Library Version: Mixpanel-swift (2.7.3) Platform: iOS Language: Swift Description:

I log "did_view_login", then the user logs in, I create an alias with their user ID, then I call "did_login", and a few other events as user goes through onboarding. I have noticed that the first few events after calling createAlias are silently dropped. No error, no indication of problem or warning.

If the user logs out, logs back in where I only call identity(), all onboarding events are properly called. So it's something with calling createAlias that drops these first events.

Seems like https://github.com/mixpanel/mixpanel-iphone/issues/824 is a similar issue but hasn't been addressed for 6 months now.

High-level steps:

  1. Reset Mixpanel from dashboard so we start from a clean slate
  2. Initialize Mixpanel:
    Mixpanel.initialize(token: "XYZ", flushInterval: 10)
  3. Log event 1 ("did_view_login")
  4. Create alias with some ID:
    Mixpanel.mainInstance().createAlias(result.user.uid, distinctId: Mixpanel.mainInstance().distinctId)
  5. Log event 2 ("did_login")
  6. Log event 3

Notice that event 2 and 3 are not logged!

I have not found a workaround other than not using createAlias 🤕.

Expected Behavior: All events should be logged properly; if they are not, at least give me some error so I know what's the issue, so that I don't have to launch an app and only post analysis realize there is this major issue 😢

zihejia commented 4 years ago

hi @zkhalapyan , sorry for the late response. I could not reproduce the problem by using your example. But maybe I missed something, when you say event 2 and 3 are not logged, could you find it in liveview? which report are you referring to? You can turn the logging on Mixpanel.mainInstance().loggingEnabled = true, that should give you more information about the data traffic to mixpanel and errors if there are any.

zihejia commented 4 years ago

hi @zkhalapyan , if you are talking about events being missed in Explore for a specific user, the issue is more from the server side that sometimes a race condition is hard to avoid if the normal events tracking and creating alias api calls are triggered at the same time on the server. You can enable ID Merge through Mixpanel project settings to fix this issue. https://help.mixpanel.com/hc/en-us/articles/360039133851-Moving-to-Identity-Merge.

I'm closing it now, please try the ID Merge, if the problem still exists, please feel free to reopen it.