Error tracking enables you to view the stack trace and code context associated with an exception. This can help understand, identify and resolve the root cause of an issue.
For languages like Python, the stack trace and code context can be gathered by the PostHog client and requires no additional processing.


Symbol sets
Compiled or minified languages requires additional information to perform a process called symbolification to produce the same stack trace and code context output shown above. The additional information is known as a symbol set.
The source
of a frame in the exception stack trace should point to the minified code of your application which should contain the sourceMappingUrl
parameter denoting the location of the source map. These files must either be publicly accessible for PostHog to fetch or uploaded manually to symbolify the stack trace.
You can see the symbol sets fetched by PostHog and the associated frames within the error tracking settings. Any missing symbol sets will also be present along with the failure reason. From here, you can also manually upload missing symbol sets or replace existing ones.


Uploading source maps
If your source maps are not publicly hosted, you will need to upload them during your build process to see unminified code in your stack traces, the posthog-cli
handles this process.
Download
Install posthog-cli and upgrade to latest version
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/PostHog/posthog/releases/download/posthog-cli-v0.0.5/posthog-cli-installer.sh | shposthog-cli-update
Authenticate
To authenticate the CLI you can call the login
command and follow the instructions:
posthog-cli login
If you are using the CLI in a CI/CD environment such as GitHub Actions you can set environment variables to authenticate. POSTHOG_CLI_ENV_ID
and POSTHOG_CLI_TOKEN
should be the number in your PostHog homepage URL and a personal API key respectively.
Use --host option in subsequent commands to specify a different PostHog instance / or region. For EU users:
posthog-cli --host https://eu.posthog.com [CMD]
Inject
Once you've built your application and have bundled assets that serve your site, inject the context required by PostHog to associate the maps with the served code. You will then need to upload the modified assets to PostHog, and ensure that the modified asset bundles are the ones you're serving - if you serve a copy of the bundled assets as they were prior to running posthog-cli sourcemap inject
, we won't be able to use the uploaded sourcemap to unminify or demangle your stack traces.
# Inject metadata in files to resolve errorsposthog-cli sourcemap inject --directory ./path/to/assets
Upload
# Upload assets to posthogposthog-cli sourcemap inject --directory ./path/to/assets