createUnnamedTransactionsDiscoverTarget.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {Location} from 'history';
  2. import {t} from 'sentry/locale';
  3. import {NewQuery, Organization} from 'sentry/types';
  4. import EventView from 'sentry/utils/discover/eventView';
  5. export const UNPARAMETERIZED_TRANSACTION = '<< unparameterized >>'; // Represents 'other' transactions with high cardinality names that were dropped on the metrics dataset.
  6. const SHOW_UNPARAM_BANNER = 'showUnparameterizedBanner';
  7. enum DiscoverQueryPageSource {
  8. PERFORMANCE = 'performance',
  9. DISCOVER = 'discover',
  10. }
  11. export function createUnnamedTransactionsDiscoverTarget(props: {
  12. location: Location;
  13. organization: Organization;
  14. source?: DiscoverQueryPageSource;
  15. }) {
  16. const fields =
  17. props.source === DiscoverQueryPageSource.DISCOVER
  18. ? ['transaction', 'project', 'transaction.source', 'epm()']
  19. : ['transaction', 'project', 'transaction.source', 'epm()', 'p50()', 'p95()'];
  20. const query: NewQuery = {
  21. id: undefined,
  22. name:
  23. props.source === DiscoverQueryPageSource.DISCOVER
  24. ? t('Unparameterized Transactions')
  25. : t('Performance - Unparameterized Transactions'),
  26. query: 'event.type:transaction transaction.source:"url"',
  27. projects: [],
  28. fields,
  29. version: 2,
  30. };
  31. const discoverEventView = EventView.fromNewQueryWithLocation(
  32. query,
  33. props.location
  34. ).withSorts([{field: 'epm', kind: 'desc'}]);
  35. const target = discoverEventView.getResultsViewUrlTarget(props.organization.slug);
  36. target.query[SHOW_UNPARAM_BANNER] = 'true';
  37. return target;
  38. }