project-list-events.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { useCallback } from 'react'
  2. import { sendMB } from '@/infrastructure/event-tracking'
  3. export type ExtraSegmentations = {
  4. 'menu-expand': {
  5. item: 'help' | 'account' | 'features' | 'admin'
  6. location: 'top-menu' | 'sidebar'
  7. }
  8. 'menu-click': {
  9. item:
  10. | 'login'
  11. | 'register'
  12. | 'premium-features'
  13. | 'enterprises'
  14. | 'universities'
  15. | 'publishers'
  16. | 'edu'
  17. | 'government'
  18. | 'why-latex'
  19. | 'learn'
  20. | 'contact'
  21. | 'templates'
  22. | 'plans'
  23. location: 'top-menu' | 'sidebar'
  24. destinationURL?: string
  25. }
  26. 'new-project-expand': undefined
  27. 'new-project-click': {
  28. item:
  29. | 'blank-project'
  30. | 'example-project'
  31. | 'upload'
  32. | 'github-import'
  33. | 'all-templates'
  34. | (string & {})
  35. destinationURL?: string
  36. }
  37. }
  38. export const useSendProjectListMB = () => {
  39. return useCallback(
  40. <T extends keyof ExtraSegmentations>(
  41. event: T,
  42. payload: ExtraSegmentations[T]
  43. ) => sendMB(event, payload),
  44. []
  45. )
  46. }