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 directoryYes Directory containing built assets (for example, dist)env-idYes PostHog project ID. Get it from your project settings cli-tokenYes Personal API key with error tracking write scope. Get it from your personal API key settings projectNo Project identifier. Defaults to the Git repository name when available versionNo Release/version (for example, commit SHA). Defaults to current commit SHA when available hostNo PostHog host URL. Defaults to https://us.posthog.com. For EU cloud, set it tohttps://eu.posthog.comWe recommend storing
env-idandcli-tokenin GitHub Secrets (for example,POSTHOG_ENV_IDandPOSTHOG_CLI_TOKEN). - 4
Serve injected assets
RequiredYou must deploy the injected build artifacts to production. PostHog reads the injected
chunkIdmetadata 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.