useProjectWebVitalsTimeseriesQuery.tsx 1.2 KB

1234567891011121314151617181920212223242526272829
  1. import type {Sort} from 'sentry/utils/discover/fields';
  2. import {useProjectRawWebVitalsTimeseriesQuery} from 'sentry/views/performance/browser/webVitals/utils/queries/rawWebVitalsQueries/useProjectRawWebVitalsTimeseriesQuery';
  3. import {useProjectWebVitalsScoresTimeseriesQuery} from 'sentry/views/performance/browser/webVitals/utils/queries/storedScoreQueries/useProjectWebVitalsScoresTimeseriesQuery';
  4. import type {WebVitals} from 'sentry/views/performance/browser/webVitals/utils/types';
  5. import {useStoredScoresSetting} from 'sentry/views/performance/browser/webVitals/utils/useStoredScoresSetting';
  6. type Props = {
  7. defaultSort?: Sort;
  8. limit?: number;
  9. orderBy?: WebVitals | null;
  10. sortName?: string;
  11. transaction?: string | null;
  12. };
  13. export const useProjectWebVitalsTimeseriesQuery = ({transaction}: Props) => {
  14. const shouldUseStoredScores = useStoredScoresSetting();
  15. const storedScoresResult = useProjectWebVitalsScoresTimeseriesQuery({
  16. transaction,
  17. enabled: shouldUseStoredScores,
  18. });
  19. const rawWebVitalsResult = useProjectRawWebVitalsTimeseriesQuery({
  20. transaction,
  21. enabled: !shouldUseStoredScores,
  22. });
  23. if (shouldUseStoredScores) {
  24. return storedScoresResult;
  25. }
  26. return rawWebVitalsResult;
  27. };