Files
Verso/services/web/frontend/js/features/event-tracking/search-events.ts
T
DavidandCopybot ae9d84c279 Merge pull request #28392 from overleaf/dp-segment-editor-analytics
Add editor-redesign segmentation to a bunch of analytics events

GitOrigin-RevId: e8d2091028dab09de06362c38c5a17f32253e7cc
2025-09-11 08:05:05 +00:00

38 lines
948 B
TypeScript

import { sendMB } from '@/infrastructure/event-tracking'
type SearchEventSegmentation = {
'search-open':
| ({
searchType: 'full-project'
} & (
| { method: 'keyboard' }
| { method: 'button'; location: 'toolbar' | 'search-form' | 'rail' }
))
| ({
searchType: 'document'
mode: 'visual' | 'source'
} & ({ method: 'keyboard' } | { method: 'button'; location: 'toolbar' }))
'search-execute': {
searchType: 'full-project'
totalDocs: number
totalResults: number
'editor-redesign'?: 'enabled'
}
'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)
}