|
|
@@ -6,10 +6,15 @@ import { debugConsole } from '@/utils/debugging'
|
|
|
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'
|
|
|
|
|
|
-function createEditingSessionHeartbeatData(editorType: EditorType) {
|
|
|
+function createEditingSessionHeartbeatData(
|
|
|
+ editorType: EditorType,
|
|
|
+ newEditor: boolean
|
|
|
+) {
|
|
|
return {
|
|
|
editorType,
|
|
|
+ editorRedesign: newEditor,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -25,6 +30,7 @@ function sendEditingSessionHeartbeat(
|
|
|
export function useEditingSessionHeartbeat() {
|
|
|
const { projectId } = useIdeReactContext()
|
|
|
const { getEditorType } = useEditorManagerContext()
|
|
|
+ const newEditor = useIsNewEditorEnabled()
|
|
|
|
|
|
// Keep track of how many heartbeats we've sent so that we can calculate how
|
|
|
// long to wait until the next one
|
|
|
@@ -51,7 +57,10 @@ export function useEditingSessionHeartbeat() {
|
|
|
|
|
|
heartBeatSentRecentlyRef.current = true
|
|
|
|
|
|
- const segmentation = createEditingSessionHeartbeatData(editorType)
|
|
|
+ const segmentation = createEditingSessionHeartbeatData(
|
|
|
+ editorType,
|
|
|
+ newEditor
|
|
|
+ )
|
|
|
|
|
|
debugConsole.log('[Event] send heartbeat request', segmentation)
|
|
|
sendEditingSessionHeartbeat(projectId, segmentation)
|
|
|
@@ -71,7 +80,7 @@ export function useEditingSessionHeartbeat() {
|
|
|
heartBeatResetTimerRef.current = window.setTimeout(() => {
|
|
|
heartBeatSentRecentlyRef.current = false
|
|
|
}, backoffSecs * 1000)
|
|
|
- }, [getEditorType, projectId])
|
|
|
+ }, [getEditorType, projectId, newEditor])
|
|
|
|
|
|
// Hook the heartbeat up to editor events
|
|
|
useEventListener('cursor:editor:update', editingSessionHeartbeat)
|