utils.tsx 1.0 KB

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