PostHog / posthog-java

Official PostHog java library
MIT License
8 stars 10 forks source link

Java SDK Update #50

Open michaelkimball opened 8 months ago

michaelkimball commented 8 months ago

We're actively working on a refreshed Android SDK

When V3 of that SDK is released we plan to base the Java SDK off the same kotlin source. We'll take it out of beta at that point.

Originally posted by @pauldambra in https://github.com/PostHog/posthog-java/issues/45#issuecomment-1794600461

I see that the V3 of the Android SDK was released back in December. How is the update of this SDK going? Are we able to use this https://github.com/PostHog/posthog-android/tree/main/posthog library without Android? (https://mvnrepository.com/artifact/com.posthog/posthog I believe). If so, can the docs https://posthog.com/docs/libraries/java be updated to reflect the new usage?

marandaneto commented 8 months ago

Hi @michaelkimball

Sadly not yet since https://github.com/PostHog/posthog-android/tree/main/posthog uses local storage caching which isn't available on non-Android devices. The most important part missing is implementing in-memory caching, so events are cached in memory and sent in batches, probably a few other small changes but not much more. The other thing is context isolation, since PostHog is a static class, it works for a single-user context but not for backend apps in which each request coming in is a different user, eg calling identify on thread A cannot leak to thread B, etc (Thread-local storage or allow one single instance per thread). Those are the 2 major things that should change.

I cannot promise but I'll bring it into our Q2-24 plan, we are focused on making PostHog more mobile-friendly in Q1, stay tuned.

I'd be very happy to guide you in case you are willing to contribute and submit a PR though.

marandaneto commented 7 months ago

Relates to https://github.com/PostHog/posthog/issues/16419