mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 16:19:02 +02:00
Merge pull request #25955 from overleaf/mj-ide-editing-session
[analytics+web] Add editor redesign status to editing session segmentation GitOrigin-RevId: 8f2a05a6851d41712a592952c18b845b77115f47
This commit is contained in:
committed by
Copybot
parent
393e738ce6
commit
97f8149a2b
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user