Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: handle redirect in onboarding (#6324)

Yunus M860145fb1db3
diff --git a/frontend/src/AppRoutes/index.tsx b/frontend/src/AppRoutes/index.tsx
index cf17fd4db3..2d0f4231cc 100644
--- a/frontend/src/AppRoutes/index.tsx
+++ b/frontend/src/AppRoutes/index.tsx
@@ -37,6 +37,7 @@ import {
UPDATE_ORG_PREFERENCES,
} from 'types/actions/app';
import AppReducer, { User } from 'types/reducer/app';
+import { USER_ROLES } from 'types/roles';
import { extractDomain, isCloudUser, isEECloudUser } from 'utils/app';
import PrivateRoute from './Private';
@@ -74,7 +75,7 @@ function App(): JSX.Element {
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
queryFn: () => getAllOrgPreferences(),
queryKey: ['getOrgPreferences'],
- enabled: isLoggedInState,
+ enabled: isLoggedInState && role === USER_ROLES.ADMIN,
});
useEffect(() => {
@@ -95,6 +96,17 @@ function App(): JSX.Element {
}
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
+ useEffect(() => {
+ if (isLoggedInState && role !== USER_ROLES.ADMIN) {
+ dispatch({
+ type: UPDATE_IS_FETCHING_ORG_PREFERENCES,
+ payload: {
+ isFetchingOrgPreferences: false,
+ },
+ });
+ }
+ }, [isLoggedInState, role, dispatch]);
+
const featureResponse = useGetFeatureFlag((allFlags) => {
dispatch({
type: UPDATE_FEATURE_FLAG_RESPONSE,
diff --git a/frontend/src/container/OnboardingQuestionaire/index.tsx b/frontend/src/container/OnboardingQuestionaire/index.tsx
index 1917cd7a55..4cb3ecaa80 100644
--- a/frontend/src/container/OnboardingQuestionaire/index.tsx
+++ b/frontend/src/container/OnboardingQuestionaire/index.tsx
@@ -25,6 +25,7 @@ import {
UPDATE_ORG_PREFERENCES,
} from 'types/actions/app';
import AppReducer from 'types/reducer/app';
+import { USER_ROLES } from 'types/roles';
import {
AboutSigNozQuestions,
@@ -69,7 +70,10 @@ const INITIAL_OPTIMISE_SIGNOZ_DETAILS: OptimiseSignozDetails = {
function OnboardingQuestionaire(): JSX.Element {
const { notifications } = useNotifications();
- const { org } = useSelector<AppState, AppReducer>((state) => state.app);
+ const { org, role, isLoggedIn: isLoggedInState } = useSelector<
+ AppState,
+ AppReducer
+ >((state) => state.app);
const [currentStep, setCurrentStep] = useState<number>(1);
const [orgDetails, setOrgDetails] = useState<OrgDetails>(INITIAL_ORG_DETAILS);
const [signozDetails, setSignozDetails] = useState<SignozDetails>(
@@ -103,12 +107,13 @@ function OnboardingQuestionaire(): JSX.Element {
} = useQuery({
queryFn: () => getOrgPreference({ preferenceID: 'ORG_ONBOARDING' }),
queryKey: ['getOrgPreferences', 'ORG_ONBOARDING'],
+ enabled: role === USER_ROLES.ADMIN,
});
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
queryFn: () => getAllOrgPreferences(),
queryKey: ['getOrgPreferences'],
- enabled: isOnboardingComplete,
+ enabled: isOnboardingComplete && role === USER_ROLES.ADMIN,
});
useEffect(() => {
@@ -129,6 +134,17 @@ function OnboardingQuestionaire(): JSX.Element {
}
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
+ useEffect(() => {
+ if (isLoggedInState && role !== USER_ROLES.ADMIN) {
+ dispatch({
+ type: UPDATE_IS_FETCHING_ORG_PREFERENCES,
+ payload: {
+ isFetchingOrgPreferences: false,
+ },
+ });
+ }
+ }, [isLoggedInState, role, dispatch]);
+
useEffect(() => {
if (
!isLoadingOnboardingPreference &&