From b0d05c0cf0750714e1f467d20ed6c5f5e9467e8f Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Thu, 30 Oct 2025 11:15:53 +0000 Subject: [PATCH] Merge pull request #29380 from overleaf/mj-layout-editing-sessions [analytics+web] Add layout info to editing sessions GitOrigin-RevId: d5f3161444718004aa722a6f413f6b5ff9c95aea --- .../hooks/use-editing-session-heartbeat.ts | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/services/web/frontend/js/features/ide-react/hooks/use-editing-session-heartbeat.ts b/services/web/frontend/js/features/ide-react/hooks/use-editing-session-heartbeat.ts index cdb0a151ae..518dd461e1 100644 --- a/services/web/frontend/js/features/ide-react/hooks/use-editing-session-heartbeat.ts +++ b/services/web/frontend/js/features/ide-react/hooks/use-editing-session-heartbeat.ts @@ -7,14 +7,33 @@ import { useCallback, useEffect, useRef } from 'react' import useEventListener from '@/shared/hooks/use-event-listener' import useDomEventListener from '@/shared/hooks/use-dom-event-listener' import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils' +import { + IdeLayout, + IdeView, + useLayoutContext, +} from '@/shared/context/layout-context' +import { + RailTabKey, + useRailContext, +} from '@/features/ide-redesign/contexts/rail-context' function createEditingSessionHeartbeatData( editorType: EditorType, - newEditor: boolean + newEditor: boolean, + view: IdeView | null, + layout: IdeLayout, + railOpen: boolean, + railTab: RailTabKey, + hasDetachedPdf: boolean ) { + const newEditorSegmentation = newEditor ? { railOpen, railTab } : {} return { editorType, editorRedesign: newEditor, + editorView: view, + editorLayout: layout, + hasDetachedPdf, + ...newEditorSegmentation, } } @@ -31,6 +50,8 @@ export function useEditingSessionHeartbeat() { const { projectId } = useIdeReactContext() const { getEditorType } = useEditorManagerContext() const newEditor = useIsNewEditorEnabled() + const { view, pdfLayout: layout, detachIsLinked } = useLayoutContext() + const { isOpen: railIsOpen, selectedTab: selectedRailTab } = useRailContext() // Keep track of how many heartbeats we've sent so that we can calculate how // long to wait until the next one @@ -59,7 +80,12 @@ export function useEditingSessionHeartbeat() { const segmentation = createEditingSessionHeartbeatData( editorType, - newEditor + newEditor, + view, + layout, + railIsOpen, + selectedRailTab, + detachIsLinked ) debugConsole.log('[Event] send heartbeat request', segmentation) @@ -80,7 +106,16 @@ export function useEditingSessionHeartbeat() { heartBeatResetTimerRef.current = window.setTimeout(() => { heartBeatSentRecentlyRef.current = false }, backoffSecs * 1000) - }, [getEditorType, projectId, newEditor]) + }, [ + getEditorType, + projectId, + newEditor, + view, + layout, + railIsOpen, + selectedRailTab, + detachIsLinked, + ]) // Hook the heartbeat up to editor events useEventListener('cursor:editor:update', editingSessionHeartbeat)