spanIdCell.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Link from 'sentry/components/links/link';
  2. import {trackAnalytics} from 'sentry/utils/analytics';
  3. import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import useOrganization from 'sentry/utils/useOrganization';
  6. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  7. import {SPAN_ID_DISPLAY_LENGTH} from 'sentry/views/performance/http/settings';
  8. import type {ModuleName} from 'sentry/views/starfish/types';
  9. interface Props {
  10. moduleName: ModuleName;
  11. projectSlug: string;
  12. spanId: string;
  13. timestamp: string;
  14. traceId: string;
  15. transactionId: string;
  16. }
  17. export function SpanIdCell({
  18. moduleName,
  19. projectSlug,
  20. traceId,
  21. transactionId,
  22. spanId,
  23. timestamp,
  24. }: Props) {
  25. const organization = useOrganization();
  26. const location = useLocation();
  27. const url = normalizeUrl(
  28. generateLinkToEventInTraceView({
  29. eventId: transactionId,
  30. projectSlug,
  31. traceSlug: traceId,
  32. timestamp,
  33. organization,
  34. location,
  35. spanId,
  36. })
  37. );
  38. return (
  39. <Link
  40. onClick={() =>
  41. trackAnalytics('performance_views.sample_spans.span_clicked', {
  42. organization,
  43. source: moduleName,
  44. })
  45. }
  46. to={url}
  47. >
  48. {spanId.slice(0, SPAN_ID_DISPLAY_LENGTH)}
  49. </Link>
  50. );
  51. }