noDataDueToOldSDKMessage.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {tct} from 'sentry/locale';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import usePageFilters from 'sentry/utils/usePageFilters';
  6. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  7. import {useIneligibleProjects} from 'sentry/views/performance/database/useIneligibleProjects';
  8. import {useHasAnySpanMetrics} from 'sentry/views/starfish/queries/useHasAnySpanMetrics';
  9. interface Props {
  10. Wrapper?: React.ComponentType;
  11. }
  12. function DivWrapper(props) {
  13. return <div {...props} />;
  14. }
  15. export function NoDataDueToOldSDKMessage({Wrapper = DivWrapper}: Props) {
  16. const {selection, isReady: pageFilterIsReady} = usePageFilters();
  17. const options = {
  18. projectId: pageFilterIsReady
  19. ? selection.projects.map(projectId => projectId.toString())
  20. : undefined,
  21. enabled: pageFilterIsReady,
  22. };
  23. const {hasMetrics} = useHasAnySpanMetrics(options);
  24. const {ineligibleProjects} = useIneligibleProjects(options);
  25. const organization = useOrganization();
  26. const hasMoreIneligibleProjectsThanVisible =
  27. ineligibleProjects.length > MAX_LISTED_PROJECTS;
  28. if (hasMetrics) {
  29. return null;
  30. }
  31. if (ineligibleProjects.length < 1) {
  32. return null;
  33. }
  34. const listedProjects = ineligibleProjects.slice(0, MAX_LISTED_PROJECTS + 1);
  35. return (
  36. <Wrapper>
  37. {tct(
  38. "You may be missing data due to outdated SDKs. Please refer to Sentry's [documentation:documentation] for more information. Projects with outdated SDKs: [projectList]",
  39. {
  40. documentation: (
  41. <ExternalLink href="https://docs.sentry.io/product/performance/query-insights/" />
  42. ),
  43. projectList: (
  44. <Fragment>
  45. {listedProjects.map((project, projectIndex) => {
  46. return (
  47. <span key={project.id}>
  48. <a
  49. href={normalizeUrl(
  50. `/organizations/${organization.slug}/projects/${project.slug}/`
  51. )}
  52. >
  53. {project.name}
  54. </a>
  55. {projectIndex < listedProjects.length - 1 && ', '}
  56. </span>
  57. );
  58. })}
  59. </Fragment>
  60. ),
  61. }
  62. )}
  63. {hasMoreIneligibleProjectsThanVisible
  64. ? tct(' and [count] more', {
  65. count: ineligibleProjects.length - MAX_LISTED_PROJECTS,
  66. })
  67. : ''}
  68. </Wrapper>
  69. );
  70. }
  71. const MAX_LISTED_PROJECTS = 3;