Upload source maps for Vite
- 1
Install the PostHog Rollup plugin
RequiredVite uses Rollup under the hood, so you can use the PostHog Rollup plugin:
Terminal - 2
Add PostHog plugin to your Vite config
RequiredAdd the following to your
vite.config.jsfile:vite.config.jsWhere you should set the following environment variables:
Environment Variable Description POSTHOG_API_KEYPersonal API key with at least writeaccess onerror trackingPOSTHOG_ENV_IDProject ID you can find in your project settings POSTHOG_HOST(optional) Your PostHog instance URL. Defaults to https://us.i.posthog.comIf you are using a CI/CD service, make sure these environment variables are added to your project settings, not just your local setup. This enables source maps to be automatically uploaded on your production build.