Upload source maps for React
AI wizard
Set up source map uploading automatically with our wizard by running this command in your project directory with your terminal (it also works for LLM coding agents like Cursor and Bolt):
Manual setup
- 1
Install the PostHog CLI
Required - 2
Authenticate the PostHog CLI
RequiredLog in to PostHog. This opens your browser, where you approve the login:
TerminalIf posthog-cli is already logged in on this machine, import that login instead:
TerminalThese CI providers can upload with the job's OIDC token, so you don't store a personal API key in CI.
- Logged in with
hog auth login, run this once in the repository:
Terminal- An organization admin approves the request in PostHog.
- Add the
hostandprojectIdthat hog prints toposthog.json, and add the snippet it prints to the job.
In GitHub Actions, the job needs the
id-token: writepermission:YAMLRemove any personal API key from the job. A key wins over the OIDC token.
Set these environment variables in the job:
Environment variable Description Source HOG_HOSTThe PostHog host to connect to, such as https://eu.posthog.com[default: https://us.posthog.com]Project settings HOG_PROJECT_IDPostHog project ID Project settings HOG_PERSONAL_API_KEYPersonal API key with the error_tracking:writescopeAPI key settings hog reads only the
HOG_*names. The PostHog build plugins and upload scripts still pass the oldPOSTHOG_CLI_*names to hog for now, with a warning for each one. Ahogcommand you run yourself needs theHOG_*names. The migration guide lists each rename. - 3
- 4
Inject source map
RequiredOnce you've built your application and have bundled assets, inject the context required by PostHog to associate the maps with the served code.
Terminal Verify source map injection
CheckpointConfirm source map comments are presentConfirm that the served files are injected with the correct source map comment in production in dev tools.
JavaScript- 5
Upload source map
RequiredYou will then need to upload the modified assets to PostHog.
Terminalhog creates or reuses the release for the detected or supplied release name and version. hog tries to detect the release name and version from Git and your CI provider, but you can set them explicitly with
--release-nameand--release-version. We recommend setting the release name, and letting hog detect the version, if your project is continuously deployed (the version will be the git commit hash at build time).You can also pass
--buildto add a build number (e.g.CFBundleVersionon iOS,versionCodeon Android) to the release version, as<version>+<build>. This is optional.💡 Tip: You can use the
--delete-afteroption to clean up sourcemaps after uploading them. To inject and upload in one command, usehog error-tracking process ./path/to/assets.Serve injected assets
You must serve the injected assets in deployed production app. The injected metadata is used during error capture to identify the correct source map to use. We suggest you upload source maps right after your production build in CI.
If you serve a copy of the bundled assets as they were prior to running
hog error-tracking inject, we won't be able to use the uploaded sourcemap to unminify or demangle your stack traces.





