Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Dec 10, 2025

Summary

This PR adds app version tracking to PostHog exception captures and filters out billing-related (402) errors.

Changes

1. Added 402 to EXPECTED_API_ERROR_CODES

  • Added 402 (Payment required - billing issues) to the set of expected API error codes
  • 402 errors will now be filtered out from telemetry reports (same as 429 rate limit errors)

2. Made appVersion a required property in captureException

  • Updated TelemetryClient interface to require appVersion parameter in captureException
  • Updated all implementing classes (PostHogTelemetryClient, CloudTelemetryClient, BaseTelemetryClient)
  • TelemetryService now stores appVersion (set once during extension activation) and automatically passes it to all clients
  • PostHogTelemetryClient includes it as $app_version property in exception reports sent to PostHog

3. Callers don't need to change

The existing callers like openrouter.ts continue to work unchanged:

TelemetryService.instance.captureException(error, { provider, modelId, operation })

The TelemetryService handles passing the appVersion automatically.

Test Plan

  • All existing tests pass
  • Added new tests for shouldReportApiErrorToTelemetry and EXPECTED_API_ERROR_CODES
  • Updated PostHogTelemetryClient tests for the new signature

Related Issues

N/A


Important

Add app version to exception captures and filter out 402 errors in telemetry reporting.

  • Behavior:
    • Add 402 to EXPECTED_API_ERROR_CODES in telemetry.ts to filter out billing-related errors from telemetry.
    • Update captureException in PostHogTelemetryClient to include appVersion in exception reports.
  • Interfaces:
    • Modify TelemetryClient interface in telemetry.ts to require appVersion in captureException.
  • Tests:
    • Add tests for shouldReportApiErrorToTelemetry and EXPECTED_API_ERROR_CODES in telemetry.test.ts.
    • Update PostHogTelemetryClient.test.ts to test new captureException behavior with appVersion.

This description was created by Ellipsis for 87aab92. You can customize this summary. It will automatically update as commits are pushed.

The processFinishReason() method was clearing rawChunkTracker immediately after
emitting tool_call_end events. However, Task.ts doesn't process these events in
the main streaming loop - they're only processed via the fallback mechanism in
finalizeRawChunks().

This caused MCP tools to never be converted from tool_use to mcp_tool_use type,
resulting in 'unknown tool' errors.

The fix removes the redundant clear() call from processFinishReason(). The tracker
is still properly cleared by:
1. finalizeRawChunks() - after processing remaining tools (line 180)
2. clearRawChunkState() - when a new API request starts
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Dec 10, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 10, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. All issues have been resolved.

  • Interface/implementation mismatch: captureException implementations return Promise<void> but the TelemetryClient interface declares void
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 10, 2025
… errors

- Add appVersion as required parameter in captureException across TelemetryClient interface
- TelemetryService stores appVersion (set once at activation) and automatically passes it to all clients
- PostHogTelemetryClient includes $app_version in all exception reports sent to PostHog
- Add 402 (payment required) to EXPECTED_API_ERROR_CODES to filter out billing-related errors
- Add tests for shouldReportApiErrorToTelemetry and updated captureException tests
@daniel-lxs daniel-lxs force-pushed the feat/telemetry-appversion-402-filter branch from 8f5e243 to 02003f7 Compare December 10, 2025 21:20
# Conflicts:
#	packages/telemetry/src/PostHogTelemetryClient.ts
#	packages/types/src/__tests__/telemetry.test.ts
@cursor
Copy link
Contributor

cursor bot commented Dec 10, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 17.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 10, 2025
@cte cte merged commit 1cf6ae6 into main Dec 10, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Dec 10, 2025
@cte cte mentioned this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants