Skip to content

Conversation

@hannahbergam
Copy link
Contributor

Warning!!

We have entered Pixel Lock for Hour of AI! All merges to the staging branch from Dec 2 through Dec 12 must go through live change review and be deemed critical for supporting the Hour of AI. External contributions will not be accepted at this time.

For non-critical changes, please change your base to staging-next and delete this warning. We will merge staging-next into staging on Dec 15, 2025.

This PR adds a metric that listens for users who press '/' to open the shortcuts menu. This might be a possible indicator that we have a keyboard navigation user.

I was able to confirm that the metric logs when focus is in the blockly div, and doesn't log outside that focus. Note- this time Claude was very helpful and I only needed to make minor tweaks, but another set of eyes would be helpful to make sure I'm not biased to the tool's solution.

Screenshot 2025-12-11 at 4 49 06 PM

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Creation Checklist:

  • Tests provide adequate coverage
  • Privacy impacts have been documented
  • Security impacts have been documented
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Follow-up work items (including potential tech debt) are tracked and linked

@hannahbergam hannahbergam requested a review from Copilot December 12, 2025 00:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds analytics tracking to identify potential keyboard navigation users in Blockly by logging when they press the '/' key to open the shortcuts menu.

  • Adds a new Statsig event constant for tracking slash key presses
  • Implements keyboard event listener on the blockly-div element to capture '/' key presses
  • Includes proper cleanup logic to prevent duplicate listeners during re-initialization

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/src/metrics/AnalyticsConstants.js Adds new event constant for tracking slash key presses
apps/src/blockly/addons/cdoKeyboardNavigation.ts Implements slash key listener with cleanup handlers and integrates into keyboard navigation initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +119 to +123
analyticsReporter.sendEvent(
EVENTS.BLOCKLY_SLASH_KEY_PRESSED,
{},
PLATFORMS.STATSIG
);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The analytics event is sent every time '/' is pressed, which could result in duplicate events if a user presses the key multiple times or holds it down. Consider debouncing or throttling this event, or tracking only the first occurrence per session to avoid inflating metrics.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we want to know truly how often users are pressing this key.


// Create and store new listener
slashKeyListener = handleSlashKeyPress;
blocklyDiv.addEventListener('keydown', slashKeyListener);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The event listener is attached every time initializeKeyboardNavigation is called without checking if one already exists at the DOM level. While the code removes the listener reference before adding a new one, consider using addEventListener with {once: true} for the first occurrence tracking, or add a flag to track if this has already been logged in the current session.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already take care of this by double checking and removing if one exists.

@hannahbergam hannahbergam requested a review from a team December 12, 2025 20:29
@alex-m-brown alex-m-brown changed the base branch from staging-next to staging December 15, 2025 15:24
@hannahbergam hannahbergam merged commit 7588dd0 into staging Dec 17, 2025
4 checks passed
@hannahbergam hannahbergam deleted the hbergam/proxy-metric-keynav branch December 17, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants