PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
69 stars 36 forks source link

swapping posthog-js and posthog-js-lite #183

Open pauldambra opened 9 months ago

pauldambra commented 9 months ago

When building the toolbar we use shared code from the main posthog app

But we never want to allow posthog-js in the toolbar, just posthog-js-lite

You can't always swap one-for-one because you can't import { posthog } from posthog-js-lite

it'd be cool if you could

fromaline commented 7 months ago

@pauldambra, hi! Sorry, maybe it's the wrong place to ask this question, but can I replace posthog-js with posthog-js-lite on the web in production right now?

I only use posthog.identify and posthog.capture, so the "minimal API" from the readme seems enough. I tested already, and it seems to work as expected with no issues. The only thing I had to change is how I import posthog, exactly like you said in your comment 👆

pauldambra commented 7 months ago

hey @fromaline yep, we use it in the toolbar... so it should be completely fine

this issue was only about the mismatch in exports that means you can't always swap with no code changes

fromaline commented 7 months ago

@pauldambra, got it! Thanks for answering! PostHog is great tool 👍

fromaline commented 6 months ago

Hey @pauldambra! Does posthog-js-lite no longer record the Device Type property? It seems to work in regular posthog-js.

pauldambra commented 6 months ago

Hey, It's best to go through the in-app support flow or ask new questions rather than comment on different issues 😊

posthog-js-lite is a subset of posthog-js - you can see what it gathers here https://github.com/PostHog/posthog-js-lite/blob/e5ccc75f49435e7cf307f9e515aebef79dcc3f8a/posthog-web/src/context.ts#L4

Best to run through the support flow saying what you're observing and what you expect or open a new issue here if you think there's a bug 🙏

joaovpmamede commented 5 months ago

@pauldambra so currently there's no way of enabling toolbar with posthog-js-lite, correct? Is that something that will be added in the near future?

pauldambra commented 5 months ago

hey @joaovpmamede, no... posthog-js-lite is a super stripped down library for folk that need to prioritise bundle size over functionality. if we add functionality to it then it's no longer `lite' 😊

fromaline commented 5 months ago

@pauldambra, thanks for answering my question! Initially, I missed it

joaovpmamede commented 5 months ago

@pauldambra got it and I really appreciate the work on the "lite" version. We're playing with it exactly because we'd like a smaller bundle size but now we were requested to have heatmaps and that seems to be only possible with the toolbar.

pauldambra commented 5 months ago

yep, that's posthog-js only 👍