Files
overleaf-cep/services/web/frontend/js/features/editor-left-menu/hooks/use-set-compilation-setting.ts
T
Mathias Jakobsen 3a8d383ac3 Merge pull request #28871 from overleaf/mj-recompile-setting-changed-add-missing
[web] Add missing events for changing compile-related settings

GitOrigin-RevId: b2ccb4c8f0f3920762d6e69ccb537ae9bedb0281
2025-10-09 08:05:36 +00:00

24 lines
716 B
TypeScript

import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
import { useCallback } from 'react'
export function useSetCompilationSettingWithEvent<T>(
settingName: string,
setter: (value: T) => void,
options: { omitValueInEvent?: boolean } = {}
): (value: T) => void {
const { sendEvent } = useEditorAnalytics()
return useCallback(
value => {
const segmentation: { setting: string; settingVal?: T } = {
setting: settingName,
}
if (!options.omitValueInEvent) {
segmentation.settingVal = value
}
sendEvent('recompile-setting-changed', segmentation)
setter(value)
},
[sendEvent, setter, settingName, options.omitValueInEvent]
)
}