feat(error-tracking): add selectable MCP event context - #71111
Conversation
Add an include parameter for compact, opt-in error event context groups, including stack traces, code variables, releases, and diagnostics. Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
|
Hey @hpouillot! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
🤖 CI report✅ Bundle size — no changeUncompressed size of every built Total: 64.77 MiB · no change No file changed by more than 1000 B. Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report ✅ Eager graph — within budgetHow much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy
🟢 Largest files eagerly shipped from
|
| Size | File |
|---|---|
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 24.6 KiB | ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js |
| 6.3 KiB | ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js |
| 4.5 KiB | ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js |
| 3.9 KiB | ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js |
| 1.4 KiB | ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js |
| 1.3 KiB | src/RootErrorBoundary.tsx |
| 912 B | ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js |
| 789 B | src/scenes/ChunkLoadErrorBoundary.tsx |
| 762 B | src/index.tsx |
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 281.3 KiB | ../node_modules/.pnpm/posthog-js@1.402.3/node_modules/posthog-js/dist/rrweb.js |
| 267.7 KiB | ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 235.5 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 222.9 KiB | ../node_modules/.pnpm/posthog-js@1.402.3/node_modules/posthog-js/dist/module.js |
| 164.0 KiB | src/queries/validators.js |
| 154.3 KiB | ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js |
| 126.8 KiB | ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js |
| 105.8 KiB | src/lib/api.ts |
| 93.3 KiB | ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js |
| 92.7 KiB | ../packages/quill/packages/quill/dist/index.js |
Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479
✅ Dist folder size — no change
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1312.70 MiB · no change
ℹ️ MCP UI apps size — 31 app(s), 16561.5 KB JS
Built size of each MCP UI app (main.js + styles.css).
| App | JS | CSS |
|---|---|---|
| debug | 598.2 KB | 179.2 KB |
| action | 456.5 KB | 179.2 KB |
| action-list | 563.0 KB | 179.2 KB |
| cohort | 455.4 KB | 179.2 KB |
| cohort-list | 562.0 KB | 179.2 KB |
| email-template | 455.3 KB | 179.2 KB |
| error-details | 471.1 KB | 179.2 KB |
| error-issue | 456.1 KB | 179.2 KB |
| error-issue-list | 562.9 KB | 179.2 KB |
| experiment | 560.1 KB | 179.2 KB |
| experiment-list | 563.8 KB | 179.2 KB |
| experiment-results | 561.8 KB | 179.2 KB |
| feature-flag | 565.8 KB | 179.2 KB |
| feature-flag-list | 569.5 KB | 179.2 KB |
| feature-flag-testing | 459.4 KB | 179.2 KB |
| insight-actors | 560.8 KB | 179.2 KB |
| invite-email-preview | 454.7 KB | 179.2 KB |
| llm-costs | 558.1 KB | 179.2 KB |
| session-recording | 457.2 KB | 179.2 KB |
| session-summary | 462.5 KB | 179.2 KB |
| survey | 457.0 KB | 179.2 KB |
| survey-global-stats | 560.9 KB | 179.2 KB |
| survey-list | 563.7 KB | 179.2 KB |
| survey-stats | 560.8 KB | 179.2 KB |
| trace-span | 455.8 KB | 179.2 KB |
| trace-span-list | 562.9 KB | 179.2 KB |
| workflow | 455.8 KB | 179.2 KB |
| workflow-list | 562.4 KB | 179.2 KB |
| query-results | 743.7 KB | 179.2 KB |
| render-ui | 824.0 KB | 179.2 KB |
| visual-review-snapshots | 460.3 KB | 179.2 KB |
⚠️ Backend coverage — 98.0% of changed backend lines covered — 1 uncovered
🧪 Backend test coverage
Patch coverage — changed backend lines (products + core): ████████████████████ 98.0% (91 / 92)
| File | Patch | Uncovered changed lines |
|---|---|---|
products/error_tracking/backend/presentation/views/query.py |
94.1% | 195 |
🤖 Agents: add a test covering the lines above, or note why under "How did you test this code?". Machine-readable gap list: the patch-coverage artifact on this run (gh run download 29489137408 -n patch-coverage), or the coverage-data block at the end of this comment.
Per-product line coverage (touched products)
| Product | Coverage | Lines |
|---|---|---|
demo |
███████████░░░░░░░░░ 56.2% |
1,497 / 2,663 |
tasks |
█████████████░░░░░░░ 67.4% |
25,785 / 38,250 |
signals |
████████████████░░░░ 79.1% |
19,033 / 24,073 |
data_modeling |
████████████████░░░░ 80.0% |
4,834 / 6,045 |
cdp |
████████████████░░░░ 80.7% |
3,118 / 3,864 |
notebooks |
█████████████████░░░ 84.3% |
6,343 / 7,520 |
agent_platform |
█████████████████░░░ 84.7% |
3,273 / 3,862 |
cohorts |
█████████████████░░░ 86.1% |
4,022 / 4,671 |
actions |
█████████████████░░░ 86.6% |
717 / 828 |
product_tours |
█████████████████░░░ 87.5% |
1,266 / 1,447 |
exports |
██████████████████░░ 88.3% |
6,891 / 7,800 |
conversations |
██████████████████░░ 88.9% |
16,129 / 18,133 |
dashboards |
██████████████████░░ 89.1% |
5,719 / 6,418 |
mcp_analytics |
██████████████████░░ 89.1% |
2,502 / 2,807 |
error_tracking |
██████████████████░░ 89.6% |
9,790 / 10,925 |
alerts |
██████████████████░░ 89.9% |
3,638 / 4,046 |
engineering_analytics |
██████████████████░░ 90.1% |
5,105 / 5,665 |
streamlit_apps |
██████████████████░░ 90.4% |
2,499 / 2,764 |
slack_app |
██████████████████░░ 90.6% |
9,511 / 10,503 |
marketing_analytics |
██████████████████░░ 90.8% |
11,514 / 12,684 |
product_analytics |
██████████████████░░ 91.1% |
5,599 / 6,143 |
data_warehouse |
██████████████████░░ 92.1% |
18,133 / 19,683 |
workflows |
██████████████████░░ 92.4% |
5,148 / 5,574 |
web_analytics |
███████████████████░ 92.7% |
13,624 / 14,691 |
ai_observability |
███████████████████░ 92.8% |
14,868 / 16,019 |
surveys |
███████████████████░ 92.9% |
5,687 / 6,120 |
posthog_ai |
███████████████████░ 93.2% |
1,322 / 1,418 |
approvals |
███████████████████░ 93.3% |
3,395 / 3,640 |
reminders |
███████████████████░ 93.4% |
468 / 501 |
early_access_features |
███████████████████░ 93.8% |
848 / 904 |
endpoints |
███████████████████░ 94.1% |
8,606 / 9,143 |
skills |
███████████████████░ 94.4% |
2,827 / 2,995 |
revenue_analytics |
███████████████████░ 94.5% |
3,598 / 3,809 |
review_hog |
███████████████████░ 94.6% |
6,532 / 6,905 |
logs |
███████████████████░ 95.3% |
9,528 / 9,994 |
experiments |
███████████████████░ 95.6% |
24,179 / 25,296 |
replay_vision |
███████████████████░ 95.7% |
13,354 / 13,952 |
annotations |
███████████████████░ 96.2% |
732 / 761 |
feature_flags |
███████████████████░ 96.3% |
16,118 / 16,741 |
warehouse_sources |
███████████████████░ 96.3% |
238,151 / 247,341 |
user_interviews |
███████████████████░ 96.4% |
2,242 / 2,325 |
data_catalog |
███████████████████░ 97.1% |
2,034 / 2,095 |
customer_analytics |
███████████████████░ 97.2% |
7,480 / 7,698 |
Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.
⚠️ MCP snapshots — 1 updated (1 modified, 0 added, 0 deleted)
Snapshots: MCP unit test snapshots updated
Changes: 1 snapshots (1 modified, 0 added, 0 deleted)
What this means:
- Snapshots have been automatically updated to match current output
Next steps:
- Review the changes to ensure they're intentional
- If unexpected, investigate what caused the output to change
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
🦔 Hogbox preview · ❌ build failedThe preview didn't come up for commit |
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
|
Reviews (1): Last reviewed commit: "feat(error-tracking): improve event corr..." | Re-trigger Greptile |
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
Generated-By: PostHog Code Task-Id: 919fa31e-4c0b-49ec-9756-9780156138b9
| ], | ||
| "release": ["properties.$exception_releases"], | ||
| "navigation": ["properties.$current_url", "properties.$screen_name", "properties.$referrer"], | ||
| "correlation": [ |
There was a problem hiding this comment.
adding few ids to link with other resources
| columns = [str(column) for column in raw_columns] if isinstance(raw_columns, list) else event_selects | ||
| raw_results_value = data.get("results") | ||
| raw_results: list[object] = raw_results_value if isinstance(raw_results_value, list) else [] | ||
| verbosity = cast(str, params.get("verbosity", "summary")) |
There was a problem hiding this comment.
Dropping the verbosity param in favor of include. It won't be backward compatible but this endpoint is only used by agents from what I saw
cat-ph
left a comment
There was a problem hiding this comment.
coooool 🔥 I like this quite a bit more than the 'verbosity' levels! 😬 few comments but looks great!
| ], | ||
| "release": ["properties.$exception_releases"], | ||
| "navigation": ["properties.$current_url", "properties.$screen_name", "properties.$referrer"], | ||
| "correlation": [ |
| "properties.$exception_values", | ||
| "properties.$exception_list", | ||
| "properties.$exception_fingerprint", | ||
| "properties.$exception_issue_id", |
There was a problem hiding this comment.
I know I also added this but thinking out loud whether it's still that useful now with auto-merge and more volatile issue IDs changing, or it might confuse agents 🤔 but I'd err to keeping it, the more context the better 😆
should we also add $exception_level and maybe $exception_handled? 🤔
There was a problem hiding this comment.
Good point, I think we can remove it. The events are queried for a specific issue_id, if it's not the same it will be confusing 🫨 I'll add level and handled props as well 👍
| "properties.$session_id", | ||
| "properties.$trace_id", | ||
| "properties.$ai_trace_id", | ||
| "properties.$span_id", |
There was a problem hiding this comment.
I thought we use $ai_span_id? 🤔 or is this for traces separately from AIO? I looked at our project and we don't have $trace_id / $span_id in the taxonomy, but there is $ai_span_id
There was a problem hiding this comment.
I think trace_id is for tracing and ai_trace_id is for llma but I'll double check
There was a problem hiding this comment.
Good catch, It wasn't the case 😄 I added it here: PostHog/posthog-python#743
We can rollout $trace_id and $span_id in other SDKs as well, if there are not attached the property won't be returned
There was a problem hiding this comment.
nice! thanks for adding it 💙
Problem
Agents need enough error-event context to debug issues without receiving a large exception payload on every request. Stack traces, code variables, release details, and ingestion diagnostics should be available explicitly when needed.
Changes
includeparameter toquery-error-tracking-issue-eventswith compact context groups.How did you test this code?
ruff checkpasses for the changed Python files.hogli build:openapicompletes and regenerates the frontend and MCP artifacts.pnpm --filter=@posthog/mcp lint-tool-namespasses.hogli ci:preflight --strictpasses.@posthog/quilland@posthog/quill-chartspackages unrelated to this change.👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
The MCP tool prompt documents the selectable context groups and the sensitive-data considerations for code variables.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Codex implemented a narrow, backward-compatible extension to the existing issue-events endpoint rather than introducing a new event response shape. The existing
verbosityparameter remains supported for raw payload compatibility, whileincludecontrols which context groups are queried and returned. Code variables remain excluded unless explicitly requested throughinclude, except for legacy callers already requesting stack or raw verbosity without the new parameter.Created with PostHog Code