Stack traces

Last updated:

|Edit this page

On this page

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.

Stack traces example

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.

Symbol set examples

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

Terminal
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/PostHog/posthog/releases/download/posthog-cli-v0.0.5/posthog-cli-installer.sh | sh
posthog-cli-update

Authenticate

To authenticate the CLI you can call the login command and follow the instructions:

Terminal
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:

Terminal
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.

Terminal
# Inject metadata in files to resolve errors
posthog-cli sourcemap inject --directory ./path/to/assets

Upload

Terminal
# Upload assets to posthog
posthog-cli sourcemap inject --directory ./path/to/assets

Questions? Ask Max AI.

It's easier than reading through 635 docs articles.

Community questions

Was this page useful?

Next article

Error monitoring and issue management

Errors are captured as $exception events which means that you can create insights, filter recordings, trigger surveys, and more in the same way you can for any other type of event. Issue list In addition to using events in insights, replays, and surveys as mentioned above customers can also visit the error tracking page . Exceptions are grouped by type, each with aggregated counts and sparklines providing an indication of the severity of each group. You can also search for exceptions…

Read next article