Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 15, 2026

This PR attempts to address Issue #10737.

Problem

When ClineProvider is disposed (e.g., when the webview tab is closed), the WeakRef in TelemetryClient returns undefined, causing required telemetry properties (appName, appVersion, vscodeVersion, platform, editorName, language, mode) to be undefined. This results in telemetry validation errors like:

[TelemetryClient#capture] Invalid telemetry event: [
  {"code":"invalid_type","expected":"string","received":"undefined","path":["properties","appName"],"message":"Required"},
  ...
]

Solution

This fix:

  • Caches static app properties in BaseTelemetryClient when setProvider() is called
  • Uses the cached static properties as a fallback when the provider is no longer available (WeakRef returns undefined)
  • Ensures telemetry events always have the required static fields even after the ClineProvider is disposed

Changes

  • packages/cloud/src/TelemetryClient.ts: Added cachedStaticProperties field and logic to cache/use static properties
  • packages/cloud/src/tests/TelemetryClient.test.ts: Added tests for the new caching behavior

Feedback and guidance are welcome.


Important

Caches static telemetry properties in BaseTelemetryClient to prevent validation errors when provider is disposed, ensuring telemetry events remain valid.

  • Behavior:
    • Caches static telemetry properties in BaseTelemetryClient when setProvider() is called.
    • Uses cached properties if WeakRef returns undefined, ensuring required telemetry fields are present.
  • Code Changes:
    • Adds cachedStaticProperties to BaseTelemetryClient in TelemetryClient.ts.
    • Modifies getEventProperties() to use cached properties if provider is unavailable.
  • Tests:
    • Adds tests in TelemetryClient.test.ts for caching behavior and provider disposal scenarios.
    • Tests ensure telemetry events are valid even if provider is disposed and handle errors gracefully.

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

…hen provider is disposed

When ClineProvider is disposed (e.g., webview closed), the WeakRef in TelemetryClient returns undefined, causing required telemetry properties (appName, appVersion, vscodeVersion, platform, editorName) to be undefined.

This fix:
- Caches static app properties when setProvider() is called
- Uses cached properties as fallback when provider is unavailable
- Ensures telemetry events always have required fields

Fixes #10737
@roomote
Copy link
Contributor Author

roomote bot commented Jan 15, 2026

Rooviewer Clock   See task on Roo Cloud

Reviewed the telemetry caching changes. Found one issue regarding incomplete caching of required properties.

  • Dynamic properties (language, mode) are not cached but are required by the telemetry validation schema

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

Comment on lines +92 to +96
if ("appProperties" in provider) {
this.cachedStaticProperties = (
provider as TelemetryPropertiesProvider & { appProperties: StaticAppProperties }
).appProperties
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caches only static properties, but telemetryPropertiesSchema also requires language and mode from dynamicAppPropertiesSchema. When the provider is disposed, if the event's properties don't include these fields, validation at rooCodeTelemetryEventSchema.safeParse() will still fail. Consider also caching the dynamic properties, or updating the PR description to clarify this is a partial fix that only addresses static property errors.

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants