utils.tsx 2.3 KB

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