urls.ts 813 B

1234567891011121314151617181920212223242526272829303132
  1. import {LocationDescriptor, Query} from 'history';
  2. import {spanTargetHash} from 'sentry/components/events/interfaces/spans/utils';
  3. import {Organization} from 'sentry/types';
  4. import {defined} from 'sentry/utils';
  5. export function getTransactionDetailsUrl(
  6. orgSlug: Organization['slug'],
  7. eventSlug: string,
  8. transaction?: string,
  9. query?: Query,
  10. spanId?: string
  11. ): LocationDescriptor {
  12. const locationQuery = {
  13. ...(query || {}),
  14. transaction,
  15. };
  16. if (!defined(locationQuery.transaction)) {
  17. delete locationQuery.transaction;
  18. }
  19. const target = {
  20. pathname: `/organizations/${orgSlug}/performance/${eventSlug}/`,
  21. query: locationQuery,
  22. hash: defined(spanId) ? spanTargetHash(spanId) : undefined,
  23. };
  24. if (!defined(target.hash)) {
  25. delete target.hash;
  26. }
  27. return target;
  28. }