traceAnalytics.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import * as Sentry from '@sentry/react';
  2. import type {Organization} from 'sentry/types/organization';
  3. import {trackAnalytics} from 'sentry/utils/analytics';
  4. import type {TraceType} from './traceType';
  5. const trackTraceShape = (shape: TraceType, organization: Organization) => {
  6. Sentry.metrics.increment(`trace.trace_shape.${shape}`);
  7. trackAnalytics('trace.shape', {
  8. shape,
  9. organization,
  10. });
  11. };
  12. const trackFailedToFetchTraceState = () =>
  13. Sentry.metrics.increment('trace.failed_to_fetch_trace');
  14. const trackEmptyTraceState = () => Sentry.metrics.increment('trace.empty_trace');
  15. const trackLayoutChange = (layout: string, organization: Organization) =>
  16. trackAnalytics('trace.trace_layout.change', {
  17. layout,
  18. organization,
  19. });
  20. const trackDrawerMinimize = (organization: Organization) =>
  21. trackAnalytics('trace.trace_layout.drawer_minimize', {
  22. organization,
  23. });
  24. const trackShowInView = (organization: Organization) =>
  25. trackAnalytics('trace.trace_layout.show_in_view', {
  26. organization,
  27. });
  28. const trackViewEventJSON = (organization: Organization) =>
  29. trackAnalytics('trace.trace_layout.view_event_json', {
  30. organization,
  31. });
  32. const trackTabPin = (organization: Organization) =>
  33. trackAnalytics('trace.trace_layout.tab_pin', {
  34. organization,
  35. });
  36. const trackTabView = (tab: string, organization: Organization) =>
  37. trackAnalytics('trace.trace_layout.tab_view', {
  38. organization,
  39. tab,
  40. });
  41. const trackSearchFocus = (organization: Organization) =>
  42. trackAnalytics('trace.trace_layout.search_focus', {
  43. organization,
  44. });
  45. const trackResetZoom = (organization: Organization) =>
  46. trackAnalytics('trace.trace_layout.reset_zoom', {
  47. organization,
  48. });
  49. const trackViewShortcuts = (organization: Organization) =>
  50. trackAnalytics('trace.trace_layout.view_shortcuts', {
  51. organization,
  52. });
  53. const trackTraceWarningType = (type: TraceType, organization: Organization) =>
  54. trackAnalytics('trace.trace_warning_type', {
  55. organization,
  56. type,
  57. });
  58. const traceAnalytics = {
  59. // Trace shape
  60. trackTraceShape,
  61. trackEmptyTraceState,
  62. trackFailedToFetchTraceState,
  63. // Drawer actions
  64. trackShowInView,
  65. trackViewEventJSON,
  66. // Layout actions
  67. trackLayoutChange,
  68. trackDrawerMinimize,
  69. trackSearchFocus,
  70. trackTabPin,
  71. trackTabView,
  72. // Toolbar actions
  73. trackResetZoom,
  74. trackViewShortcuts,
  75. trackTraceWarningType,
  76. };
  77. export {traceAnalytics};