davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`alias` method should accept 2 params

derekmisler opened this issue · comments

Mixpanel's documentation show 2 params for the alias method, for associating pre-identification events with an existing user:
https://developer.mixpanel.com/docs/javascript-full-api-reference#section-mixpanel-alias

Example:

mixpanel.alias('new_id', 'existing_id');

Currently, the createAlias and alias methods of this package only allows a single param:

createAlias(alias: string) {
  if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR)
  defaultInstance.alias(alias)
}

// and

alias(alias: string): Promise<void> {
  if (!this.initialized) throw new Error(uninitializedError('createAlias'))
  return RNMixpanel.createAlias(alias, this.apiToken)
}

The issue with defaulting to the distinctId (as seen here), is that Mixpanel creates a new distinctId for every pre-identified user, which prevents tracking across devices.

I'm proposing we add support for the second alias param.

@derekmisler Could you test "react-native-mixpanel": "github:lorenc-tomasz/react-native-mixpanel#1.1.12", please?

PR: #207

YES. Thank you, @lorenc-tomasz, that worked!