useResourcePageQuery.ts 1003 B

1234567891011121314151617181920212223242526272829303132333435
  1. import type {Sort} from 'sentry/utils/discover/fields';
  2. import {useSpanTransactionMetrics} from 'sentry/views/insights/common/queries/useSpanTransactionMetrics';
  3. import {SpanMetricsField, type SubregionCode} from 'sentry/views/insights/types';
  4. const {HTTP_RESPONSE_CONTENT_LENGTH, RESOURCE_RENDER_BLOCKING_STATUS} = SpanMetricsField;
  5. export const useResourcePagesQuery = (
  6. groupId: string,
  7. {
  8. sort,
  9. cursor,
  10. subregions,
  11. renderBlockingStatus,
  12. }: {
  13. sort: Sort;
  14. cursor?: string;
  15. renderBlockingStatus?: string;
  16. subregions?: SubregionCode[];
  17. }
  18. ) => {
  19. return useSpanTransactionMetrics(
  20. {
  21. 'span.group': groupId,
  22. ...(renderBlockingStatus
  23. ? {[RESOURCE_RENDER_BLOCKING_STATUS]: renderBlockingStatus}
  24. : {}),
  25. ...(subregions
  26. ? {[SpanMetricsField.USER_GEO_SUBREGION]: `[${subregions.join(',')}]`}
  27. : {}),
  28. },
  29. [sort],
  30. cursor,
  31. [`avg(${HTTP_RESPONSE_CONTENT_LENGTH})`, RESOURCE_RENDER_BLOCKING_STATUS]
  32. );
  33. };