Code Monkey home page Code Monkey logo

mixpanel-java's Introduction

This is the official Mixpanel tracking library for Java.

Latest Version

May 08, 2024 - v1.5.3
<dependency>
    <groupId>com.mixpanel</groupId>
    <artifactId>mixpanel-java</artifactId>
    <version>1.5.3</version>
</dependency>

You can alternatively download the library jar directly from Maven here.

How To Use

The library is designed to produce events and people updates in one process or thread, and consume the events and people updates in another thread or process. Specially formatted JSON objects are built by MessageBuilder objects, and those messages can be consumed by the MixpanelAPI via ClientDelivery objects, possibly after serialization or IPC.

MessageBuilder messages = new MessageBuilder("my token");
JSONObject event = messages.event("[email protected]", "Logged In", null);

// Later, or elsewhere...
ClientDelivery delivery = new ClientDelivery();
delivery.addMessage(event);

MixpanelAPI mixpanel = new MixpanelAPI();
mixpanel.deliver(delivery);

Learn More

This library in particular has more in-depth documentation at

https://mixpanel.com/docs/integration-libraries/java

Mixpanel maintains documentation at

http://www.mixpanel.com/docs

The library also contains a simple demo application, that demonstrates using this library in an asynchronous environment.

There are also community supported libraries in addition to this library, that provide a threading model, support for dealing directly with Java Servlet requests, support for persistent properties, etc. Two interesting ones are at:

https://github.com/eranation/mixpanel-java
https://github.com/scalascope/mixpanel-java

Other Mixpanel Libraries

Mixpanel also maintains a full-featured library for tracking events from Android apps at https://github.com/mixpanel/mixpanel-android

And a full-featured client side library for web applications, in Javascript, that can be loaded directly from Mixpanel servers. To learn more about our Javascript library, see: https://mixpanel.com/docs/integration-libraries/javascript

This library is intended for use in back end applications or API services that can't take advantage of the Android libraries or the Javascript library.

License

See LICENSE File for details. The Base64Coder class used by this software
has been licensed from non-Mixpanel sources and modified for use in the library.
Please see Base64Coder.java for details.

mixpanel-java's People

Contributors

avram avatar ceedubs avatar danielwalker avatar dependabot[bot] avatar evanmp avatar jakobmerrild avatar jaredmixpanel avatar jensrantil avatar patedit avatar skyebook avatar yayc avatar zihejia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mixpanel-java's Issues

Full support for ip= field

This document states that HTTP API supports passing object of tracking ip address for geo segmentation. But java API supports only 0/1.

BTW, class api is badly designed, so there is no way for extension (closed members), only full rewrite. This is sad.

Improper errors/exceptions message

When you don't supply the token or the token value is given null the SDK throws exception with message mix panel Server refused to accept messages, they may be malformed which i think is very confusing. I have found (on the internet) that it also throws the same error due to some other errors as well.

It would be good and helpful to have more proper and meaningful errors for such scenarios.

I think the sendData() method could be modified to return something more diverse and meaningful.

Java library should use https by default

Given the sensitive nature of the data that is being transmitted to Mixpanel servers, https should be enabled by default. At the moment we have to use new MixpanelAPI("https://api.mixpanel.com/track", "https://api.mixpanel.com/engage") which is not ideal. If there is some reason why https can't be used by default, then a new constructor with a boolean useHttps parameter could be added instead.

Passing $email in storing user profiles gives error

Hi, I am required to have mixpanel integrate with my Grails project. When I pass $email property in JSONObject while creating the user profile it gives error. As $email property is required to send email notification from the mixpanel site.
Kindly help with some example to set $email property for user profiles so that I can send email notification.

Thanks and awaiting your reply.

No way to identify() user in Java

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!

remove $ios_devices doesn't work

Hi guys,

I want to call $remove action to remove one of users' ios devices, but it didn't work. No errors and ios devices still exists.

here is the json I sent:

{"mPeopleMessages":[{"$token":"xxxxxxx","$time":1530007209155,"$remove":{"$ios_devices":"yyyyyyyyyy"},"$distinct_id":"ccccccccc"}],"mEventsMessages":[]}

thanks

HTTP error code 408

I'm getting a bunch of these errors every once in a while:

Server returned HTTP response code: 408 for URL: http://api.mixpanel.com/track?ip=0

After I perform: mixPanelApi.deliver(delivery)

I'm just wondering if anyone else encountered this issue

No PSK available.

Hello Team we are facing an issue with mixpanel java library where we are getting the following exception "javax.net.ssl.SSLException: No PSK available." We initially thought it was a TLS issue as mentioned here https://bugs.openjdk.org/browse/JDK-8213202 and did try to update our jdk 11 to latest amazon corretto 11. But we still having issues. would you be able to help us please and its happening on random events.

Make socket timeouts configurable

Problem: Currently the socket read timeout applied in 9f945f3 is hardcoded. Two minutes is waay long for us since we are making very many small POSTs.

Request: Make timeout configurable. This should also apply to the connect timeout mentioned in #20.

Connect timeout not set

#12 only fixated a read timeout. However, a sane Java library should also set connect timeout, which defaults to infinity. Without setting it, the client risks locking up an entire application that has fixed number of threads (which most do).

See also 9f945f3.

No socket timeouts; delivery blocks forever reading response

We're seeing a reproducible bug where the delivery blocks forever trying to read (as in stacktrace below). It seems there should be a socket timeout here as a sanity check. I'll follow up with a PR doing that once I confirm it addresses this problem for us.

"pool-6-thread-15" #90 prio=5 os_prio=0 tid=0x00007f8b40c5f000 nid=0xef1 runnable [0x00007f8ae56e6000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    - locked <0x00000006af8a0438> (a java.io.BufferedInputStream)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:701)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1534)
    - locked <0x00000006af8a0460> (a sun.net.www.protocol.http.HttpURLConnection)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    - locked <0x00000006af8a0460> (a sun.net.www.protocol.http.HttpURLConnection)
    at com.mixpanel.mixpanelapi.MixpanelAPI.sendData(MixpanelAPI.java:140)
    at com.mixpanel.mixpanelapi.MixpanelAPI.sendMessages(MixpanelAPI.java:163)
    at com.mixpanel.mixpanelapi.MixpanelAPI.deliver(MixpanelAPI.java:96)
    at com.mixpanel.mixpanelapi.MixpanelAPI.deliver(MixpanelAPI.java:76)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.