Posthog provider doesn't seem to work with railway
I have a frontend that uses posthog for its analytics. I used to have this whole project hosted elsewhere and everything worked perfectly. However, it does not seem to work on railway.
I am defining my provider with
(this is React + Vite, setup very similar to the template; but not exaclty the same)
What this should do, is send all analytic requests to posthog. But I don't see any requests being made in the network. Normally, I would then have
In a
Caddyfile
to actually handle that redirect. And this used to work. But it doesn't on railway. For some reason.
I have tried to also not do this redirect thing btw, and just send request directly to posthog. However, it doesn't change anything.
I have tried on both the new proxy and not. I have tried adding the handle_path to multiple locations (reverse proxy and frontend file server). I am not sure how to solve.
Hopefully someone knows something that might help. And if not a direct tribal knowledge, at least tips on how to debug this would help π
project id: 1b326884-0c17-43ed-9b52-f443662e8f5014 Replies
Project ID:
1b326884-0c17-43ed-9b52-f443662e8f50
so let me get this straight, this would be a network request the user's browser makes?
Yea
so basically the same kinda thing as calling Google analytics
Yea. Basically. If you have never heard of posthog, it is an analytics tool. 100x better than google analytics.
can you send a link to your site where it should be making a call to posthog or your ingest endpoint
The site as a whole makes requests automagically. It was before I switched to railway.
It triggers on events like loading a page or clicking a button. I mean you can add extra events and data. But there isn't any here. And there is also session replays. So simply being on the site, you should normally see regular outbound requests to
/ingest
. It would normally be to just us.posthog. Similar to how google analytics works. But it goes to /ingest
to be able to be internally routed and prevent common analytic blocking.
I did try to send the requests directly. But for some unknown (unknown to me) reason, posthog is just not trying to make any requests.so is your frontend even making a call to /ingest as of right now?
No. It does not seem to be
Hmmmm. I actually wonder something :hmmmm:
Going to have to test out something later. I will report back later
would it make a call to /ingest locally?
Local as in CLI local? Or just local dev. Local dev, it does. But technically speaking, my local deploy is a different process (docker compose). So there are a few possible mixed wires going on. I have a few more rocks to flip over. If they all don't work, I will be back. But for now, I can try a few more things
sounds good!
best advice i can give would be to run your app locally as close as to how it would be ran on railway to see if you can reproduce locally
The biggest thing I can't replicate, is the private network. But yea, there are a few other little differnce between the two. So I will just bring down all of the debug stuff and see if actually makes a difference. But another thing I need to test, is environment variable stuff. Becuase I know these tools (Vite) can be picky sometimes. Although, like I said, it did used to work before. But, to be fair, railway wasn't the only change
The biggest thing I can't replicate, is the private networksure you can!
http://127.0.0.1:3000