zevarito / mixpanel

Simple lib to track events in Mixpanel service. It can be used in any rack based framework.
MIT License
274 stars 84 forks source link

Difficulty Tracking Charges #126

Closed gavingmiller closed 11 years ago

gavingmiller commented 11 years ago

I'm attempting to implement revenue tracking for our app and am having difficulty charging multiple users and incrementing the revenue for a single user.

I'm setting the distinct_id as the user's email address. The first call works great, but on subsequent calls the distinct_id is getting overridden, so I'm unable to have multiple users, or increment a single user's revenue. For example:

mixpanel.track_charge('gavin@petrofeed.com', amount / 100, DateTime.now)

Sets gavin@petrofeed.com in mixpanel's revenue panel. However calling the method again in a new transaction/request with a different email causes the gavin@petrofeed.com record to be overridden -or- if I call it with the same email no action occurs where I'd expect a second charge to occur.

I'm sure this is just a misunderstanding on how the track_charge interface works, and I can't find any documentation to set my thinking straight.

gavingmiller commented 11 years ago

I've tracked the issue back to having multiple users aliased to the same distinct_id. This is happening because the front end is calling the alias method multiple times creating an incorrect mapping.