context-menu-analytics.ts 962 B

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