context-menu-analytics.ts 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { sendMB } from '@/infrastructure/event-tracking'
  2. export type ContextMenuItemSegmentation =
  3. | 'cut'
  4. | 'copy'
  5. | 'paste'
  6. | 'paste-without-formatting'
  7. | 'paste-with-formatting'
  8. | 'select-all'
  9. | 'give-feedback'
  10. | 'delete'
  11. | 'jump-to-location-in-pdf'
  12. | 'suggest-edits'
  13. | 'back-to-editing'
  14. | 'comment'
  15. | 'accept-changes'
  16. | 'reject-changes'
  17. export type ContextMenuAnalyticsEvents = {
  18. 'menu-expand': {
  19. location: 'editor-context-menu'
  20. }
  21. 'menu-click': {
  22. location: 'editor-context-menu'
  23. item: ContextMenuItemSegmentation
  24. }
  25. 'jump-to-location': {
  26. method: 'editor-context-menu'
  27. direction: 'code-location-in-pdf'
  28. }
  29. 'add-comment': {
  30. location: 'editor-context-menu'
  31. }
  32. 'paywall-prompt': {
  33. 'paywall-type': 'track-changes'
  34. location: 'editor-context-menu'
  35. }
  36. }
  37. export const sendContextMenuEvent = <
  38. T extends keyof ContextMenuAnalyticsEvents,
  39. >(
  40. eventName: T,
  41. segmentation: ContextMenuAnalyticsEvents[T]
  42. ) => {
  43. sendMB(eventName, segmentation)
  44. }