From 97f8149a2b265d41d8c0a4dedf7188b28ef48029 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Thu, 29 May 2025 11:48:22 +0100 Subject: [PATCH] Merge pull request #25955 from overleaf/mj-ide-editing-session [analytics+web] Add editor redesign status to editing session segmentation GitOrigin-RevId: 8f2a05a6851d41712a592952c18b845b77115f47 --- .../hooks/use-editing-session-heartbeat.ts | 15 ++++++++++++--- 1 file changed, 12 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 d264766d76..cdb0a151ae 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 @@ -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)