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:
reading the cookie headers, checking for an existing PH cookie and grabbing the distinct_id from there.
generate a new v4 uuid() if there is no PH header present (the phone did not visit our main landing page before) and write it into a cookie via Set-Cookie header which the client side PostHog then picks up and continues to use when the phone visits our domain.com.
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
export the generateUUID function to reuse it
export a method to construct the cookie payload
export a method to parse a PH cookie payload
Related sub-libraries
[ ] All of them
[ ] posthog-web
[x] posthog-node
[ ] posthog-react-native
Additional context
Thank you for your feature request – we love each and every one!
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:
distinct_id
from there.domain.com
.All that works great!
I noticed that ph uses this
generateUUID
function but does not export it on theposthog-node
package. The anonymous uuids seem to share a common prefix081b
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
generateUUID
function to reuse itRelated sub-libraries
Additional context
Thank you for your feature request – we love each and every one!