routes.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {Location, LocationDescriptor, Path} from 'history';
  2. import {Organization, Project} from 'sentry/types';
  3. import {Trace} from 'sentry/types/profiling/core';
  4. export function generateProfilingRoute({orgSlug}: {orgSlug: Organization['slug']}): Path {
  5. return `/organizations/${orgSlug}/profiling/`;
  6. }
  7. export function generateProfileSummaryRoute({
  8. orgSlug,
  9. projectSlug,
  10. }: {
  11. orgSlug: Organization['slug'];
  12. projectSlug: Project['slug'];
  13. }): Path {
  14. return `/organizations/${orgSlug}/profiling/summary/${projectSlug}/`;
  15. }
  16. export function generateProfileFlamegraphRoute({
  17. orgSlug,
  18. projectSlug,
  19. profileId,
  20. }: {
  21. orgSlug: Organization['slug'];
  22. profileId: Trace['id'];
  23. projectSlug: Project['slug'];
  24. }): string {
  25. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/flamegraph/`;
  26. }
  27. export function generateProfileDetailsRoute({
  28. orgSlug,
  29. projectSlug,
  30. profileId,
  31. }: {
  32. orgSlug: Organization['slug'];
  33. profileId: Trace['id'];
  34. projectSlug: Project['slug'];
  35. }): string {
  36. return `/organizations/${orgSlug}/profiling/profile/${projectSlug}/${profileId}/details/`;
  37. }
  38. export function generateProfilingRouteWithQuery({
  39. location,
  40. orgSlug,
  41. query,
  42. }: {
  43. orgSlug: Organization['slug'];
  44. location?: Location;
  45. query?: Location['query'];
  46. }): LocationDescriptor {
  47. const pathname = generateProfilingRoute({orgSlug});
  48. return {
  49. pathname,
  50. query: {
  51. ...location?.query,
  52. ...query,
  53. },
  54. };
  55. }
  56. export function generateProfileSummaryRouteWithQuery({
  57. location,
  58. orgSlug,
  59. projectSlug,
  60. transaction,
  61. query,
  62. }: {
  63. orgSlug: Organization['slug'];
  64. projectSlug: Project['slug'];
  65. transaction: string;
  66. location?: Location;
  67. query?: Location['query'];
  68. }): LocationDescriptor {
  69. const pathname = generateProfileSummaryRoute({orgSlug, projectSlug});
  70. return {
  71. pathname,
  72. query: {
  73. ...location?.query,
  74. ...query,
  75. transaction,
  76. },
  77. };
  78. }
  79. export function generateProfileFlamegraphRouteWithQuery({
  80. location,
  81. orgSlug,
  82. projectSlug,
  83. profileId,
  84. query,
  85. }: {
  86. orgSlug: Organization['slug'];
  87. profileId: Trace['id'];
  88. projectSlug: Project['slug'];
  89. location?: Location;
  90. query?: Location['query'];
  91. }): LocationDescriptor {
  92. const pathname = generateProfileFlamegraphRoute({orgSlug, projectSlug, profileId});
  93. return {
  94. pathname,
  95. query: {
  96. ...location?.query,
  97. ...query,
  98. },
  99. };
  100. }
  101. export function generateProfileDetailsRouteWithQuery({
  102. location,
  103. orgSlug,
  104. projectSlug,
  105. profileId,
  106. query,
  107. }: {
  108. orgSlug: Organization['slug'];
  109. profileId: Trace['id'];
  110. projectSlug: Project['slug'];
  111. location?: Location;
  112. query?: Location['query'];
  113. }): LocationDescriptor {
  114. const pathname = generateProfileDetailsRoute({orgSlug, projectSlug, profileId});
  115. return {
  116. pathname,
  117. query: {
  118. ...location?.query,
  119. ...query,
  120. },
  121. };
  122. }