utils.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type {Query} from 'history';
  2. import {decodeScalar} from 'sentry/utils/queryString';
  3. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  4. import type {DomainView} from 'sentry/views/insights/pages/useFilters';
  5. import {getTransactionSummaryBaseUrl} from 'sentry/views/performance/transactionSummary/utils';
  6. export function aggregateWaterfallRouteWithQuery({
  7. orgSlug,
  8. transaction,
  9. projectID,
  10. query,
  11. view,
  12. }: {
  13. orgSlug: string;
  14. query: Query;
  15. transaction: string;
  16. projectID?: string | string[];
  17. view?: DomainView;
  18. }) {
  19. const pathname = `${getTransactionSummaryBaseUrl(orgSlug, view)}/aggregateWaterfall/`;
  20. const filter = decodeScalar(query.query);
  21. let httpMethod: string | undefined = undefined;
  22. if (filter) {
  23. const search = new MutableSearch(filter);
  24. const method = search.tokens.find(token => token.key === 'http.method');
  25. if (method) {
  26. httpMethod = method.value;
  27. }
  28. }
  29. return {
  30. pathname,
  31. query: {
  32. transaction,
  33. project: projectID,
  34. environment: query.environment,
  35. statsPeriod: query.statsPeriod,
  36. start: query.start,
  37. end: query.end,
  38. query: query.query,
  39. ...(httpMethod ? {'http.method': httpMethod} : null),
  40. },
  41. };
  42. }