Upload source maps with GitHub Actions
- 1
Prerequisites
RequiredUploading source maps with GitHub Actions requires your build to have already generated source maps. This action does not build your project, it only injects source map metadata into the built files and uploads them to PostHog. Make sure to run your production build first (for example,
npm run build
). - 2
Use the GitHub action
RequiredAdd a workflow step to run the PostHog upload action after your build:
YAMLThis step:
- Injects a
//# chunkId=...
comment into your built source files so PostHog can match them with uploaded source maps - Uploads the source maps to your PostHog project
- Injects a
- 3
Inputs
Reference for action configurationName Required Description directory
Yes Directory containing built assets (for example, dist
)env-id
Yes PostHog project ID. Get it from your project settings cli-token
Yes Personal API key with error tracking write scope. Get it from your personal API key settings project
No Project identifier. Defaults to the Git repository name when available version
No Release/version (for example, commit SHA). Defaults to current commit SHA when available host
No PostHog host URL. Defaults to https://us.posthog.com
. For EU cloud, set it tohttps://eu.posthog.com
We recommend storing
env-id
andcli-token
in GitHub Secrets (for example,POSTHOG_ENV_ID
andPOSTHOG_CLI_TOKEN
). - 4
Serve injected assets
RequiredYou must deploy the injected build artifacts to production. PostHog reads the injected
chunkId
metadata during error capture to resolve stack traces. If you deploy files that were not processed by the action, uploaded source maps cannot be used to unminify your stack traces.