spanIdCell.tsx 1.6 KB

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