diff --git a/.changeset/thirty-years-smile.md b/.changeset/thirty-years-smile.md new file mode 100644 index 00000000..d2a839ff --- /dev/null +++ b/.changeset/thirty-years-smile.md @@ -0,0 +1,6 @@ +--- +"@hyperdx/app": patch +--- + +fix: localmode stops prematurely fetching data +fix: users do not have to keep defining sources during onboarding modal if they already have sources diff --git a/packages/app/src/components/OnboardingModal.tsx b/packages/app/src/components/OnboardingModal.tsx index 8a36ae26..89345643 100644 --- a/packages/app/src/components/OnboardingModal.tsx +++ b/packages/app/src/components/OnboardingModal.tsx @@ -234,6 +234,18 @@ function OnboardingModalComponent({ setStep(startStep); } }, [startStep, step]); + useEffect(() => { + if ( + (step === 'auto-detect' || step === 'source') && + sources && + sources.length > 0 + ) { + // Sources may load in late once a connection is defined. + // If this happens, close the modal, we don't want to bother the user + // by forcing redefining their sources + setStep('closed'); + } + }, [step, sources]); const createSourceMutation = useCreateSource(); const createConnectionMutation = useCreateConnection(); diff --git a/packages/app/src/connection.ts b/packages/app/src/connection.ts index 1aa7a684..3ed38168 100644 --- a/packages/app/src/connection.ts +++ b/packages/app/src/connection.ts @@ -97,6 +97,7 @@ export function useCreateConnection() { }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['connections'] }); + queryClient.invalidateQueries({ queryKey: ['sources'] }); }, }); } diff --git a/packages/app/src/source.ts b/packages/app/src/source.ts index ee3c77fe..153b0206 100644 --- a/packages/app/src/source.ts +++ b/packages/app/src/source.ts @@ -27,6 +27,8 @@ import { HDX_LOCAL_DEFAULT_SOURCES } from '@/config'; import { IS_LOCAL_MODE } from '@/config'; import { parseJSON } from '@/utils'; +import { getLocalConnections } from './connection'; + // Columns for the sessions table as of OTEL Collector v0.129.1 export const SESSION_TABLE_EXPRESSIONS = { resourceAttributesExpression: 'ResourceAttributes', @@ -47,7 +49,8 @@ function setLocalSources(fn: (prev: TSource[]) => TSource[]) { } function getLocalSources(): TSource[] { - if (store.has(LOCAL_STORE_SOUCES_KEY)) { + const connections = getLocalConnections(); + if (connections.length > 0 && store.has(LOCAL_STORE_SOUCES_KEY)) { return store.get(LOCAL_STORE_SOUCES_KEY, []) ?? []; } // pull sources from env var