2024-08-06 14:52:22 +00:00
|
|
|
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
|
2021-10-21 05:36:17 +00:00
|
|
|
import { requiresAuth } from "pages/UserAuth/requiresAuthHOC";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { useCallback } from "react";
|
|
|
|
|
import { useEffect } from "react";
|
2022-11-28 08:13:17 +00:00
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
2023-02-20 16:59:06 +00:00
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
2021-10-21 05:36:17 +00:00
|
|
|
import PerformanceTracker, {
|
|
|
|
|
PerformanceTransactionName,
|
|
|
|
|
} from "utils/PerformanceTracker";
|
2023-12-25 12:24:46 +00:00
|
|
|
import UserWelcomeScreen from "pages/setup/UserWelcomeScreen";
|
2022-05-04 08:43:02 +00:00
|
|
|
import { Center } from "pages/setup/common";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { Spinner } from "design-system";
|
2024-08-06 14:52:22 +00:00
|
|
|
import { isValidLicense } from "ee/selectors/tenantSelectors";
|
|
|
|
|
import { redirectUserAfterSignup } from "ee/utils/signupHelpers";
|
2023-07-12 06:42:16 +00:00
|
|
|
import { setUserSignedUpFlag } from "utils/storage";
|
2024-08-06 14:52:22 +00:00
|
|
|
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
|
2021-10-21 05:36:17 +00:00
|
|
|
|
|
|
|
|
export function SignupSuccess() {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const urlObject = new URL(window.location.href);
|
2023-01-10 05:39:15 +00:00
|
|
|
const redirectUrl = urlObject?.searchParams.get("redirectUrl") ?? "";
|
2021-10-21 05:36:17 +00:00
|
|
|
const shouldEnableFirstTimeUserOnboarding = urlObject?.searchParams.get(
|
|
|
|
|
"enableFirstTimeUserExperience",
|
|
|
|
|
);
|
2023-01-10 05:39:15 +00:00
|
|
|
const validLicense = useSelector(isValidLicense);
|
2023-07-12 06:42:16 +00:00
|
|
|
const user = useSelector(getCurrentUser);
|
|
|
|
|
|
2021-10-21 05:36:17 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
PerformanceTracker.stopTracking(PerformanceTransactionName.SIGN_UP);
|
2023-07-12 06:42:16 +00:00
|
|
|
user?.email && setUserSignedUpFlag(user?.email);
|
2021-10-21 05:36:17 +00:00
|
|
|
}, []);
|
|
|
|
|
|
2023-12-28 10:07:24 +00:00
|
|
|
const isNonInvitedUser = shouldEnableFirstTimeUserOnboarding === "true";
|
2023-11-09 04:19:02 +00:00
|
|
|
|
2023-01-10 05:39:15 +00:00
|
|
|
const redirectUsingQueryParam = useCallback(
|
|
|
|
|
() =>
|
|
|
|
|
redirectUserAfterSignup(
|
|
|
|
|
redirectUrl,
|
|
|
|
|
shouldEnableFirstTimeUserOnboarding,
|
|
|
|
|
validLicense,
|
|
|
|
|
dispatch,
|
2024-03-15 05:43:14 +00:00
|
|
|
isNonInvitedUser,
|
2023-01-10 05:39:15 +00:00
|
|
|
),
|
|
|
|
|
[],
|
|
|
|
|
);
|
2021-10-21 05:36:17 +00:00
|
|
|
|
2023-09-29 04:50:06 +00:00
|
|
|
const onGetStarted = useCallback((proficiency?: string, useCase?: string) => {
|
2021-10-21 05:36:17 +00:00
|
|
|
dispatch({
|
|
|
|
|
type: ReduxActionTypes.UPDATE_USER_DETAILS_INIT,
|
|
|
|
|
payload: {
|
2023-09-29 04:50:06 +00:00
|
|
|
proficiency,
|
2021-10-21 05:36:17 +00:00
|
|
|
useCase,
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-10-16 12:07:06 +00:00
|
|
|
AnalyticsUtil.logEvent("GET_STARTED_CLICKED", {
|
|
|
|
|
proficiency,
|
|
|
|
|
goal: useCase,
|
|
|
|
|
});
|
2021-10-21 05:36:17 +00:00
|
|
|
redirectUsingQueryParam();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Proceed with redirection,
|
|
|
|
|
* For a super user, since we already collected role and useCase during signup
|
|
|
|
|
* For a normal user, who has filled in their role and useCase and try to visit signup-success url by entering manually.
|
2022-06-15 15:37:41 +00:00
|
|
|
* For an invited user, we don't want to collect the data. we just want to redirect to the workspace they have been invited to.
|
2023-08-26 04:22:23 +00:00
|
|
|
* We identify an invited user based on `enableFirstTimeUserExperience` flag in url.
|
2021-10-21 05:36:17 +00:00
|
|
|
*/
|
|
|
|
|
//TODO(Balaji): Factor in case, where user had closed the tab, while filling the form.And logs back in again.
|
|
|
|
|
if (
|
|
|
|
|
user?.isSuperUser ||
|
2023-12-25 12:24:46 +00:00
|
|
|
((user?.role || user?.proficiency) && user?.useCase) ||
|
2021-10-21 05:36:17 +00:00
|
|
|
shouldEnableFirstTimeUserOnboarding !== "true"
|
|
|
|
|
) {
|
|
|
|
|
redirectUsingQueryParam();
|
2022-05-04 08:43:02 +00:00
|
|
|
// Showing a loader until the redirect
|
|
|
|
|
return (
|
|
|
|
|
<Center>
|
2023-05-19 18:37:06 +00:00
|
|
|
<Spinner size="lg" />
|
2022-05-04 08:43:02 +00:00
|
|
|
</Center>
|
|
|
|
|
);
|
2021-10-21 05:36:17 +00:00
|
|
|
}
|
2023-12-25 12:24:46 +00:00
|
|
|
return <UserWelcomeScreen isSuperUser={false} onGetStarted={onGetStarted} />;
|
2021-10-21 05:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default requiresAuth(SignupSuccess);
|