amplitude / amplitude/Amplitude-Flutter
Only complete initialization after userId is properly set
- Dominant language
- Dart
- Stars
- 133
- Forks
- 108
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Currently, if we initialize the plugin via `Amplitude.getInstance()` and try to get userId from it via `Amplitude.getInstance().getUserId()` right after, the userId is not set yet, because the initialization happens in a background thread and there is not a proper way to know when it is completed.
I've seen a `initCompletionBlock` that can be used for that on the iOS SDK, but I couldn't find one in the Android one. So maybe a change on the Android SDK would also be needed to achieve this.
## Motivations
Since we don't know when the userId will be ready, we need to wait some arbitrary amount of time. Since we use the presence of the userId to make some initialization decisions, if by any reason the amplitude initialization takes longer (e.g. some database migration), we will take the wrong initialization route.
Contributor guide
Assessment
This issue has not been assessed yet.