Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace original with distinct_id in alias #808

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main/java/com/mixpanel/android/mpmetrics/MixpanelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,28 +582,28 @@ public void setServerURL(String serverURL) {

public Boolean getTrackAutomaticEvents() { return mTrackAutomaticEvents; }
/**
* This function creates a distinct_id alias from alias to original. If original is null, then it will create an alias
* This function creates a distinct_id alias from alias to distinct_id. If distinct_id is null, then it will create an alias
* to the current events distinct_id, which may be the distinct_id randomly generated by the Mixpanel library
* before {@link #identify(String)} is called.
*
* <p>This call does not identify the user after. You must still call {@link #identify(String)} if you wish the new alias to be used for Events and People.
*
* @param alias the new distinct_id that should represent original.
* @param original the old distinct_id that alias will be mapped to.
* @param alias the new value that should represent distinct_id.
* @param distinct_id the old distinct_id that alias will be mapped to.
*/
public void alias(String alias, String original) {
public void alias(String alias, String distinct_id) {
if (hasOptedOutTracking()) return;
if (original == null) {
original = getDistinctId();
if (distinct_id == null) {
distinct_id = getDistinctId();
}
if (alias.equals(original)) {
if (alias.equals(distinct_id)) {
MPLog.w(LOGTAG, "Attempted to alias identical distinct_ids " + alias + ". Alias message will not be sent.");
return;
}
try {
final JSONObject j = new JSONObject();
j.put("alias", alias);
j.put("original", original);
j.put("distinct_id", distinct_id);
track("$create_alias", j);
} catch (final JSONException e) {
MPLog.e(LOGTAG, "Failed to alias", e);
Expand Down