Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BX-565] Keyboard shortcut and navigation tracking #837

Merged
merged 4 commits into from
Aug 3, 2023

Conversation

derHowie
Copy link
Member

@derHowie derHowie commented Aug 3, 2023

Fixes BX-####
Figma link (if any):

What changed (plus any additional context for devs)

Screen recordings / screenshots

What to test

Final checklist

  • I have tested my changes in a LavaMoat bundle (yarn build).
  • I have tested my changes in Chrome & Brave.
  • If your changes are visual, did you check both the light and dark themes?

@linear
Copy link

linear bot commented Aug 3, 2023

BX-565 Keyboard shortcut and navigation tracking

Shortcut event (when hotkeys or shortcuts are fired)

  • event name: keyboard.shortcut.triggered
  • event metadata:
    • type (i.e. cancel_transaction)
    • key
    • screen (i.e. wallet, tokens, my_qr_code)

Navigation event (when user navigates with their keyboard, i.e. tab, arrow keys, or enter)

  • event name: keyboard.navigation.triggered
  • event metadata:
    • key
    • screen

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Here's the packed extension for this build:
rainbowbx-af3874b670d8bd362892a6896a83460dc9877021.zip

Copy link
Collaborator

@DanielSinclair DanielSinclair left a comment

Choose a reason for hiding this comment

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

Looking good 👌

const currentScreen = screen[pathname];
const trackNavigation = useCallback(
({ key }: { key: string; type: KeyboardEventDescription }) => {
analytics.track('keyboard.navigation.triggered', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would use event.keyboardNavigationTriggered instead here

);
const trackShortcut = useCallback(
({ key, type }: { key: string; type: KeyboardEventDescription }) => {
analytics.track('keyboard.shortcut.triggered', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would also use event.keyboardShortcutTriggered here

// hackery preventing GweiInputMask from firing an onChange event when opening the menu with KB
setTimeout(() => openCustomGasSheet(), 0);
} else if (e.key === shortcuts.global.OPEN_GAS_MENU.key) {
trackShortcut({
key: shortcuts.global.OPEN_GAS_MENU.display,
type: 'gasMenu.open',
Copy link
Contributor

Choose a reason for hiding this comment

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

we don'y have / need consts for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

aah i see KeyboardEventDescription, is other thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, KeyboardEventDescription will show a type error if a random string is used and also provides autocompletion.

Copy link
Contributor

@estebanmino estebanmino left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Here's the packed extension for this build:
rainbowbx-1cfb25e7935ee8f8d64e3a77e2c37eb9810a548f.zip

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Here's the packed extension for this build:
rainbowbx-be5b7196ad3bcb2ef3a9d41f42d1baeb5df42476.zip

@greg-schrammel
Copy link
Contributor

can't we have the useKeyboardShortcut hook do the tracking somehow? so we don't have to remember to explicitly call trackShortcut
it's approved maybe a thought to improve later on

@derHowie derHowie merged commit fcc6a69 into master Aug 3, 2023
10 checks passed
@derHowie derHowie deleted the @chris/kb-analytics branch August 3, 2023 16:25
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Here's the packed extension for this build:
rainbowbx-fcc6a69a8ee4250e0983f9c2cfc4b22a9c4d3e21.zip

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.

4 participants