project-list-events.ts 1.3 KB

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