Преглед изворни кода

Merge pull request #25955 from overleaf/mj-ide-editing-session

[analytics+web] Add editor redesign status to editing session segmentation

GitOrigin-RevId: 8f2a05a6851d41712a592952c18b845b77115f47
Mathias Jakobsen пре 1 година
родитељ
комит
97f8149a2b

+ 12 - 3
services/web/frontend/js/features/ide-react/hooks/use-editing-session-heartbeat.ts

@@ -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)