mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 14:49:01 +02:00
3a8d383ac3
[web] Add missing events for changing compile-related settings GitOrigin-RevId: b2ccb4c8f0f3920762d6e69ccb537ae9bedb0281
24 lines
716 B
TypeScript
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]
|
|
)
|
|
}
|