-
Notifications
You must be signed in to change notification settings - Fork 6
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
[PostHog.js] PostHog was initialized without a token. This likely indicates a misconfiguration. #69
Comments
I am not able to reproduce this problem in local. Providing both variables using only the environment works. |
I'm using a Docker container for my Nuxt frontend. I've confirmed the running docker container contains the environment variables:
I'm a bit confused at the use of the use of non-prefixed env vars. i.e. I would have thought I'd have to use NUXT_POSTHOG_API_KEY instead of POSTHOG_API_KEY. This makes me wonder if the POSTHOG_API_KEY is injected at the time that the container is built on my development machine and not at runtime? |
The Posthog variables are picked up at build time, not runtime. That's probably why you are facing this issue. |
Yes this is definitely the issue. When I added the env vars to my Dockerfile, where the app is built, and pushed to my staging environment it worked. This seems to defeat the purpose of using Nuxt though. This is my first Nuxt project but I have many plain Vue projects deployed. I'm used to the difficulty of trying to use runtime environment variables in the production build. But Nuxt allows us to read environment variables at runtime. I feel like it would be a good idea for this library to take advantage of Nuxt 3's runtime environment by making use of I'm willing to help convert it to using runtime if you want. It looks like somewhere around line 74 in |
Should help with mitjans#69
Gave it a try here but didn't have time to test. I also noticed the same issue but in Cloudflare deployemt with Nuxt hub, didn't pick the variables at build time. |
I've just installed this module and got it working on my development environment. Pageviews, custom events, session recordings, etc. are all working.
Next, I deployed to my staging environment and I get the following console log error when the app loads:
I've confirmed that the same environment variables I used in development are configured on the staging server.
POSTHOG_API_KEY="secret"
POSTHOG_API_HOST="https://us.i.posthog.com"
When I run
env
on the staging server I see that the environment variables are active.I tried directly configuring the
posthog
node in thenuxt.config.ts
file:But that doesn't work on staging either.
Are there any other options I can try?
The text was updated successfully, but these errors were encountered: