overleaf/services/web/frontend/js/features/ide-react/hooks/use-layout-event-tracking.ts
Tim Down 01439641ca Merge pull request #15376 from overleaf/td-ide-page-working-editor
React IDE page: working editor

GitOrigin-RevId: 3ba8cb787a6f7f8435686d8962adb7444d09acb5
2023-10-27 08:03:07 +00:00

25 lines
632 B
TypeScript

import { useLayoutContext } from '@/shared/context/layout-context'
import { useEffect } from 'react'
import { sendMBOnce } from '@/infrastructure/event-tracking'
export function useLayoutEventTracking() {
const { view, leftMenuShown, chatIsOpen } = useLayoutContext()
useEffect(() => {
if (view !== 'editor' && view !== 'pdf') {
sendMBOnce(`ide-open-view-${view}-once`)
}
}, [view])
useEffect(() => {
if (leftMenuShown) {
sendMBOnce(`ide-open-left-menu-once`)
}
}, [leftMenuShown])
useEffect(() => {
if (chatIsOpen) {
sendMBOnce(`ide-open-chat-once`)
}
}, [chatIsOpen])
}