|
@@ -7,14 +7,33 @@ import { useCallback, useEffect, useRef } from 'react'
|
|
|
import useEventListener from '@/shared/hooks/use-event-listener'
|
|
import useEventListener from '@/shared/hooks/use-event-listener'
|
|
|
import useDomEventListener from '@/shared/hooks/use-dom-event-listener'
|
|
import useDomEventListener from '@/shared/hooks/use-dom-event-listener'
|
|
|
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
|
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(
|
|
function createEditingSessionHeartbeatData(
|
|
|
editorType: EditorType,
|
|
editorType: EditorType,
|
|
|
- newEditor: boolean
|
|
|
|
|
|
|
+ newEditor: boolean,
|
|
|
|
|
+ view: IdeView | null,
|
|
|
|
|
+ layout: IdeLayout,
|
|
|
|
|
+ railOpen: boolean,
|
|
|
|
|
+ railTab: RailTabKey,
|
|
|
|
|
+ hasDetachedPdf: boolean
|
|
|
) {
|
|
) {
|
|
|
|
|
+ const newEditorSegmentation = newEditor ? { railOpen, railTab } : {}
|
|
|
return {
|
|
return {
|
|
|
editorType,
|
|
editorType,
|
|
|
editorRedesign: newEditor,
|
|
editorRedesign: newEditor,
|
|
|
|
|
+ editorView: view,
|
|
|
|
|
+ editorLayout: layout,
|
|
|
|
|
+ hasDetachedPdf,
|
|
|
|
|
+ ...newEditorSegmentation,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -31,6 +50,8 @@ export function useEditingSessionHeartbeat() {
|
|
|
const { projectId } = useIdeReactContext()
|
|
const { projectId } = useIdeReactContext()
|
|
|
const { getEditorType } = useEditorManagerContext()
|
|
const { getEditorType } = useEditorManagerContext()
|
|
|
const newEditor = useIsNewEditorEnabled()
|
|
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
|
|
// Keep track of how many heartbeats we've sent so that we can calculate how
|
|
|
// long to wait until the next one
|
|
// long to wait until the next one
|
|
@@ -59,7 +80,12 @@ export function useEditingSessionHeartbeat() {
|
|
|
|
|
|
|
|
const segmentation = createEditingSessionHeartbeatData(
|
|
const segmentation = createEditingSessionHeartbeatData(
|
|
|
editorType,
|
|
editorType,
|
|
|
- newEditor
|
|
|
|
|
|
|
+ newEditor,
|
|
|
|
|
+ view,
|
|
|
|
|
+ layout,
|
|
|
|
|
+ railIsOpen,
|
|
|
|
|
+ selectedRailTab,
|
|
|
|
|
+ detachIsLinked
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
debugConsole.log('[Event] send heartbeat request', segmentation)
|
|
debugConsole.log('[Event] send heartbeat request', segmentation)
|
|
@@ -80,7 +106,16 @@ export function useEditingSessionHeartbeat() {
|
|
|
heartBeatResetTimerRef.current = window.setTimeout(() => {
|
|
heartBeatResetTimerRef.current = window.setTimeout(() => {
|
|
|
heartBeatSentRecentlyRef.current = false
|
|
heartBeatSentRecentlyRef.current = false
|
|
|
}, backoffSecs * 1000)
|
|
}, backoffSecs * 1000)
|
|
|
- }, [getEditorType, projectId, newEditor])
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ getEditorType,
|
|
|
|
|
+ projectId,
|
|
|
|
|
+ newEditor,
|
|
|
|
|
+ view,
|
|
|
|
|
+ layout,
|
|
|
|
|
+ railIsOpen,
|
|
|
|
|
+ selectedRailTab,
|
|
|
|
|
+ detachIsLinked,
|
|
|
|
|
+ ])
|
|
|
|
|
|
|
|
// Hook the heartbeat up to editor events
|
|
// Hook the heartbeat up to editor events
|
|
|
useEventListener('cursor:editor:update', editingSessionHeartbeat)
|
|
useEventListener('cursor:editor:update', editingSessionHeartbeat)
|