fix(analytics): stabilize the wizard's own exception stack frames - #1274
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
posthog-node rewrites every stack frame path to be relative to process.cwd(). The wizard runs from the user's project directory while its bundle lives in an npx / dlx / bunx cache, so a single frame reaches error tracking under a different path for nearly every run, and the same failure is filed as a new issue per path shape. Frames inside a package cache are also never marked in_app, although the bundle is the application. before_send now re-anchors our own frames to the package root, drops the rolldown content hash, and marks them in_app. Every other frame is untouched. Generated-By: PostHog Desktop Task-Id: 45957cb9-8ed1-4349-858a-286e288fe5d5
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
posthog-nodere-anchors every frame toprocess.cwd(), but the wizard runs from the user's project while its bundle sits in an npx/dlx/bunx cache. Issues line up one-to-one with path shape:dist/bin.js019e8427.npm/_npx/H/…/dist/bin.js019e6539../.npm/_npx/H/…/dist/bin.js019e661d../../.npm/_npx/H/…/dist/bin.js019e2aa2../../../.npm/_npx/H/…/dist/bin.js019e2ab0../../../../.npm/_npx/H/…/dist/bin.js../depth, home directory, drive letter and cache hash.in_app: false(23434 vs 1472), because the shipped bundle always lives undernode_modules.Note
The report's proposed fix — adding
posthog-cli sourcemapupload topublish.yml— is not implemented here, because it cannot work. That flow matches symbol sets by an injectedchunkId, andposthog-nodeemits nochunk_idon frames (verified in the SDK through the latest 5.52.4: the only frame modifiers shipped arecontext-lines,moduleandrelative-path). Uploading maps would produce symbol sets nothing ever matches.Changes
before_send, so one line of code has one identity on every machine.in_app: true— this bundle is the application.node:internals,ink,react-reconciler) is left untouched.Test plan
src/utils/__tests__/exception-frames.test.ts: path rewriting, hash stripping, cwd-independence, non-wizard frames untouched, frameless exceptions.analytics.test.tscovering thebefore_sendwiring.eslintandprettierclean on touched files;pnpm typecheckreports 31 errors before and after this change (all pre-existing, in untouched files).import.meta.urlsurvives bundling intodist/analytics-*.js, and resolves to the package root.Agent context
posthog/ai-gateway, a Go service with no npm publish, notsdownand nosrc/utils/analytics.ts. The described code is all in this repo, so the fix landed here.chunk_idin the SDK.in_appare correct regardless, and path shape is what the data correlates with. Expect the collapse to show up in new issues; existing ones are already minted.enableExceptionAutocapture, and theReact is not definedstartup crash already covered by a draft PR.Created with PostHog Desktop from this inbox report.