mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #29380 from overleaf/mj-layout-editing-sessions
[analytics+web] Add layout info to editing sessions GitOrigin-RevId: d5f3161444718004aa722a6f413f6b5ff9c95aea
This commit is contained in:
committed by
Copybot
parent
bfed1ac2ae
commit
4cb60410da
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user