overleaf-cep/services/web/frontend/js/features/event-tracking/search-events.ts
Eric Mc Sween 82c95dd82d Merge pull request #24930 from overleaf/em-ae-jd-full-project-search-launch
Launch full project search from regular search

GitOrigin-RevId: 3ef4f6923a0aeef6ab68768bab79e4be32f09eb0
2025-04-17 08:06:07 +00:00

36 lines
905 B
TypeScript

import { sendMB } from '@/infrastructure/event-tracking'
type SearchEventSegmentation = {
'search-open':
| ({
searchType: 'full-project'
} & (
| { method: 'keyboard' }
| { method: 'button'; location: 'toolbar' | 'search-form' }
))
| ({
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)
}