Files
overleaf-cep/services/web/frontend/js/features/ide-settings/hooks/use-set-compilation-setting.ts
T
Mathias Jakobsen 3a3adf5e5a Merge pull request #34980 from overleaf/mj-ide-settings-feature
[web] Consolidate ide settings in `features/ide-settings`

GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
2026-09-17 11:13:11 +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]
)
}