Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions static/app/components/events/autofix/v1/drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useMemo} from 'react';
import {useQuery} from '@tanstack/react-query';

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

Expand All @@ -13,8 +14,8 @@ import {Placeholder} from 'sentry/components/placeholder';
import type {Event} from 'sentry/types/event';
import type {Group} from 'sentry/types/group';
import type {Project} from 'sentry/types/project';
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
import {useOrganization} from 'sentry/utils/useOrganization';
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
import {useAiConfig} from 'sentry/views/issueDetails/streamline/hooks/useAiConfig';

interface SeerDrawerProps {
Expand Down Expand Up @@ -70,7 +71,7 @@ function InnerSeerDrawer({
aiConfig,
}: InnerSeerDrawerProps) {
const organization = useOrganization();
const {isPending, data} = useSeerOnboardingCheck();
const {isPending, data} = useQuery(getSeerOnboardingCheckQueryOptions({organization}));

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Fragment, type CSSProperties} from 'react';
import styled from '@emotion/styled';
import {useQuery} from '@tanstack/react-query';

import seerConfigSeerImg from 'sentry-images/spot/seer-config-seer.svg';
import seerConfigShipImg from 'sentry-images/spot/seer-config-ship.svg';
Expand All @@ -19,9 +20,9 @@ import {t} from 'sentry/locale';
import type {Event} from 'sentry/types/event';
import type {Group} from 'sentry/types/group';
import type {Project} from 'sentry/types/project';
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
import {MarkedText} from 'sentry/utils/marked/markedText';
import {useOrganization} from 'sentry/utils/useOrganization';
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';

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

export function AutofixConfigureSeer({event, group, project}: AutofixConfigureSeerProps) {
const organization = useOrganization();
const {data: setupCheck} = useSeerOnboardingCheck();
const {data: setupCheck} = useQuery(getSeerOnboardingCheckQueryOptions({organization}));
const {data, isPending, isError} = useGroupSummary(group, event, project);

const orgNeedsToConfigureSeer =
Expand Down
2 changes: 1 addition & 1 deletion static/app/utils/analytics/seerAnalyticsEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export type SeerAnalyticsEventsParameters = {
user_id: string;
};
'seer.config_reminder.rendered': {
can_write_settings: boolean;
has_code_review_beta: boolean;
has_legacy_seer: boolean;
has_seat_based_seer: boolean;
initial_step: string;
};
'seer.explorer.feedback_submitted': {
block_index: number;
Expand Down
27 changes: 27 additions & 0 deletions static/app/utils/getSeerOnboardingCheckQueryOptions.tsx
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these query option generators be in their own subdir?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah idk about this yet. i tried making an endpoints/ directory and got discouraged by the ownership rules for it :(

missing patterns here but idk what it should be yet. Ideally we'll have the base *QueryOptions for everything, they could be generated even (only like 19k lines) and then on top of that have onMutate, onError, onSettled callbacks that import the keys, and manage different optimistsic updates and cache-clearing calls.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type {Organization} from 'sentry/types/organization';
import {apiOptions} from 'sentry/utils/api/apiOptions';

interface SeerOnboardingCheckResponse {
hasSupportedScmIntegration: boolean;
isAutofixEnabled: boolean;
isCodeReviewEnabled: boolean;
isSeerConfigured: boolean;
needsConfigReminder: boolean;
}

interface Props {
organization: Organization;
staleTime?: number;
}

export function getSeerOnboardingCheckQueryOptions({organization, staleTime = 0}: Props) {
return apiOptions.as<SeerOnboardingCheckResponse>()(
'/organizations/$organizationIdOrSlug/seer/onboarding-check/',
{
path: {
organizationIdOrSlug: organization.slug,
},
staleTime,
}
);
}
33 changes: 0 additions & 33 deletions static/app/utils/useSeerOnboardingCheck.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useCallback, useMemo, type CSSProperties} from 'react';
import styled from '@emotion/styled';
import {useQuery} from '@tanstack/react-query';

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

Expand Down Expand Up @@ -39,11 +40,11 @@ import {t} from 'sentry/locale';
import type {Event} from 'sentry/types/event';
import type {Group} from 'sentry/types/group';
import type {Project} from 'sentry/types/project';
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
import {useRouteAnalyticsParams} from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
import {useLocation} from 'sentry/utils/useLocation';
import {useOrganization} from 'sentry/utils/useOrganization';
import {useSeerOnboardingCheck} from 'sentry/utils/useSeerOnboardingCheck';
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {SidebarFoldSection} from 'sentry/views/issueDetails/streamline/foldSection';
import {useAiConfig} from 'sentry/views/issueDetails/streamline/hooks/useAiConfig';
Expand Down Expand Up @@ -125,7 +126,9 @@ export interface AutofixContentProps {
export function AutofixContent({aiConfig, group, project, event}: AutofixContentProps) {
const organization = useOrganization();
const autofix = useExplorerAutofix(group.id);
const {data: setupCheck, isPending} = useSeerOnboardingCheck();
const {data: setupCheck, isPending} = useQuery(
getSeerOnboardingCheckQueryOptions({organization})
);

useAutoTriggerAutofix({autofix, group});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {t, tct, tn} from 'sentry/locale';
import {DEFAULT_CODE_REVIEW_TRIGGERS} from 'sentry/types/integrations';
import type {Organization} from 'sentry/types/organization';
import {useFetchAllPages} from 'sentry/utils/api/apiFetch';
import {getSeerOnboardingCheckQueryOptions} from 'sentry/utils/getSeerOnboardingCheckQueryOptions';
import {useInfiniteQuery, useQueryClient} from 'sentry/utils/queryClient';
import {fetchMutation} from 'sentry/utils/queryClient';
import {useOrganization} from 'sentry/utils/useOrganization';
Expand Down Expand Up @@ -94,6 +95,10 @@ export function CodeReviewOverviewSection({
if (queryKey) {
queryClient.invalidateQueries({queryKey});
}
// Invalidate the onboarding check query to get the updated settings
queryClient.invalidateQueries({
queryKey: getSeerOnboardingCheckQueryOptions({organization}).queryKey,
});
(mutations ?? []).forEach(mutation => {
// Invalidate related queries
queryClient.invalidateQueries({
Expand Down
Loading
Loading