Browse Source

chore(starfish): Call test endpoint in a couple places (#49001)

Calling the endpoint introduced in
https://github.com/getsentry/sentry/pull/49000
so we can introduce some regressions
Shruthi 1 year ago
parent
commit
11132b05a0

+ 10 - 1
static/app/views/dashboards/manage/index.tsx

@@ -56,6 +56,7 @@ type State = {
   dashboards: DashboardListItem[] | null;
   dashboardsPageLinks: string;
   showTemplates: boolean;
+  starfishResult?: null;
 } & AsyncView['state'];
 
 class ManageDashboards extends AsyncView<Props, State> {
@@ -68,7 +69,7 @@ class ManageDashboards extends AsyncView<Props, State> {
 
   getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
     const {organization, location} = this.props;
-    return [
+    const endpoints: ReturnType<AsyncView['getEndpoints']> = [
       [
         'dashboards',
         `/organizations/${organization.slug}/dashboards/`,
@@ -81,6 +82,14 @@ class ManageDashboards extends AsyncView<Props, State> {
         },
       ],
     ];
+    if (organization.features.includes('starfish-test-endpoint')) {
+      endpoints.push([
+        'starfishResult',
+        `/organizations/${organization.slug}/events-starfish/`,
+        {query: {statsPeriod: '7d'}},
+      ]);
+    }
+    return endpoints;
   }
 
   getActiveSort() {

+ 15 - 1
static/app/views/discover/homepage.tsx

@@ -6,6 +6,7 @@ import AsyncComponent from 'sentry/components/asyncComponent';
 import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
 import {
   getDatetimeFromState,
+  normalizeDateTimeParams,
   normalizeDateTimeString,
 } from 'sentry/components/organizations/pageFilters/parse';
 import {getPageFilterStorage} from 'sentry/components/organizations/pageFilters/persistence';
@@ -29,6 +30,7 @@ type Props = {
 
 type HomepageQueryState = AsyncComponent['state'] & {
   savedQuery?: SavedQuery | null;
+  starfishResult?: null;
 };
 
 class HomepageQueryAPI extends AsyncComponent<Props, HomepageQueryState> {
@@ -81,7 +83,12 @@ class HomepageQueryAPI extends AsyncComponent<Props, HomepageQueryState> {
   }
 
   getEndpoints(): ReturnType<AsyncComponent['getEndpoints']> {
-    const {organization} = this.props;
+    const {organization, selection} = this.props;
+    const {projects, environments, datetime} = selection;
+    const commonQuery = {
+      environment: environments,
+      project: projects.map(proj => String(proj)),
+    };
 
     const endpoints: ReturnType<AsyncComponent['getEndpoints']> = [];
     if (organization.features.includes('discover-query')) {
@@ -90,6 +97,13 @@ class HomepageQueryAPI extends AsyncComponent<Props, HomepageQueryState> {
         `/organizations/${organization.slug}/discover/homepage/`,
       ]);
     }
+    if (organization.features.includes('starfish-test-endpoint')) {
+      endpoints.push([
+        'starfishResult',
+        `/organizations/${organization.slug}/events-starfish/`,
+        {query: {...commonQuery, ...normalizeDateTimeParams(datetime)}},
+      ]);
+    }
     return endpoints;
   }
 

+ 25 - 0
static/app/views/starfish/modules/APIModule/APIModuleView.tsx

@@ -6,9 +6,12 @@ import moment from 'moment';
 
 import {CompactSelect} from 'sentry/components/compactSelect';
 import DatePageFilter from 'sentry/components/datePageFilter';
+import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import {Series} from 'sentry/types/echarts';
+import {useApiQuery} from 'sentry/utils/queryClient';
+import useOrganization from 'sentry/utils/useOrganization';
 import usePageFilters from 'sentry/utils/usePageFilters';
 import Chart from 'sentry/views/starfish/components/chart';
 import ChartPanel from 'sentry/views/starfish/components/chartPanel';
@@ -59,6 +62,7 @@ export default function APIModuleView({location, onSelect}: Props) {
     transaction: '',
   });
   const endpointTableRef = useRef<HTMLInputElement>(null);
+  const organization = useOrganization();
 
   const endpointsDomainEventView = getEndpointDomainsEventView({
     datetime: pageFilter.selection.datetime,
@@ -67,6 +71,27 @@ export default function APIModuleView({location, onSelect}: Props) {
     datetime: pageFilter.selection.datetime,
   });
 
+  const {selection} = pageFilter;
+  const {projects, environments, datetime} = selection;
+
+  useApiQuery<null>(
+    [
+      `/organizations/${organization.slug}/events-starfish/`,
+      {
+        query: {
+          ...{
+            environment: environments,
+            project: projects.map(proj => String(proj)),
+          },
+          ...normalizeDateTimeParams(datetime),
+        },
+      },
+    ],
+    {
+      staleTime: 10,
+    }
+  );
+
   const {isLoading: _isDomainsLoading, data: domains} = useSpansQuery({
     eventView: endpointsDomainEventView,
     queryString: endpointsDomainQuery,

+ 23 - 2
static/app/views/starfish/modules/databaseModule/index.tsx

@@ -4,6 +4,7 @@ import moment from 'moment';
 
 import DatePageFilter from 'sentry/components/datePageFilter';
 import * as Layout from 'sentry/components/layouts/thirds';
+import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
 import TransactionNameSearchBar from 'sentry/components/performance/searchBar';
 import Switch from 'sentry/components/switchButton';
 import {t} from 'sentry/locale';
@@ -13,7 +14,7 @@ import {
   PageErrorAlert,
   PageErrorProvider,
 } from 'sentry/utils/performance/contexts/pageError';
-import {useQuery} from 'sentry/utils/queryClient';
+import {useApiQuery, useQuery} from 'sentry/utils/queryClient';
 import {MutableSearch} from 'sentry/utils/tokenizeSearch';
 import {useLocation} from 'sentry/utils/useLocation';
 import useOrganization from 'sentry/utils/useOrganization';
@@ -63,9 +64,29 @@ function DatabaseModule() {
     sortKey: sort.sortHeader?.key,
     sortDirection: sort.direction,
   });
-
   const pageFilters = usePageFilters();
 
+  const {selection} = pageFilters;
+  const {projects, environments, datetime} = selection;
+
+  useApiQuery<null>(
+    [
+      `/organizations/${organization.slug}/events-starfish/`,
+      {
+        query: {
+          ...{
+            environment: environments,
+            project: projects.map(proj => String(proj)),
+          },
+          ...normalizeDateTimeParams(datetime),
+        },
+      },
+    ],
+    {
+      staleTime: 10,
+    }
+  );
+
   const {data: dbAggregateData} = useQuery({
     queryKey: ['dbAggregates', transaction, filterNew, filterOld],
     queryFn: () =>

+ 22 - 0
static/app/views/starfish/views/webServiceView/starfishView.tsx

@@ -17,7 +17,9 @@ const EventsRequest = withApi(_EventsRequest);
 import {useTheme} from '@emotion/react';
 
 import {t} from 'sentry/locale';
+import {useApiQuery} from 'sentry/utils/queryClient';
 import {MutableSearch} from 'sentry/utils/tokenizeSearch';
+import usePageFilters from 'sentry/utils/usePageFilters';
 import withApi from 'sentry/utils/withApi';
 import FacetBreakdownBar from 'sentry/views/starfish/components/breakdownBar';
 import Chart from 'sentry/views/starfish/components/chart';
@@ -42,6 +44,26 @@ export function StarfishView(props: BasePerformanceViewProps) {
   const theme = useTheme();
   const [selectedSpike, setSelectedSpike] = useState<FailureSpike>(null);
 
+  const pageFilters = usePageFilters();
+  const {selection} = pageFilters;
+  const {projects, environments} = selection;
+
+  useApiQuery<null>(
+    [
+      `/organizations/${organization.slug}/events-starfish/`,
+      {
+        query: {
+          environment: environments,
+          project: projects.map(proj => String(proj)),
+          statsPeriod: '7d',
+        },
+      },
+    ],
+    {
+      staleTime: 10,
+    }
+  );
+
   function renderFailureRateChart() {
     const query = new MutableSearch(['event.type:transaction']);