davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking
MIT License
455 stars 195 forks source link

Multiple Mixpanel instances #122

Open StevePotter opened 6 years ago

StevePotter commented 6 years ago

Hey all, I have a situation where we have to log events to 2 mixpanel projects at once. In case you are wondering, the reason is our old mixpanel system got mangled over the years and we are starting a fresh one for our marketing team.

Anyway, we use this wonderful package in our app but it is limited to a single mixpanel instance. I think with a little work, multiple mixpanel instances could be supported. I was thinking that the API could work like this: Normal:

Mixpanel.sharedInstanceWithToken(YOUR_PROJECT_TOKEN)

Multiple instances:

Mixpanel.sharedInstanceWithToken(YOUR_PROJECT_TOKEN)
Mixpanel.namedInstanceWithToken('second',YOUR_SECOND_PROJECT_TOKEN)

Then you could specify the instance in each event like so:

Mixpanel.track('Event name', 'second')

This is a rare use case, I know. But it's the situation I'm in and I would love to make it available to people and avoid using a fork forever. If I created the PR and everything was tight, is this something you would consider? Thanks!

davide-scalzo commented 6 years ago

@StevePotter that's awesome!