PostHog / posthog-js-lite

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

Expose distinct UUID generation and parser/constructor for cookie payload #126

Open joernroeder opened 1 year ago

joernroeder commented 1 year ago

Is your feature request related to a problem?

I'd love to hand out one URL domain.com/download-app to send users to the android and apple stores by having a dynamic redirect depending on the user agent visiting that page in place — of course I'd love to track this event in PostHog.

Initiating the client inside a lambda function is straight forward, there are two things I'm doing manually right now:

All that works great!

I noticed that ph uses this generateUUID function but does not export it on the posthog-node package. The anonymous uuids seem to share a common prefix 081b in my case, which differs from what the v4 uuids are looking which I am generating (via uuid).

Also parsing and constructing the cookie myself feels error prone, exposing those three building blocks from the lib would make this future proof.

Describe the solution you'd like

Related sub-libraries

Additional context

Thank you for your feature request – we love each and every one!

marandaneto commented 8 months ago

@joernroeder we use the uuidv7() method now. would you like to contribute with a PR exposing the construct and parse of cookies?