utils.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import type {Query} from 'history';
  2. import type {Organization} from 'sentry/types/organization';
  3. import {decodeScalar} from 'sentry/utils/queryString';
  4. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  5. import type {DomainView} from 'sentry/views/insights/pages/useFilters';
  6. import {getTransactionSummaryBaseUrl} from 'sentry/views/performance/transactionSummary/utils';
  7. export function aggregateWaterfallRouteWithQuery({
  8. organization,
  9. transaction,
  10. projectID,
  11. query,
  12. view,
  13. }: {
  14. organization: Organization;
  15. query: Query;
  16. transaction: string;
  17. projectID?: string | string[];
  18. view?: DomainView;
  19. }) {
  20. const pathname = `${getTransactionSummaryBaseUrl(organization, view)}/aggregateWaterfall/`;
  21. const filter = decodeScalar(query.query);
  22. let httpMethod: string | undefined = undefined;
  23. if (filter) {
  24. const search = new MutableSearch(filter);
  25. const method = search.tokens.find(token => token.key === 'http.method');
  26. if (method) {
  27. httpMethod = method.value;
  28. }
  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. ...(httpMethod ? {'http.method': httpMethod} : null),
  41. },
  42. };
  43. }