From a293474c0c4aa901b6a79012cce8cc48a1997feb Mon Sep 17 00:00:00 2001 From: Malik Glossop Date: Wed, 4 Mar 2026 13:58:16 +0100 Subject: [PATCH] Merge pull request #31035 from overleaf/mg-context-menu-analytics Add analytics event for context menu, comment, track changes, and jump to location GitOrigin-RevId: 8412cc3c8039cd1582ccee20b162b4bef4467dea --- .../components/pdf-synctex-controls.tsx | 15 +++- .../components/review-mode-switcher.tsx | 7 +- .../components/review-tooltip-menu.tsx | 10 ++- .../upgrade-track-changes-modal.tsx | 48 +++++++++--- .../editor-context-menu-feedback.tsx | 8 +- .../components/editor-context-menu.tsx | 4 + .../components/toolbar/toolbar-items.tsx | 4 +- .../source-editor/extensions/shortcuts.ts | 4 + .../extensions/toolbar/commands.ts | 6 +- .../hooks/use-context-menu-items.tsx | 77 +++++++++++++------ .../use-toolbar-menu-editor-commands.tsx | 2 +- .../utils/context-menu-analytics.ts | 44 +++++++++++ .../js/shared/context/editor-context.tsx | 18 +++-- .../frontend/helpers/editor-providers.tsx | 4 +- 14 files changed, 203 insertions(+), 48 deletions(-) create mode 100644 services/web/frontend/js/features/source-editor/utils/context-menu-analytics.ts diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.tsx b/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.tsx index bba7c150e3..75c840133a 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.tsx +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-synctex-controls.tsx @@ -10,6 +10,7 @@ import { Placement } from 'react-bootstrap/types' import useSynctex from '../hooks/use-synctex' import { useFeatureFlag } from '@/shared/context/split-test-context' import OLSpinner from '@/shared/components/ol/ol-spinner' +import { sendMB } from '@/infrastructure/event-tracking' const GoToCodeButton = memo(function GoToCodeButton({ syncToCode, @@ -35,6 +36,10 @@ const GoToCodeButton = memo(function GoToCodeButton({ } const syncToCodeWithButton = useCallback(() => { + sendMB('jump-to-location', { + method: 'arrow', + direction: 'pdf-location-in-code', + }) syncToCode({ visualOffset: 72 }) }, [syncToCode]) @@ -85,6 +90,14 @@ const GoToPdfButton = memo(function GoToPdfButton({ 'detach-synctex-control': !!isDetachLayout, }) + const handleSyncToPdf = useCallback(() => { + sendMB('jump-to-location', { + method: 'arrow', + direction: 'code-location-in-pdf', + }) + syncToPdf() + }, [syncToPdf]) + let buttonIcon = null if (syncToPdfInFlight) { buttonIcon = @@ -104,7 +117,7 @@ const GoToPdfButton = memo(function GoToPdfButton({ void }>( >() const [visible, setVisible] = useState(false) + const handleAddCommentClick = useCallback(() => { + sendMB('add-comment', { + location: 'tooltip', + }) + onAddComment() + }, [onAddComment]) + const changesInSelection = useMemo(() => { return (ranges?.changes ?? []).filter(({ op }) => { const opFrom = op.p @@ -219,7 +227,7 @@ const ReviewTooltipMenuContent = memo<{ onAddComment: () => void }>( >