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)