context-menu-analytics.ts 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. export type ContextMenuAnalyticsEvents = {
  16. 'menu-expand': {
  17. location: 'editor-context-menu'
  18. }
  19. 'menu-click': {
  20. location: 'editor-context-menu'
  21. item: ContextMenuItemSegmentation
  22. }
  23. 'jump-to-location': {
  24. method: 'editor-context-menu'
  25. direction: 'code-location-in-pdf'
  26. }
  27. 'add-comment': {
  28. location: 'editor-context-menu'
  29. }
  30. 'paywall-prompt': {
  31. 'paywall-type': 'track-changes'
  32. location: 'editor-context-menu'
  33. }
  34. }
  35. export const sendContextMenuEvent = <
  36. T extends keyof ContextMenuAnalyticsEvents,
  37. >(
  38. eventName: T,
  39. segmentation: ContextMenuAnalyticsEvents[T]
  40. ) => {
  41. sendMB(eventName, segmentation)
  42. }