Files
2024-02-15 17:01:50 +00:00

33 lines
823 B
TypeScript

import type {LocationDescriptor, Query} from 'history';
import {spanTargetHash} from 'sentry/components/events/interfaces/spans/utils';
import type {Organization} from 'sentry/types';
import {defined} from 'sentry/utils';
export function getTransactionDetailsUrl(
orgSlug: Organization['slug'],
eventSlug: string,
transaction?: string,
query?: Query,
spanId?: string
): LocationDescriptor {
const locationQuery = {
...(query || {}),
transaction,
};
if (!defined(locationQuery.transaction)) {
delete locationQuery.transaction;
}
const target = {
pathname: `/organizations/${orgSlug}/performance/${eventSlug}/`,
query: locationQuery,
hash: defined(spanId) ? spanTargetHash(spanId) : undefined,
};
if (!defined(target.hash)) {
delete target.hash;
}
return target;
}