Skip to content

Conversation

@markijbema
Copy link
Contributor

Summary

Track when a suggestion is shown to the user for the first time. This helps count only the requests that were actually displayed to users.

Changes

  • Add AUTOCOMPLETE_UNIQUE_SUGGESTION_SHOWN to TelemetryEventName enum in packages/types/src/telemetry.ts
  • Add captureUniqueSuggestionShown method to AutocompleteTelemetry class
  • Track shown suggestions using a Set with text+prefix+suffix as key
  • Integrate tracking in GhostInlineCompletionProvider for both cache hits and LLM responses
  • Add comprehensive tests for the new telemetry event

Event Properties

  • languageId: The programming language of the file
  • modelId: The model used for the suggestion
  • provider: The provider used for the suggestion
  • suggestionLength: Length of the suggestion text
  • source: Either "llm" (new from LLM) or "cache" (retrieved from cache)

Testing

  • All 8 new tests pass
  • Covers first-time capture, duplicate filtering, different suggestions, prefix/suffix variations, empty suggestions, and source tracking

@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2025

⚠️ No Changeset found

Latest commit: 52c8179

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@markijbema
Copy link
Contributor Author

To do this properly is hard, and we decided to let it go for now, and instead use at telemetry which is correct, even though it means missing the conceptual 'acceptance rate' as experienced by the end-user of autocomplete

Track when a suggestion is shown to the user for the first time.
This helps count only the requests that were actually displayed to users.

- Add AUTOCOMPLETE_UNIQUE_SUGGESTION_SHOWN to TelemetryEventName enum
- Add captureUniqueSuggestionShown method to AutocompleteTelemetry
- Track shown suggestions using a Set with text+prefix+suffix as key
- Integrate tracking in GhostInlineCompletionProvider for both cache hits and LLM responses
- Add comprehensive tests for the new telemetry event
- Add shownToUser flag to FillInAtCursorSuggestion
- Update findMatchingSuggestion to return isFirstTimeShown flag
- Simplify AutocompleteTelemetry.captureUniqueSuggestionShown signature
- Remove ID generation and Set tracking logic
- Update tests to match new implementation
@markijbema markijbema force-pushed the mark/unique-suggestion-shown-telemetry branch from fc9c864 to 411d811 Compare January 5, 2026 09:30
Only count suggestions as 'unique shown' if they were visible for at least
300ms, filtering out suggestions that flash briefly when typing quickly.

- Add firstShownAt and uniqueTelemetryFired fields to FillInAtCursorSuggestion
- Add MIN_VISIBILITY_DURATION_MS constant (300ms)
- Add updateVisibilityTracking() helper function
- Add shouldFireUniqueTelemetry flag to MatchingSuggestionWithFirstTimeFlag
- Add comprehensive tests for visibility duration tracking
…metry

The previous implementation relied on subsequent calls to findMatchingSuggestion
to check if 300ms had elapsed since the suggestion was first shown. This approach
was flawed because there's no guarantee the function would be called again - if
the user just stares at the suggestion without typing, no telemetry would fire.

This fix implements proper timeout-based tracking:
1. When a suggestion is shown, start a 300ms timer
2. After 300ms, check if the same suggestion is still being displayed
3. If yes, fire AUTOCOMPLETE_UNIQUE_SUGGESTION_SHOWN telemetry
4. If no (different suggestion or dismissed), don't fire

Changes:
- Added VisibilityTrackingState interface to track current suggestion
- Added startVisibilityTracking() and cancelVisibilityTracking() methods
- Modified findMatchingSuggestion to return suggestionKey instead of shouldFireUniqueTelemetry
- Removed firstShownAt and uniqueTelemetryFired from FillInAtCursorSuggestion type
- Updated tests to reflect the new implementation
The isFirstTimeShown flag and shownToUser property were computed but never
actually consumed by any code. The visibility-based telemetry system uses
suggestionKey and firedUniqueTelemetryKeys Set for deduplication instead.

Removed:
- isFirstTimeShown property from MatchingSuggestionWithVisibilityKey interface
- shownToUser property from FillInAtCursorSuggestion interface
- All logic computing and returning isFirstTimeShown in findMatchingSuggestion()
- Related test assertions and test data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants