diagnosing-stacktrace-symbolication
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDiagnosing stack-trace symbolication
诊断堆栈跟踪符号化问题
Symbolication is the cross-platform name for what JavaScript source-map lookup, Hermes function-offset resolution,
Proguard / R8 demangling, and dSYM address-to-line lookup all do — turn a minified or obfuscated frame back into a
readable file, function, and line.
Work through the user's build and PostHog symbol sets as one pipeline: build config -> generated symbol artifacts
(JavaScript source maps, Hermes maps, Proguard mappings, or dSYM bundles) -> uploaded symbol set in PostHog ->
captured error frame. Most failures become obvious once those four pieces are checked in order.
符号化(symbolication)是一个跨平台术语,涵盖JavaScript源映射查找、Hermes函数偏移解析、Proguard / R8反混淆以及dSYM地址转行号等操作——其作用是将压缩或混淆的堆栈帧还原为可读的文件、函数和行号。
将用户的构建流程与PostHog符号集视为一个完整管道来排查:构建配置 → 生成的符号制品(JavaScript源映射、Hermes映射、Proguard映射或dSYM包) → PostHog中已上传的符号集 → 捕获到的错误帧。按顺序检查这四个环节后,大多数故障原因都会变得清晰。
Platforms
平台信息
| Platform | Symbol-data type | Reference |
|---|---|---|
| JavaScript / TypeScript web | source-and-map | javascript.md |
| React Native (Hermes) | hermes | coming soon |
| Android (Proguard / R8) | proguard | coming soon |
| iOS / macOS (dSYM) | apple-dsym | coming soon |
Step 3 of the workflow (symbol-set lookup in PostHog) is identical across platforms — handles all four container types. Steps 1, 2, and the platform-specific failure modes live in the
per-platform reference.
posthog-cli symbol-sets extract| 平台 | 符号数据类型 | 参考文档 |
|---|---|---|
| JavaScript / TypeScript Web | source-and-map | javascript.md |
| React Native(Hermes) | hermes | coming soon |
| Android(Proguard / R8) | proguard | coming soon |
| iOS / macOS(dSYM) | apple-dsym | coming soon |
工作流的第3步(PostHog中的符号集查找)在各平台完全一致——可处理所有四种容器类型。第1、2步以及平台特定的故障模式记录在各平台参考文档中。
posthog-cli symbol-sets extractWorkflow
排查工作流
Step 1 - Find how symbol data is produced and uploaded
步骤1 - 确定符号数据的生成与上传方式
Look at the app repo's build scripts and PostHog upload config. Confirm which PostHog package handles the upload
(, , , , or direct
) and which directory or asset it processes. See the platform reference for build-tool-specific
config inspection.
@posthog/rollup-plugin@posthog/webpack-plugin@posthog/nextjs-config@posthog/nuxtposthog-cliFor debugging, prefer a build where symbol artifacts remain on disk after upload so you can compare local
artifacts against what PostHog received. JavaScript example with the Vite plugin (the platform reference covers
the equivalent setting for other build tools):
ts
sourcemaps: {
enabled: true,
deleteAfterUpload: false,
}查看应用仓库的构建脚本和PostHog上传配置。确认负责上传的PostHog包(、、、或直接使用),以及它处理的目录或资源。请参考平台参考文档查看特定构建工具的配置检查方法。
@posthog/rollup-plugin@posthog/webpack-plugin@posthog/nextjs-config@posthog/nuxtposthog-cli为便于调试,优先选择上传后符号制品仍保留在磁盘上的构建方式,这样可以将本地制品与PostHog接收的内容进行对比。以下是Vite插件的JavaScript示例(平台参考文档包含其他构建工具的等效设置):
ts
sourcemaps: {
enabled: true,
deleteAfterUpload: false,
}Step 2 - Build and inspect local artifacts
步骤2 - 构建并检查本地制品
Run the production build that uploads symbols, then inspect the emitted files locally. The exact files and helper
invocation differ per platform — see the platform reference for the helper command, expected file shape, and common
build-time pitfalls (notably empty-mappings false positives that look like upload bugs but are actually bundler
config issues).
If local artifacts already look wrong, fix the build before debugging the PostHog upload.
运行会上传符号的生产构建,然后在本地检查生成的文件。具体文件和辅助命令因平台而异——请参考平台参考文档获取辅助命令、预期文件结构以及常见构建时问题(尤其是看起来像上传bug但实际是打包器配置问题的空映射误报)。
如果本地制品已经存在问题,请先修复构建,再调试PostHog上传流程。
Step 3 - Check symbol sets in PostHog
步骤3 - 检查PostHog中的符号集
Look up the symbol set whose matches the captured frame's using the dedicated MCP tools — they
handle auth, project scoping, and pagination automatically:
refchunk_id- with
posthog:error-tracking-symbol-sets-listreturns the matching row.ref=<chunk_id> - with the ID returns the same shape (and confirms permissions).
posthog:error-tracking-symbol-sets-retrieve - returns a one-hour presigned URL pointing at the uploaded symbol-data file. Download it immediately; do not echo the URL back unless the user explicitly asks.
posthog:error-tracking-symbol-sets-download-retrieve
If MCP access is not available, the same data is in Project settings > Error tracking > Symbol sets in the
PostHog UI.
Interpret the row:
- must match the captured frame
ref.chunk_id - updating means PostHog found and loaded that symbol set. It does not guarantee the frame resolved.
last_used - means the upload did not complete.
has_uploaded_file: false - A non-null means PostHog could not parse or load the uploaded symbol data.
failure_reason
The downloaded file is a PostHog symbol-data container (compressed Rust-encoded payload), not plain JSON. Extract
it with :
posthog-clibash
posthog-cli symbol-sets extract symbolset.bin -o ./extracted使用专用MCP工具查找与捕获帧的匹配的符号集——这些工具会自动处理认证、项目范围和分页:
refchunk_id- 搭配
posthog:error-tracking-symbol-sets-list参数可返回匹配的记录。ref=<chunk_id> - 搭配ID参数可返回相同结构的数据(并确认权限)。
posthog:error-tracking-symbol-sets-retrieve - 会返回一个指向已上传符号数据文件的1小时有效预签名URL。请立即下载该文件;除非用户明确要求,否则不要返回URL。
posthog:error-tracking-symbol-sets-download-retrieve
如果无法访问MCP,可在PostHog UI的项目设置 > 错误追踪 > 符号集中查看相同数据。
解读记录内容:
- 必须与捕获帧的
ref匹配。chunk_id - 更新意味着PostHog已找到并加载该符号集,但不保证帧已解析成功。
last_used - 表示上传未完成。
has_uploaded_file: false - 非空表示PostHog无法解析或加载已上传的符号数据。
failure_reason
下载的文件是PostHog符号数据容器(压缩的Rust编码 payload),不是纯JSON。使用提取内容:
posthog-clibash
posthog-cli symbol-sets extract symbolset.bin -o ./extractedor, without installing globally:
或者,无需全局安装:
npx @posthog/cli symbol-sets extract symbolset.bin -o ./extracted
npx @posthog/cli symbol-sets extract symbolset.bin -o ./extracted
bunx @posthog/cli symbol-sets extract symbolset.bin -o ./extracted
bunx @posthog/cli symbol-sets extract symbolset.bin -o ./extracted
`posthog-cli symbol-sets extract` handles all four symbol-set types (source-and-map, hermes, proguard, dSYM) and
writes the extracted files into the output directory. Once extracted, summarize using the platform reference's
helper.
`posthog-cli symbol-sets extract`支持所有四种符号集类型(source-and-map、hermes、proguard、dSYM),并将提取的文件写入输出目录。提取完成后,请使用平台参考文档中的辅助工具进行汇总。Step 4 - Compare local, uploaded, and served files
步骤4 - 对比本地、已上传和已部署文件
Use the failure location to decide what to compare:
- Local artifact empty and uploaded artifact empty: build tool emitted unusable symbols.
- Local artifact valid but uploaded artifact empty: upload processing selected or packed the wrong data.
- Uploaded artifact valid but production stack stays minified or obfuscated: compare deployed binary bytes to the binary that was uploaded with the symbols.
- : PostHog loaded the symbol data but the captured generated position did not match any token in the uploaded artifact. Usually points to a changed binary after upload, wrong line / column capture (JavaScript) or wrong frame offset (Hermes / dSYM), or a symbol-coverage bug.
Token not found
根据故障位置决定对比内容:
- 本地制品为空且已上传制品为空:构建工具生成了不可用的符号。
- 本地制品有效但已上传制品为空:上传处理选择或打包了错误的数据。
- 已上传制品有效但生产环境堆栈仍处于压缩或混淆状态:对比已部署二进制文件与上传符号时对应的二进制文件。
- 出现“Token not found”:PostHog已加载符号数据,但捕获到的生成位置与已上传制品中的任何token都不匹配。通常指向上传后二进制文件已更改、捕获的行/列信息错误(JavaScript)或帧偏移错误(Hermes / dSYM),或符号覆盖范围存在bug。
Step 5 - Fix the most likely layer
步骤5 - 修复最可能的问题层
Platform-neutral fixes:
- Upload symbols after the final build output exists, not before a later step rewrites it.
- Use the latest PostHog build plugin and .
posthog-cli - Re-upload changed assets intentionally when the same was previously uploaded with different content.
ref - Remove deployment-time transforms (CDN minify, edge rewrites, compression) that change the served binary after upload.
Platform-specific fixes live in the platform reference.
跨平台通用修复方案:
- 在最终构建输出生成后再上传符号,不要在后续步骤重写输出前上传。
- 使用最新版本的PostHog构建插件和。
posthog-cli - 当相同之前上传过不同内容时,主动重新上传已更改的资源。
ref - 移除部署时的转换操作(CDN压缩、边缘重写、压缩),这些操作会在上传后更改已部署的二进制文件。
平台特定修复方案请查看平台参考文档。
Captured frame checks
捕获帧检查
From an affected PostHog error event, collect one minified application frame:
filename- or
linelineno - or
columncolno function- (or platform-equivalent symbol-set ref)
chunk_id - any , especially
resolve_failureToken not found
The frame should match the deployed binary URL. The should match the symbol set . The
captured generated position should point into the same binary that was uploaded with the symbol data.
filenamechunk_idref从受影响的PostHog错误事件中,收集一个压缩的应用帧信息:
filename- 或
linelineno - 或
columncolno function- (或平台等效的符号集ref)
chunk_id - 任何,尤其是
resolve_failureToken not found
帧的应与已部署二进制文件的URL匹配。应与符号集的匹配。捕获到的生成位置应指向与符号数据一起上传的同一二进制文件。
filenamechunk_idrefFailure matrix (cross-platform)
跨平台故障矩阵
| Evidence | Likely cause | Next check |
|---|---|---|
No | Chunk ID injection missing or SDK frame parser did not map the filename | Inspect deployed binary and raw frame filenames. |
| Symbol set row missing | Upload went to another PostHog project/host or skipped this asset | Compare plugin |
| Upload did not finish | Check build logs; compare |
Non-null | PostHog could not parse the uploaded symbol data | Download via Step 3 and inspect the extracted contents. |
| Uploaded artifact valid, deployed binary differs | Deployment/CDN/post-build transform changed the binary after upload | Compare deployed bytes to local build output. |
| Captured position has no token in the uploaded symbol data | Verify captured position, deployed binary identity, and symbol-data coverage. |
Platform-specific failure modes (empty , missing , Hermes function-offset mismatch,
Proguard class-name drift, dSYM UUID mismatch) live in the platform reference.
mappingssourcesContent| 现象 | 可能原因 | 下一步检查 |
|---|---|---|
帧上没有 | Chunk ID注入缺失,或SDK帧解析器未映射文件名 | 检查已部署二进制文件和原始帧文件名。 |
| 符号集记录缺失 | 上传到了其他PostHog项目/主机,或跳过了该资源 | 对比插件的 |
| 上传未完成 | 检查构建日志;对比 |
| PostHog无法解析已上传的符号数据 | 通过步骤3下载并检查提取后的内容。 |
| 已上传制品有效,但已部署二进制文件不同 | 部署/CDN/构建后转换操作在上传后更改了二进制文件 | 对比已部署文件与本地构建输出。 |
| 出现“Token not found” | 捕获到的位置在已上传符号数据中没有对应的token | 验证捕获位置、已部署二进制文件标识以及符号数据覆盖范围。 |
平台特定故障模式(空、缺失、Hermes函数偏移不匹配、Proguard类名漂移、dSYM UUID不匹配)请查看平台参考文档。
mappingssourcesContent