mixpanel / mixpanel-java

Other
49 stars 37 forks source link

No way to identify() user in Java #1

Closed sguergachi closed 11 years ago

sguergachi commented 11 years ago

I'm currently using this API for a java desktop app, however I haven't found any way to attach a user profile or some String identifier that replaces the Guest numbers we see on the dashboard to show up in the People data.

Any way for us to easily implement this into the current API?

Thanks!

joeatwork commented 11 years ago

Hi! The pure Java library is designed to support applications that may interact with many users at a time, and applications that may be spread across multiple JVMs and servers. As a result, we don't support calls that set library state associated with individual users, like identify() and register() in the Javascript library.

This means you'll need to manage the distinctId of your user yourself. However, if you only have one user associated with each instance of your application, this may be as simple as setting a single value when you start up, either by using some persistent login identifier, or just java.util.UUID.randomUUID().toString() if you're only interested in users for a single run of your program.

Once you've set up a distinct id, you can use it both for calls to MessageBuilder.event() and MessageBuilder.set() - if you use the same id in both places, you should see the events show up in the user activity feed.