Skip to content

Commit

Permalink
Merge pull request #808 from mixpanel/jared-remove-original
Browse files Browse the repository at this point in the history
replace original with distinct_id in alias
  • Loading branch information
jaredmixpanel authored Jan 30, 2023
2 parents cb6aa7f + 442616e commit 10e9563
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 10e9563

Please sign in to comment.