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 and organization read scopes. 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.
PostHog is an all-in-one developer platform for building successful products. We provide product analytics, web analytics, session replay, error tracking, feature flags, experimentation, surveys, LLM analytics, data warehouse, a CDP, and an AI product assistant to help debug your code, ship features faster, and keep all your usage and customer data in one stack.