[Part 2/6] feat(telemetry): add activity detector with user interaction tracking#8111
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @eLyiN, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request lays foundational groundwork for enhanced performance monitoring by introducing mechanisms to track user activity. It provides core components for detecting and categorizing user interactions, which will be crucial for understanding system performance in relation to user engagement without affecting existing functionality.
Highlights
- New Telemetry Components: Introduces ActivityType enum and ActivityDetector class to track user activity states for future performance monitoring.
- ActivityType Enum: Defines various user activity types such as USER_INPUT_START, TOOL_CALL_SCHEDULED, and STREAM_END.
- ActivityDetector: Implements logic to track user activity timing and state transitions with a configurable idle timeout.
- Comprehensive Testing: Includes 18 new unit tests to ensure the correct functionality of the ActivityDetector and its global functions.
- API Exposure: The new APIs are exposed minimally via the telemetry index, with no changes to CLI or runtime behavior elsewhere.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces an ActivityDetector and an ActivityType enum to track user activity for future performance monitoring. The implementation is clean and comes with a comprehensive set of unit tests. The new APIs are correctly exposed through the main telemetry index file. I have one suggestion regarding the global activity detector's initialization logic to prevent potential bugs related to configuration.
cc94d31 to
41ce061
Compare
|
@jacob314 ready for review |
b093665 to
fede57a
Compare
Prevents subtle bug where first call to recordUserActivity locks in the default idle threshold, causing later initializeActivityDetector(customTimeout) to be ignored. recordUserActivity now only acts on an existing global detector (mirrors isUserActive); initialization is explicit to ensure correct configuration. Updates the unit test to assert no implicit initialization occurs.
… and improve tests Remove the initializeActivityDetector function and ensure the global activity detector is eagerly created. Update tests to use fake timers consistently.
fede57a to
f2ba1ea
Compare
407373d

Summary
Adds activity detection capabilities for user interaction tracking, enabling activity-aware telemetry recording. The ActivityDetector tracks user activity across different interaction types and provides APIs to check current activity state.
Dependencies
Review Order: Please review Part 1 (#8110) first, then this PR.
Related PRs - Enhanced Performance Monitoring Split
This is Part 2 of 6 in the split implementation of #2127:
Changes in This PR
ActivityTypes (
packages/core/src/telemetry/activity-types.ts)KEYBOARD,MOUSE,SYSTEM,IDLEActivityDetector (
packages/core/src/telemetry/activity-detector.ts)isUserActive()API to check if user is currently activeEnhanced Exports (
packages/core/src/telemetry/index.ts)ActivityDetectorclass and related APIsActivityTypeenum for type-safe usage