123456789101112131415161718192021222324252627282930313233343536373839 |
- import {Sort} from 'sentry/utils/discover/fields';
- import {USE_STORED_SCORES} from 'sentry/views/performance/browser/webVitals/settings';
- import {useTransactionRawWebVitalsQuery} from 'sentry/views/performance/browser/webVitals/utils/queries/rawWebVitalsQueries/useTransactionRawWebVitalsQuery';
- import {useTransactionWebVitalsScoresQuery} from 'sentry/views/performance/browser/webVitals/utils/queries/storedScoreQueries/useTransactionWebVitalsScoresQuery';
- import {WebVitals} from 'sentry/views/performance/browser/webVitals/utils/types';
- type Props = {
- defaultSort?: Sort;
- limit?: number;
- orderBy?: WebVitals | null;
- sortName?: string;
- transaction?: string | null;
- };
- export const useTransactionWebVitalsQuery = ({
- limit,
- transaction,
- defaultSort,
- sortName = 'sort',
- }: Props) => {
- const storedScoresResult = useTransactionWebVitalsScoresQuery({
- limit,
- transaction,
- defaultSort,
- sortName,
- enabled: USE_STORED_SCORES,
- });
- const rawWebVitalsResult = useTransactionRawWebVitalsQuery({
- limit,
- transaction,
- defaultSort,
- sortName,
- enabled: !USE_STORED_SCORES,
- });
- if (USE_STORED_SCORES) {
- return storedScoresResult;
- }
- return rawWebVitalsResult;
- };
|