routes.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 generateProfileFlamechartRoute({
  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. orgSlug,
  40. query,
  41. }: {
  42. orgSlug: Organization['slug'];
  43. query?: Location['query'];
  44. }): LocationDescriptor {
  45. const pathname = generateProfilingRoute({orgSlug});
  46. return {
  47. pathname,
  48. query: {
  49. ...query,
  50. },
  51. };
  52. }
  53. export function generateProfileSummaryRouteWithQuery({
  54. orgSlug,
  55. projectSlug,
  56. transaction,
  57. query,
  58. }: {
  59. orgSlug: Organization['slug'];
  60. projectSlug: Project['slug'];
  61. transaction: string;
  62. query?: Location['query'];
  63. }): LocationDescriptor {
  64. const pathname = generateProfileSummaryRoute({orgSlug, projectSlug});
  65. return {
  66. pathname,
  67. query: {
  68. ...query,
  69. transaction,
  70. },
  71. };
  72. }
  73. export function generateProfileFlamechartRouteWithQuery({
  74. orgSlug,
  75. projectSlug,
  76. profileId,
  77. query,
  78. }: {
  79. orgSlug: Organization['slug'];
  80. profileId: Trace['id'];
  81. projectSlug: Project['slug'];
  82. query?: Location['query'];
  83. }): LocationDescriptor {
  84. const pathname = generateProfileFlamechartRoute({
  85. orgSlug,
  86. projectSlug,
  87. profileId,
  88. });
  89. return {
  90. pathname,
  91. query: {
  92. ...query,
  93. },
  94. };
  95. }
  96. export function generateProfileFlamechartRouteWithHighlightFrame({
  97. orgSlug,
  98. projectSlug,
  99. profileId,
  100. frameName,
  101. framePackage,
  102. query,
  103. }: {
  104. frameName: string;
  105. framePackage: string | undefined;
  106. orgSlug: Organization['slug'];
  107. profileId: Trace['id'];
  108. projectSlug: Project['slug'];
  109. query?: Location['query'];
  110. }): LocationDescriptor {
  111. return generateProfileFlamechartRouteWithQuery({
  112. orgSlug,
  113. projectSlug,
  114. profileId,
  115. query: {
  116. ...query,
  117. frameName,
  118. framePackage,
  119. },
  120. });
  121. }