Skip to content

Commit c00a24f

Browse files
committed
fix(seer): Clear cache for /seer/onboarding-check/ api response, and iterate on seer config reminder
1 parent b62f69f commit c00a24f

File tree

12 files changed

+130
-73
lines changed

12 files changed

+130
-73
lines changed

static/app/components/events/autofix/v1/drawer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {useMemo} from 'react';
2+
import {useQuery} from '@tanstack/react-query';
23

34
import {Flex} from '@sentry/scraps/layout';
45

@@ -13,8 +14,8 @@ import {Placeholder} from 'sentry/components/placeholder';
1314
import type {Event} from 'sentry/types/event';
1415
import type {Group} from 'sentry/types/group';
1516
import type {Project} from 'sentry/types/project';
17+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
1618
import {useOrganization} from 'sentry/utils/useOrganization';
17-
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
1819
import {useAiConfig} from 'sentry/views/issueDetails/streamline/hooks/useAiConfig';
1920

2021
interface SeerDrawerProps {
@@ -70,7 +71,7 @@ function InnerSeerDrawer({
7071
aiConfig,
7172
}: InnerSeerDrawerProps) {
7273
const organization = useOrganization();
73-
const {isPending, data} = useSeerOnboardingCheck();
74+
const {isPending, data} = useQuery(getSeerOnboardingCheckQueryOptions({organization}));
7475

7576
const seatBasedSeer = organization.features.includes('seat-based-seer-enabled');
7677

static/app/components/events/autofix/v2/autofixConfigureSeer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Fragment, type CSSProperties} from 'react';
22
import styled from '@emotion/styled';
3+
import {useQuery} from '@tanstack/react-query';
34

45
import seerConfigSeerImg from 'sentry-images/spot/seer-config-seer.svg';
56
import seerConfigShipImg from 'sentry-images/spot/seer-config-ship.svg';
@@ -19,9 +20,9 @@ import {t} from 'sentry/locale';
1920
import type {Event} from 'sentry/types/event';
2021
import type {Group} from 'sentry/types/group';
2122
import type {Project} from 'sentry/types/project';
23+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
2224
import {MarkedText} from 'sentry/utils/marked/markedText';
2325
import {useOrganization} from 'sentry/utils/useOrganization';
24-
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
2526

2627
export const AiSetupConfiguration = HookOrDefault({
2728
hookName: 'component:ai-setup-configuration',
@@ -44,7 +45,7 @@ interface AutofixConfigureSeerProps {
4445

4546
export function AutofixConfigureSeer({event, group, project}: AutofixConfigureSeerProps) {
4647
const organization = useOrganization();
47-
const {data: setupCheck} = useSeerOnboardingCheck();
48+
const {data: setupCheck} = useQuery(getSeerOnboardingCheckQueryOptions({organization}));
4849
const {data, isPending, isError} = useGroupSummary(group, event, project);
4950

5051
const orgNeedsToConfigureSeer =
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type {Organization} from 'sentry/types/organization';
2+
import {apiOptions} from 'sentry/utils/api/apiOptions';
3+
4+
interface SeerOnboardingCheckResponse {
5+
hasSupportedScmIntegration: boolean;
6+
isAutofixEnabled: boolean;
7+
isCodeReviewEnabled: boolean;
8+
isSeerConfigured: boolean;
9+
needsConfigReminder: boolean;
10+
}
11+
12+
interface Props {
13+
organization: Organization;
14+
staleTime?: number;
15+
}
16+
17+
export function getSeerOnboardingCheckQueryOptions({organization, staleTime = 0}: Props) {
18+
return apiOptions.as<SeerOnboardingCheckResponse>()(
19+
'/organizations/$organizationIdOrSlug/seer/onboarding-check/',
20+
{
21+
path: {
22+
organizationIdOrSlug: organization.slug,
23+
},
24+
staleTime,
25+
}
26+
);
27+
}

static/app/utils/useSeerOnboardingCheck.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

static/app/views/issueDetails/streamline/sidebar/autofixSection.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {useCallback, useMemo, type CSSProperties} from 'react';
22
import styled from '@emotion/styled';
3+
import {useQuery} from '@tanstack/react-query';
34

45
import seerConfigConnectImg from 'sentry-images/spot/seer-config-connect-2.svg';
56

@@ -39,11 +40,11 @@ import {t} from 'sentry/locale';
3940
import type {Event} from 'sentry/types/event';
4041
import type {Group} from 'sentry/types/group';
4142
import type {Project} from 'sentry/types/project';
43+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
4244
import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
4345
import {useRouteAnalyticsParams} from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
4446
import {useLocation} from 'sentry/utils/useLocation';
4547
import {useOrganization} from 'sentry/utils/useOrganization';
46-
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
4748
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
4849
import {SidebarFoldSection} from 'sentry/views/issueDetails/streamline/foldSection';
4950
import {useAiConfig} from 'sentry/views/issueDetails/streamline/hooks/useAiConfig';
@@ -125,7 +126,9 @@ export interface AutofixContentProps {
125126
export function AutofixContent({aiConfig, group, project, event}: AutofixContentProps) {
126127
const organization = useOrganization();
127128
const autofix = useExplorerAutofix(group.id);
128-
const {data: setupCheck, isPending} = useSeerOnboardingCheck();
129+
const {data: setupCheck, isPending} = useQuery(
130+
getSeerOnboardingCheckQueryOptions({organization})
131+
);
129132

130133
useAutoTriggerAutofix({autofix, group});
131134

static/app/views/settings/seer/overview/codeReviewOverviewSection.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {t, tct, tn} from 'sentry/locale';
2020
import {DEFAULT_CODE_REVIEW_TRIGGERS} from 'sentry/types/integrations';
2121
import type {Organization} from 'sentry/types/organization';
2222
import {useFetchAllPages} from 'sentry/utils/api/apiFetch';
23+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
2324
import {useInfiniteQuery, useQueryClient} from 'sentry/utils/queryClient';
2425
import {fetchMutation} from 'sentry/utils/queryClient';
2526
import {useOrganization} from 'sentry/utils/useOrganization';
@@ -94,6 +95,10 @@ export function CodeReviewOverviewSection({
9495
if (queryKey) {
9596
queryClient.invalidateQueries({queryKey});
9697
}
98+
// Invalidate the onboarding check query to get the updated settings
99+
queryClient.invalidateQueries({
100+
queryKey: getSeerOnboardingCheckQueryOptions({organization}).queryKey,
101+
});
97102
(mutations ?? []).forEach(mutation => {
98103
// Invalidate related queries
99104
queryClient.invalidateQueries({

static/gsApp/components/primaryNavSeerConfigReminder.tsx

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import {LinkButton} from '@sentry/scraps/button';
44
import {Flex, Stack} from '@sentry/scraps/layout';
55
import {Heading, Text} from '@sentry/scraps/text';
66

7+
import {bulkAutofixAutomationSettingsInfiniteOptions} from 'sentry/components/events/autofix/preferences/hooks/useBulkAutofixAutomationSettings';
78
import {IconSeer} from 'sentry/icons';
89
import {t} from 'sentry/locale';
910
import type {Integration} from 'sentry/types/integrations';
1011
import type {Organization} from 'sentry/types/organization';
1112
import {trackAnalytics} from 'sentry/utils/analytics';
13+
import {useFetchAllPages} from 'sentry/utils/api/apiFetch';
1214
import {getApiUrl} from 'sentry/utils/api/getApiUrl';
15+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
1316
import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
14-
import {useApiQuery} from 'sentry/utils/queryClient';
17+
import {useApiQuery, useInfiniteQuery, useQuery} from 'sentry/utils/queryClient';
1518
import {useOrganization} from 'sentry/utils/useOrganization';
1619
import {
1720
PrimaryNavigation,
@@ -124,40 +127,70 @@ function useCanSeeReminder(organization: Organization) {
124127

125128
function useReminderCopywriting() {
126129
const organization = useOrganization();
127-
const {initialStep} = useSeerOnboardingStep();
130+
128131
const hasSeatBasedSeer = organization.features.includes('seat-based-seer-enabled');
129-
const hasLegacySeer = organization.features.includes('seer-added');
130132

131-
const descriptionByStep: Record<Steps, {description: string; title: string} | null> = {
132-
[Steps.CONNECT_GITHUB]: {
133+
const autofixResult = useInfiniteQuery({
134+
...bulkAutofixAutomationSettingsInfiniteOptions({
135+
organization,
136+
}),
137+
staleTime: 60_000,
138+
select: ({pages}) => pages.flatMap(page => page.json),
139+
});
140+
useFetchAllPages({result: autofixResult});
141+
142+
const {data: autofixSettings, isPending: isAutofixPending} = autofixResult;
143+
144+
const {
145+
isPending: isOnboardingPending,
146+
isError: isOnboardingError,
147+
data: onboardingData,
148+
} = useQuery(getSeerOnboardingCheckQueryOptions({organization, staleTime: 60_000}));
149+
150+
if (!hasSeatBasedSeer || isOnboardingPending || isOnboardingError || isAutofixPending) {
151+
return null;
152+
}
153+
const {hasSupportedScmIntegration, isCodeReviewEnabled} = onboardingData;
154+
const hasAutofix = autofixSettings?.some(s => s.reposCount > 0);
155+
156+
if (!hasSupportedScmIntegration) {
157+
return {
133158
title: t('Connect GitHub'),
134159
description: t(
135-
'Seer is enabled, but Github is not connected. Connect your GitHub account to enable Root Cause Analysis and Code Review.'
160+
'Seer is enabled, but Github is not connected. Connect your GitHub account to enable Autofix and Code Review.'
161+
),
162+
};
163+
}
164+
165+
if (!hasAutofix) {
166+
return {
167+
title: (
168+
<Flex align="center" gap="sm">
169+
<IconSeer />
170+
{t('Start using Autofix')}
171+
</Flex>
136172
),
137-
},
138-
[Steps.SETUP_ROOT_CAUSE_ANALYSIS]: {
139-
title: t('Start using Seer\u2019s Issue Autofix'),
140173
description: t(
141-
'Seer is enabled but Root Cause Analysis is not configured. Configure Seer to automatically look at issues and generate code fixes.'
174+
'Seer is enabled but projects are not connected to repos. Connecting your source code and run Root Cause Analysis, Solution generation, and PR creation.'
175+
),
176+
};
177+
}
178+
179+
if (!isCodeReviewEnabled) {
180+
return {
181+
title: (
182+
<Flex align="center" gap="sm">
183+
<IconSeer />
184+
{t('Start using Code Review')}
185+
</Flex>
142186
),
143-
},
144-
[Steps.SETUP_CODE_REVIEW]: {
145-
title: t('Start using Seer\u2019s AI Code Review'),
146187
description: t(
147188
'Seer is enabled but Code Review is not configured. Configure Seer to automatically review PRs and flag potential issues.'
148189
),
149-
},
150-
[Steps.SETUP_DEFAULTS]: null,
151-
[Steps.WRAP_UP]: null,
152-
};
153-
154-
if (hasSeatBasedSeer) {
155-
return descriptionByStep[initialStep];
190+
};
156191
}
157-
if (hasLegacySeer) {
158-
return descriptionByStep[Steps.SETUP_CODE_REVIEW];
159-
}
160-
return descriptionByStep[Steps.SETUP_ROOT_CAUSE_ANALYSIS];
192+
193+
return null;
161194
}
162195

163196
export function PrimaryNavSeerConfigReminder() {
@@ -200,11 +233,12 @@ export function PrimaryNavSeerConfigReminder() {
200233
/>
201234
{isOpen && (
202235
<PrimaryNavigation.ButtonOverlay overlayProps={overlayProps}>
203-
<Stack gap="lg" padding="xl">
236+
<Stack gap="xl">
204237
<Heading as="h3">{copy.title}</Heading>
205238
<Text>{copy.description}</Text>
206239
<Flex justify="start">
207240
<LinkButton
241+
size="sm"
208242
to={`/settings/${organization.slug}/seer/`}
209243
priority="primary"
210244
onClick={() => state.close()}

static/gsApp/views/seerAutomation/components/repoTable/seerRepoTable.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {IconSearch} from 'sentry/icons/iconSearch';
2626
import {t, tct} from 'sentry/locale';
2727
import type {RepositoryWithSettings} from 'sentry/types/integrations';
2828
import {useFetchAllPages} from 'sentry/utils/api/apiFetch';
29+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
2930
import {
3031
ListItemCheckboxProvider,
3132
useListItemCheckboxContext,
@@ -121,6 +122,9 @@ export function SeerRepoTable() {
121122
});
122123
},
123124
onSettled: mutations => {
125+
queryClient.invalidateQueries({
126+
queryKey: getSeerOnboardingCheckQueryOptions({organization}).queryKey,
127+
});
124128
(mutations ?? []).forEach(mutation => {
125129
queryClient.invalidateQueries({
126130
queryKey: getRepositoryWithSettingsQueryKey(organization, mutation.id),

static/gsApp/views/seerAutomation/components/seerConnectGitHubBanner.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import {useCallback} from 'react';
22
import {ThemeProvider} from '@emotion/react';
33
import styled from '@emotion/styled';
4+
import {useQuery} from '@tanstack/react-query';
45

56
import seerConfigMainBg from 'sentry-images/spot/seer-config-main-bg.svg';
67

78
import {Container, Flex, Grid, Stack} from '@sentry/scraps/layout';
89
import {Heading, Text} from '@sentry/scraps/text';
910

1011
import {t} from 'sentry/locale';
12+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
1113
import {useInvertedTheme} from 'sentry/utils/theme/useInvertedTheme';
12-
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
14+
import {useOrganization} from 'sentry/utils/useOrganization';
1315

1416
import {GithubButton} from 'getsentry/views/seerAutomation/onboarding/githubButton';
1517
import {SeerOnboardingProvider} from 'getsentry/views/seerAutomation/onboarding/hooks/seerOnboardingContext';
1618

1719
export function SeerConnectGitHubBanner() {
20+
const organization = useOrganization();
1821
const theme = useInvertedTheme();
1922

20-
const {data, isFetched, isError} = useSeerOnboardingCheck();
23+
const {data, isFetched, isError} = useQuery(
24+
getSeerOnboardingCheckQueryOptions({organization})
25+
);
2126

2227
const handleAddIntegration = useCallback(() => {
2328
window.location.reload();

static/gsApp/views/seerAutomation/components/seerWizardSetupBanner.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {ThemeProvider} from '@emotion/react';
22
import styled from '@emotion/styled';
3+
import {useQuery} from '@tanstack/react-query';
34

45
import seerConfigMainBg from 'sentry-images/spot/seer-config-main-bg.svg';
56

@@ -9,15 +10,17 @@ import {Heading, Text} from '@sentry/scraps/text';
910

1011
import {IconSeer} from 'sentry/icons';
1112
import {t} from 'sentry/locale';
13+
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
1214
import {useInvertedTheme} from 'sentry/utils/theme/useInvertedTheme';
1315
import {useOrganization} from 'sentry/utils/useOrganization';
14-
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
1516

1617
export function SeerWizardSetupBanner() {
1718
const organization = useOrganization();
1819
const theme = useInvertedTheme();
1920

20-
const {data, isFetched, isError} = useSeerOnboardingCheck();
21+
const {data, isFetched, isError} = useQuery(
22+
getSeerOnboardingCheckQueryOptions({organization})
23+
);
2124

2225
if (!isFetched || isError) {
2326
return null;

0 commit comments

Comments
 (0)