From 7f0e4b209222d0c85c1e188446406c32551d947a Mon Sep 17 00:00:00 2001 From: Rishichandra Wawhal Date: Tue, 6 Dec 2022 11:38:51 +0530 Subject: [PATCH] console: hide onboarding for users who onboarded before onboarding was launched PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7168 GitOrigin-RevId: 8e119129b2a910fefd692e93a19007cdfd564bf5 --- console/src/features/OnboardingWizard/constants.ts | 4 ++++ .../src/features/OnboardingWizard/mocks/constants.ts | 10 ++++++++++ console/src/features/OnboardingWizard/types.ts | 6 ++++++ console/src/features/OnboardingWizard/utils.ts | 9 ++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/console/src/features/OnboardingWizard/constants.ts b/console/src/features/OnboardingWizard/constants.ts index b2c4c18cf02..5e42d0c140f 100644 --- a/console/src/features/OnboardingWizard/constants.ts +++ b/console/src/features/OnboardingWizard/constants.ts @@ -19,6 +19,10 @@ export const fetchAllOnboardingDataQuery = ` activity target } + users { + id + created_at + } } `; diff --git a/console/src/features/OnboardingWizard/mocks/constants.ts b/console/src/features/OnboardingWizard/mocks/constants.ts index b1948779e58..cbacd757f53 100644 --- a/console/src/features/OnboardingWizard/mocks/constants.ts +++ b/console/src/features/OnboardingWizard/mocks/constants.ts @@ -8,6 +8,11 @@ import { } from '../constants'; import { OnboardingResponseData } from '../types'; +const userMock = { + id: '59300b64-fb3a-4f17-8a0f-6f698569eade', + created_at: '2022-11-02T13:31:32.526653286Z', +}; + export const mockOnboardingData: Record< string, OnboardingResponseData['data'] @@ -22,6 +27,7 @@ export const mockOnboardingData: Record< target: 'cloud_console', }, ], + users: [userMock], }, /** * config to hide wizard as hasura data source created @@ -59,6 +65,7 @@ export const mockOnboardingData: Record< target: 'cloud_console', }, ], + users: [userMock], }, /** * config to hide wizard as run query clicked @@ -100,6 +107,7 @@ export const mockOnboardingData: Record< target: 'cloud_console', }, ], + users: [userMock], }, /** * config to hide wizard as user skipped onboarding @@ -129,6 +137,7 @@ export const mockOnboardingData: Record< target: 'cloud_console', }, ], + users: [userMock], }, /** * config to hide wizard as user completed onboarding @@ -158,6 +167,7 @@ export const mockOnboardingData: Record< target: 'cloud_console', }, ], + users: [userMock], }, }; diff --git a/console/src/features/OnboardingWizard/types.ts b/console/src/features/OnboardingWizard/types.ts index 85ba090f8c8..ef1442473d9 100644 --- a/console/src/features/OnboardingWizard/types.ts +++ b/console/src/features/OnboardingWizard/types.ts @@ -3,8 +3,14 @@ export type UserOnboarding = { target: string; }; +export type User = { + id: string; + created_at: string; +}; + export type OnboardingResponseData = { data: { user_onboarding: UserOnboarding[]; + users: User[]; }; }; diff --git a/console/src/features/OnboardingWizard/utils.ts b/console/src/features/OnboardingWizard/utils.ts index 80a696b8465..983295212ca 100644 --- a/console/src/features/OnboardingWizard/utils.ts +++ b/console/src/features/OnboardingWizard/utils.ts @@ -65,7 +65,14 @@ export function getWizardState( // if onbarding data is not present due to api error, or data loading state, then hide the wizard // this early return is required to distinguish between server errors vs data not being present for user // if the request is successful and data is not present for the given user, then we should show the onboarding wizard - if (!onboardingData) return 'hidden'; + if (!onboardingData?.data) return 'hidden'; + + // if user created account before the launch of onboarding wizard (Oct 17, 2022), + // hide the wizard and survey + const userCreatedAt = new Date(onboardingData.data.users[0].created_at); + if (userCreatedAt.getTime() < 1666008600000) { + return 'hidden'; + } // transform the onboarding data if present, to a consumable format const transformedOnboardingData = onboardingDataTransformFn(onboardingData);