Files
Verso/services/web/frontend/js/features/event-tracking/search-events.ts
T
Alf Eaton 4611de3f3d Update tooltip text for search buttons (#23448)
GitOrigin-RevId: d189aac06c5f68e009eeb125d7cc225b41e8cc0c
2025-02-17 09:04:45 +00:00

34 lines
863 B
TypeScript

import { sendMB } from '@/infrastructure/event-tracking'
type SearchEventSegmentation = {
'search-open':
| ({
searchType: 'full-project'
} & ({ method: 'keyboard' } | { method: 'button'; location: 'toolbar' }))
| ({
searchType: 'document'
mode: 'visual' | 'source'
} & ({ method: 'keyboard' } | { method: 'button'; location: 'toolbar' }))
'search-execute': {
searchType: 'full-project'
totalDocs: number
totalResults: number
}
'search-result-click': {
searchType: 'full-project'
}
'search-replace-click': {
searchType: 'document'
method: 'keyboard' | 'button'
action: 'replace' | 'replace-all'
}
}
export const sendSearchEvent = <T extends keyof SearchEventSegmentation>(
eventName: T,
segmentation: SearchEventSegmentation[T]
) => {
sendMB(eventName, segmentation)
}