Skip to content

Only complete initialization after userId is properly set #188

@gabrielgarciagava

Description

@gabrielgarciagava

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions