utils.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import type {Query} from 'history';
  2. import type {SpanSlug} from 'sentry/utils/performance/suspectSpans/types';
  3. import type {DomainView} from 'sentry/views/insights/pages/useFilters';
  4. import {getTransactionSummaryBaseUrl} from 'sentry/views/performance/transactionSummary/utils';
  5. function generateSpanDetailsRoute({
  6. orgSlug,
  7. spanSlug,
  8. view,
  9. }: {
  10. orgSlug: string;
  11. spanSlug: SpanSlug;
  12. view?: DomainView;
  13. }): string {
  14. const spanComponent = `${encodeURIComponent(spanSlug.op)}:${spanSlug.group}`;
  15. return `${getTransactionSummaryBaseUrl(orgSlug, view)}/spans/${spanComponent}/`;
  16. }
  17. export function spanDetailsRouteWithQuery({
  18. orgSlug,
  19. transaction,
  20. query,
  21. spanSlug,
  22. projectID,
  23. view,
  24. }: {
  25. orgSlug: string;
  26. query: Query;
  27. spanSlug: SpanSlug;
  28. transaction: string;
  29. projectID?: string | string[];
  30. view?: DomainView;
  31. }) {
  32. const pathname = generateSpanDetailsRoute({
  33. orgSlug,
  34. spanSlug,
  35. view,
  36. });
  37. return {
  38. pathname,
  39. query: {
  40. transaction,
  41. project: projectID,
  42. environment: query.environment,
  43. statsPeriod: query.statsPeriod,
  44. start: query.start,
  45. end: query.end,
  46. query: query.query,
  47. },
  48. };
  49. }
  50. export function generateQuerySummaryRoute({
  51. orgSlug,
  52. group,
  53. }: {
  54. group: string;
  55. orgSlug: string;
  56. }): string {
  57. return `/organizations/${orgSlug}/insights/database/spans/span/${group}/`;
  58. }
  59. export function querySummaryRouteWithQuery({
  60. orgSlug,
  61. query,
  62. group,
  63. projectID,
  64. }: {
  65. group: string;
  66. orgSlug: string;
  67. query: Query;
  68. projectID?: string | string[];
  69. }) {
  70. const pathname = generateQuerySummaryRoute({
  71. orgSlug,
  72. group,
  73. });
  74. return {
  75. pathname,
  76. query: {
  77. project: projectID,
  78. environment: query.environment,
  79. statsPeriod: query.statsPeriod,
  80. start: query.start,
  81. end: query.end,
  82. },
  83. };
  84. }
  85. export function generateResourceSummaryRoute({
  86. baseUrl,
  87. group,
  88. }: {
  89. baseUrl: string;
  90. group: string;
  91. }): string {
  92. return `${baseUrl}/spans/span/${group}/`;
  93. }
  94. export function resourceSummaryRouteWithQuery({
  95. baseUrl,
  96. query,
  97. group,
  98. projectID,
  99. }: {
  100. baseUrl: string;
  101. group: string;
  102. query: Query;
  103. projectID?: string | string[];
  104. }) {
  105. const pathname = generateResourceSummaryRoute({
  106. baseUrl,
  107. group,
  108. });
  109. return {
  110. pathname,
  111. query: {
  112. project: projectID,
  113. environment: query.environment,
  114. statsPeriod: query.statsPeriod,
  115. start: query.start,
  116. end: query.end,
  117. },
  118. };
  119. }
  120. export enum ZoomKeys {
  121. MIN = 'min',
  122. MAX = 'max',
  123. START = 'start',
  124. END = 'end',
  125. }