We have followed the guidance in the linked article and Mixpanel documentation as well.
As per mixpanel, set alias on sign up
MixpanelAPI mixpanelAPI = MixpanelAPI.getInstance(context, MixPanelConstants.MIX_PANEL_TOKEN);
mixpanelAPI.alias("myAlias", mixpanelAPI.getDistinctId());
and then set identifier/distinct-id on login
MixpanelAPI mixpanelAPI = MixpanelAPI.getInstance(context, MixPanelConstants.MIX_PANEL_TOKEN);
mixpanelAPI.identify("user@xyz.com");
However this approach doesn't support linking of pre-login and post-login events if user doesn't sign up and logs in directly. Alias is set when user signs up and then identify is called on login. Mixpanel recommended to set Alias once during the life time of the user. But in case of existing user, when he tries to login, events won't be linked.
As per MixPanel guidance events can be linked if alias is set first and then identifier.
//set alias when user signs up
MixpanelAPI mixpanelAPI = MixpanelAPI.getInstance(context, MixPanelConstants.MIX_PANEL_TOKEN);
mixpanelAPI.alias("myAlias", mixpanelAPI.getDistinctId());
//set identifier when user logs in
mixpanelAPI.identify("user.alias");
Alias is set when user performs registration, right? Mixpanel recommends to set Alias once during the life time of the user. However this guidance doesn't support linking of pre-login and post-login events if user doesn't perform registration and logins directly (Existing user scenario)