From 86b4ea79de4e82ec76b8ea9cccc0d24d66162dfc Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Fri, 6 Mar 2026 19:31:28 -0300 Subject: [PATCH] perf: add enabled flag to TPA query hook to skip unnecessary fetches In ProgressiveProfiling, the TPA query fired even when registrationEmbedded was false and the result was ignored. Added an enabled option to useThirdPartyAuthHook and set it to registrationEmbedded in ProgressiveProfiling. Co-Authored-By: Claude Opus 4.6 --- src/common-components/data/apiHook.ts | 3 ++- src/progressive-profiling/ProgressiveProfiling.jsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common-components/data/apiHook.ts b/src/common-components/data/apiHook.ts index a09dfc59..f3bd4b73 100644 --- a/src/common-components/data/apiHook.ts +++ b/src/common-components/data/apiHook.ts @@ -6,11 +6,12 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys'; // Error constants export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error'; -const useThirdPartyAuthHook = (pageId, payload) => useQuery({ +const useThirdPartyAuthHook = (pageId, payload, { enabled = true } = {}) => useQuery({ queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload), queryFn: () => getThirdPartyAuthContext(payload), retry: false, staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session + enabled, }); export { diff --git a/src/progressive-profiling/ProgressiveProfiling.jsx b/src/progressive-profiling/ProgressiveProfiling.jsx index 320c22f3..b6c10105 100644 --- a/src/progressive-profiling/ProgressiveProfiling.jsx +++ b/src/progressive-profiling/ProgressiveProfiling.jsx @@ -77,7 +77,7 @@ const ProgressiveProfilingInner = () => { const [showModal, setShowModal] = useState(false); const { data, isSuccess, error } = useThirdPartyAuthHook(AUTHN_PROGRESSIVE_PROFILING, - { is_welcome_page: true, next: queryParams?.next }); + { is_welcome_page: true, next: queryParams?.next }, { enabled: registrationEmbedded }); useEffect(() => { if (registrationEmbedded) {