Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java SDK Update #50

Open
michaelkimball opened this issue Jan 31, 2024 · 9 comments
Open

Java SDK Update #50

michaelkimball opened this issue Jan 31, 2024 · 9 comments

Comments

@michaelkimball
Copy link

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 #45 (comment)

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
Copy link
Member

marandaneto commented Feb 1, 2024

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
Copy link
Member

Relates to PostHog/posthog#16419

@martypitt
Copy link

Hey there! Just wondering if there's any updates here? Lack of decent logging controls in posthog-java (#53) has become a problem for us.

I'd happily raise the PR to fix this, but the project seems abandoned - wondering what the best path forward is, given plans for a rewrite.

@pauldambra
Copy link
Member

👋 hey, not abandoned... but not many folks asking us for things :)

we still plan to unify things so that android and java sdks are based on the same kotlin core but it's not happened yet

@martypitt
Copy link

Thanks @pauldambra

If I were to pick up the fix for #53 and add in SLF4J instead of printing to stdout / stderr, would that:

  • Be an acceptable approach?
  • Be able to be merged / released?

@pauldambra
Copy link
Member

I'll let @marandaneto have the final say - he'll have the good feel for length of time until any kotlin switcheroo

@pauldambra
Copy link
Member

But @martypitt... it's a good 4 years since I regularly wrote java 🙈

if SLF4J is still the default totally happy to consider a PR

@marandaneto
Copy link
Member

But @martypitt... it's a good 4 years since I regularly wrote java 🙈

if SLF4J is still the default totally happy to consider a PR

SLF4J is an abstraction of logging in general so it'd work with a few of the most popular ones such as logback, log4j, java logging, etc.

@marandaneto
Copy link
Member

Thanks @pauldambra

If I were to pick up the fix for #53 and add in SLF4J instead of printing to stdout / stderr, would that:

  • Be an acceptable approach?
  • Be able to be merged / released?

Yes, the intention is that we stop using this SDK and start using this one instead.
addressing those points before though.
I did give it a try here and in the end, we have agreed to focus on something else until we have the time to do a proper refactoring and implement a stateless interface that would require a major breaking change for the Android SDK.
That said, since SLF4J is separated from the core logic of the Java SDK, I think it'd be fair to bring this in and later on just port the SLF4J bits to the Java core SDK.
Happy to review the contribution =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants