Skip to content

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Sep 24, 2025

This adds open / close tracking for all drawer sections whenever you switch between sections (like via the toolbar or hooks) or when you open/close the drawer or when sections disappear.

@lerouxb lerouxb requested review from gagik and gribnoysup September 24, 2025 16:05
@lerouxb lerouxb changed the title track opening and closing the assistant feat(compass-assistant): track opening and closing the assistant COMPASS-9884 Sep 24, 2025
@lerouxb lerouxb added the feature flagged PRs labeled with this label will not be included in the release notes of the next release label Sep 24, 2025
@github-actions github-actions bot added the feat label Sep 24, 2025
</DrawerActionsContext.Provider>
<DrawerCurrentTabStateContext.Provider value={drawerCurrentTab}>
<DrawerSetCurrentTabContext.Provider value={setDrawerCurrentTab}>
<DrawerActionsContext.Provider value={drawerActions}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nesting here is getting a bit wild. Can/should we not combine some of it? Is there a better way? I did kinda just copy what we're already doing for isOpen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can group all actions together, but for state if we're putting it in one context, there would be no way to subscribe to changes to a single value instead of all of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I guess it is OK then.

@lerouxb lerouxb changed the title feat(compass-assistant): track opening and closing the assistant COMPASS-9884 feat(compass-assistant): track opening and closing the drawer sections COMPASS-9884 Sep 25, 2025
}
},
[ensureOptInAndSend, setMessages]
[ensureOptInAndSend, setMessages, track]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive-by

@lerouxb lerouxb force-pushed the track-open-close-assistant branch 2 times, most recently from 07f8296 to 0fd8470 Compare September 25, 2025 15:09
@lerouxb lerouxb force-pushed the track-open-close-assistant branch from 0fd8470 to 20ac43b Compare September 25, 2025 15:10
@lerouxb lerouxb marked this pull request as ready for review September 25, 2025 15:35
@lerouxb lerouxb requested a review from a team as a code owner September 25, 2025 15:35
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 15:35
Copy link
Contributor

@Copilot 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 telemetry tracking for drawer section open/close events in the Compass application. It implements callbacks to track when users open or close drawer sections, either by switching tabs in the drawer toolbar or opening/closing the drawer itself.

  • Add telemetry events for tracking drawer section interactions
  • Implement callback props in drawer components to handle open/close events
  • Update tests to verify the new tracking functionality

Reviewed Changes

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

Show a summary per file
File Description
packages/compass/src/app/components/home.tsx Wire up drawer section tracking callbacks to telemetry
packages/compass-web/src/entrypoint.tsx Wire up drawer section tracking callbacks to telemetry
packages/compass-telemetry/src/telemetry-events.ts Define new telemetry event types for drawer section interactions
packages/compass-components/src/components/drawer-portal.tsx Implement drawer section tracking logic and callback props
packages/compass-components/src/components/drawer-portal.spec.tsx Add tests for drawer section tracking functionality
packages/compass-components/src/components/compass-components-provider.tsx Pass through drawer section tracking props
packages/compass-assistant/src/components/assistant-chat.tsx Add track dependency to useCallback hook

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +206 to +212
useEffect(() => {
const currentTab =
drawerToolbarContext.getActiveDrawerContent()?.id ?? null;

currentTabSetter(currentTab);
}, [drawerToolbarContext, currentTabSetter]);

Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

This useEffect will run on every change to drawerToolbarContext, but it should only run when the active drawer content actually changes. Consider extracting drawerToolbarContext.getActiveDrawerContent()?.id to the dependency array or using a useMemo to optimize this effect.

Suggested change
useEffect(() => {
const currentTab =
drawerToolbarContext.getActiveDrawerContent()?.id ?? null;
currentTabSetter(currentTab);
}, [drawerToolbarContext, currentTabSetter]);
const activeDrawerContentId = useMemo(
() => drawerToolbarContext.getActiveDrawerContent()?.id ?? null,
[drawerToolbarContext]
);
useEffect(() => {
currentTabSetter(activeDrawerContentId);
}, [activeDrawerContentId, currentTabSetter]);

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing we wouldn't want this because we want open/close even if it is the same tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't a value we can check. There's a method. 🤷

@lerouxb lerouxb merged commit 65c558d into main Sep 26, 2025
102 of 107 checks passed
@lerouxb lerouxb deleted the track-open-close-assistant branch September 26, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants